Agente con base de conocimiento
Crea agentes con capacidades de base de conocimiento para una recuperación de información mejorada.
Inicio rápido#
Clonar el ejemplo completo#
La forma más sencilla de empezar es clonar el repositorio del ejemplo completo:
git clone https://github.com/astreus-ai/examples
cd examples/agent-with-knowledge
npm installO instalar solo el paquete#
Si prefieres construirlo desde cero:
npm install @astreus-ai/astreusConfiguración del entorno#
# .env
# LLM API key
OPENAI_API_KEY=sk-your-openai-api-key-here
# Knowledge database (required for RAG)
KNOWLEDGE_DB_URL=postgresql://username:password@localhost:5432/knowledge_db
# Main database for agent persistence
DB_URL=sqlite://./astreus.dbAgente con base de conocimiento#
import { Agent } from '@astreus-ai/astreus';
// Create agent with knowledge enabled
const agent = await Agent.create({
name: 'CosmosBot',
model: 'gpt-6-astra',
embeddingModel: 'text-embedding-3-small', // Specify embedding model directly
knowledge: true,
systemPrompt: 'You can search and retrieve information from scientific knowledge bases about the cosmos and universe.'
});
// Add knowledge from scientific book about the sun and cosmos
await agent.addKnowledgeFromFile(
'./data/The Sun\'s Light and Heat.pdf',
{ category: 'solar-physics', version: '1.0' }
);
// Agent automatically uses knowledge in conversations
const response = await agent.ask("What is Correction for Atmospheric Absorption? Explain.");
console.log(response); // Uses knowledge base automaticallyEjecutar el ejemplo#
Si clonaste el repositorio:
npm run devRepositorio#
El ejemplo completo está disponible en GitHub: examples/agent-with-knowledge