Examples
Agent with Knowledge
Hackathon Resources
- Introduction
- Setup
- Examples
- Simple Text Agent
- Agent with Tools
- Agent with Knowledge
- Agent with Structured Outputs
- Research Agent
- YouTube Agent
- Image Input + Tools
- Image Generation using DALL-E
- Image to Structured Output
- Image Generate Audio
- Image Input + Output
- Image Transcription
- Image search using Giphy
- Audio Input
- Audio Input Output
- Audio Sentiment
- Audio Transcript
- Audio Multi Turn
- Audio Generate Podcast
- Video Input
- Video Generation with Models Lab
- Video Generation with Replicate
- Video Captions
- Video to Shorts
- Models
- Pre-built Replit Template
- 🏆 Prizes
Examples
Agent with Knowledge
This agent takes a text input, searches its knowledge base using Agentic RAG and responds with a text output.
agent_with_knowledge.py
from textwrap import dedent
from agno.agent import Agent
from agno.embedder.openai import OpenAIEmbedder
from agno.knowledge.url import UrlKnowledge
from agno.models.openai import OpenAIChat
from agno.vectordb.lancedb import LanceDb, SearchType
agent_knowledge = UrlKnowledge(
urls=["https://docs.agno.com/llms-full.txt"],
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="agno_docs",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
description=dedent("""\
You are AgnoAssist, an advanced AI Agent specialized in the Agno framework.
Your goal is to help developers effectively use Agno by providing explanations and working code examples"""),
instructions=dedent("""\
1. Analyze the request
2. Search your knowledge base for relevant information
3. Present the information to the user\
"""),
knowledge=agent_knowledge,
add_datetime_to_instructions=True,
show_tool_calls=True,
markdown=True,
)
if __name__ == "__main__":
load_knowledge = False
if load_knowledge:
agent_knowledge.load()
agent.print_response(
"What is Agno and how do I implement Agentic RAG?", stream=True
)
Usage
1
Install libraries
pip install -U agno openai lancedb tantivy
2
Export API keys
export OPENAI_API_KEY=***
3
Run the agent
python agent_with_knowledge.py
On this page