# Agent with Knowledge URL: /docs/examples/agent-with-knowledge Source: /app/src/content/docs/examples/agent-with-knowledge.mdx import { DocImage } from '@/components/DocImage'; Create agents with knowledge base capabilities for enhanced information retrieval. ## Quick Start ### Clone the Complete Example The easiest way to get started is to clone the complete example repository: ```bash git clone https://github.com/astreus-ai/agent-with-knowledge cd agent-with-knowledge npm install ``` ### Or Install Package Only If you prefer to build from scratch: ```bash npm install @astreus-ai/astreus ``` ## Environment Setup ```bash # .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 ``` ## Knowledge Agent ```typescript 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 ``` ## Running the Example If you cloned the repository: ```bash npm run dev ``` ## Repository The complete example is available on GitHub: [astreus-ai/agent-with-knowledge](https://github.com/astreus-ai/agent-with-knowledge)