from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIChat
from agno.vectordb.lancedb import LanceDb, SearchType
knowledge = Knowledge(
vector_db=LanceDb(
table_name="recipes",
uri="tmp/lancedb",
search_type=SearchType.vector,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
knowledge.add_content(
name="Recipes",
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
)
agent = Agent(
model=OpenAIChat(id="gpt-5-mini"),
knowledge=knowledge,
add_knowledge_to_context=True,
search_knowledge=False,
markdown=True,
)
agent.print_response(
"How do I make chicken and galangal in coconut milk soup", stream=True
)
Create a virtual environment
Terminal
and create a python virtual environment.python3 -m venv .venv
source .venv/bin/activate
Set your API key
export OPENAI_API_KEY=xxx
Install libraries
pip install -U openai lancedb tantivy pypdf sqlalchemy agno
Run Agent
python cookbook/agents/rag/traditional_rag_lancedb.py