Knowledge
CSV Knowledge Base
Examples
- Introduction
- Getting Started
- Agents
- Workflows
- Applications
Agent Concepts
- Multimodal
- RAG
- Knowledge
- Memory
- Teams
- Async
- Hybrid Search
- Storage
- Tools
- Vector Databases
- Embedders
Models
- Anthropic
- AWS Bedrock Claude
- Azure OpenAI
- Cohere
- DeepSeek
- Fireworks
- Gemini
- Groq
- Hugging Face
- Mistral
- NVIDIA
- Ollama
- OpenAI
- Together
- Vertex AI
- xAI
Knowledge
CSV Knowledge Base
Code
from pathlib import Path
from agno.agent import Agent
from agno.knowledge.csv import CSVKnowledgeBase
from agno.vectordb.pgvector import PgVector
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
knowledge_base = CSVKnowledgeBase(
path=Path("data/csvs"),
vector_db=PgVector(
table_name="csv_documents",
db_url=db_url,
),
num_documents=5, # Number of documents to return on search
)
# Load the knowledge base
knowledge_base.load(recreate=False)
# Initialize the Agent with the knowledge_base
agent = Agent(
knowledge=knowledge_base,
search_knowledge=True,
)
# Use the agent
agent.print_response("Ask me about something from the knowledge base", markdown=True)
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
2
Install libraries
pip install -U sqlalchemy 'psycopg[binary]' pgvector agno
3
Run PgVector
docker run -d \
-e POSTGRES_DB=ai \
-e POSTGRES_USER=ai \
-e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v pgvolume:/var/lib/postgresql/data \
-p 5532:5432 \
--name pgvector \
agnohq/pgvector:16
4
Run Agent