Skip to main content
Knowledge bases allow agents to ground their responses in your documents. This is essential for building agents that can answer questions about your specific data.

What is a knowledge base?

A knowledge base stores and retrieves documents:
  • Documents are chunked and embedded
  • Vector database stores embeddings for similarity search
  • Agents can search the knowledge base with agentic RAG

Quick example

from agno.agent import Agent
from agno.knowledge import Knowledge
from agno.vectordb.pgvector import PgVector

# Create knowledge base
knowledge = Knowledge(
    path="docs/",
    vector_db=PgVector(
        table_name="agno_docs",
        db_url="postgresql://localhost/agno"
    )
)

# Load documents
knowledge.load(recreate=False)

# Create agent with knowledge
agent = Agent(
    knowledge=knowledge,
    search_knowledge=True,
    add_knowledge_to_context=True
)

response = agent.run("What is Agno?")

Using ChromaDB (development)

from agno.knowledge import Knowledge
from agno.vectordb.chroma import ChromaDb

knowledge = Knowledge(
    path="docs/",
    vector_db=ChromaDb(
        collection="docs",
        path="./chroma_db"
    )
)

knowledge.load()
See cookbook examples for complete patterns.

Build docs developers (and LLMs) love