What You’ll Build
By the end of this tutorial, you’ll have an agent that can:- Read and understand your documents or website content
- Answer specific questions based on that information
- Provide sources for its responses
- Search intelligently without you having to specify what to look for
Prerequisites
1
Install Agno
2
Set up your API key
This tutorial uses OpenAI, but Agno supports many other models.
Step 1: Set Up Your Knowledge Base
First, let’s create a knowledge base with a vector database to store your information:knowledge_agent.py
Don't have PostgreSQL? Use LanceDB instead
Don't have PostgreSQL? Use LanceDB instead
For a quick start without setting up PostgreSQL, use LanceDB which stores data locally:
Step 2: Add Your Content
Now let’s add some knowledge to your agent. You can add content from various sources:- From Local Files
- From URLs
- From Text
Step 3: Chat with Your Agent
That’s it! Your agent is now ready to answer questions based on your content:Complete Example
Here’s the full working example:knowledge_agent.py
What Just Happened?
When you ran the code, here’s what occurred behind the scenes:- Content Processing: Your text was chunked into smaller pieces and converted to vector embeddings
- Intelligent Search: The agent analyzed your question and searched for relevant information
- Contextual Response: The agent combined the retrieved knowledge with your question to provide an accurate answer
- Source Attribution: The response is based on your specific content, not generic training data
Next Steps: Explore Advanced Features
Content Types
Learn about different ways to add content: files, URLs, databases, and more.
Chunking Strategies
Optimize how your content is broken down for better search results.
Vector Databases
Choose the right storage solution for your needs and scale.
Search Types
Explore different search strategies: vector, keyword, and hybrid search.
Troubleshooting
Agent isn't using knowledge in responses
Agent isn't using knowledge in responses
Make sure you set
search_knowledge=True
when creating your agent and consider adding explicit instructions to search the knowledge base.Vector database connection errors
Vector database connection errors
For local development, try LanceDB instead of PostgreSQL. For production, ensure your database connection string is correct.
Content not being found in searches
Content not being found in searches
Your content might need better chunking. Try different chunking strategies or smaller chunk sizes for more precise retrieval.
Ready for Core Concepts?
Dive deeper into understanding knowledge bases and how they power intelligent agents