Documentation Index
Fetch the complete documentation index at: https://agno-v2-shaloo-ai-support-link.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Knowledge gives your agent information it can search at runtime. This pattern is known as Agentic RAG. The agent decides when to search based on the user’s question.
Create a Python file
from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIResponses
from agno.vectordb.lancedb import LanceDb, SearchType
knowledge = Knowledge(
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="recipes",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
# Load a PDF into the knowledge base
knowledge.insert(
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
)
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
knowledge=knowledge,
instructions="Search your knowledge base for Thai recipes. Be concise.",
markdown=True,
)
agent.print_response("How do I make Pad Thai?", stream=True)
agent.print_response("What ingredients do I need for green curry?", stream=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
Install dependencies
uv pip install -U agno openai lancedb tantivy pypdf
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
Run Agent
python agent_with_knowledge.py
How It Works
- Knowledge base: Documents are chunked, embedded, and stored in a vector database
- Search: Agent searches the knowledge base using hybrid search (semantic + keyword)
- Context: Relevant chunks are added to context before generating a response
Adding Different Content Types
# From a URL
knowledge.insert(url="https://example.com/document.pdf")
# From a local file
knowledge.insert(path="./documents/guide.pdf")
# From text
knowledge.insert(text="Your content here...")