Examples
- Examples
- Getting Started
- Agents
- Teams
- Workflows
- Applications
- Streamlit Apps
- Evals
Agent Concepts
- Reasoning
- Multimodal
- RAG
- User Control Flows
- Knowledge
- Memory
- Async
- Hybrid Search
- Storage
- Tools
- Vector Databases
- Context
- Embedders
- Agent State
- Observability
- Miscellaneous
Models
- Anthropic
- AWS Bedrock
- AWS Bedrock Claude
- Azure AI Foundry
- Azure OpenAI
- Cerebras
- Cerebras OpenAI
- Cohere
- DeepInfra
- DeepSeek
- Fireworks
- Gemini
- Groq
- Hugging Face
- IBM
- LM Studio
- LiteLLM
- LiteLLM OpenAI
- Meta
- Mistral
- NVIDIA
- Ollama
- OpenAI
- Perplexity
- Together
- XAI
- Vercel
Tools
Reasoning Agent with Knowledge Tools
Code
cookbook/reasoning/tools/knowledge_tools.py
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.tools.knowledge import KnowledgeTools
from agno.vectordb.lancedb import LanceDb, SearchType
# Create a knowledge base containing information from a URL
agno_docs = UrlKnowledge(
urls=["https://docs.agno.com/llms-full.txt"],
# Use LanceDB as the vector database and store embeddings in the `agno_docs` table
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="agno_docs",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
)
knowledge_tools = KnowledgeTools(
knowledge=agno_docs,
think=True,
search=True,
analyze=True,
add_few_shot=True,
)
agent = Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[knowledge_tools],
show_tool_calls=True,
markdown=True,
)
if __name__ == "__main__":
# Load the knowledge base, comment after first run
agno_docs.load(recreate=True)
agent.print_response("How do I build multi-agent teams with Agno?", stream=True)
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2
Set your API key
export OPENAI_API_KEY=xxx
3
Install libraries
pip install -U openai lancedb tantivy sqlalchemy agno
4
Run Example
python cookbook/reasoning/tools/knowledge_tools.py
Assistant
Responses are generated using AI and may contain mistakes.