Astreus

Agente con knowledge base

Crea agenti con capacità di knowledge base per un recupero delle informazioni avanzato. Scopri i pattern di configurazione, le API e gli esempi pratici...

Crea agenti con capacità di knowledge base per un recupero delle informazioni avanzato.

Avvio rapido

Clona l'esempio completo

Il modo più semplice per iniziare è clonare il repository dell'esempio completo:

git clone https://github.com/astreus-ai/examples
cd examples/agent-with-knowledge
npm install

Oppure installa solo il pacchetto

Se preferisci costruire tutto da zero:

npm install @astreus-ai/astreus

Configurazione dell'ambiente

# .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.db

Agente con knowledge base

import { Agent } from '@astreus-ai/astreus';

// Create agent with knowledge enabled
const agent = await Agent.create({
  name: 'CosmosBot',
  model: 'gpt-4o',
  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 automatically

Esecuzione dell'esempio

Se hai clonato il repository:

npm run dev

Repository

L'esempio completo è disponibile su GitHub: examples/agent-with-knowledge

Ultimo aggiornamento: 6 luglio 2026