Files
agno/cookbook/agent_concepts/knowledge/csv_kb.py
T
KaustubhandDirk Brand 90b04c5515 async support for csv reader and kb with tests (#2626)
## Summary

add `csv` and `csv url` reader and kb with tests

## Type of change

- [ ] Bug fix (If applicable, issue number: #____)
- [x] New feature
- [ ] Breaking change
- [ ] Improvement
- [ ] Model update
- [ ] Other: _____________________

---

## Checklist

- [x] Code complies with style guidelines
- [x] Ran format/validation scripts (`./scripts/format.sh` and
`./scripts/validate.sh`)
- [x] Self-review completed
- [x] Documentation updated (comments, docstrings)
- [x] Examples and guides: Relevant cookbook examples have been included
or updated (if applicable)
- [x] Tested in clean environment
- [x] Tests added/updated (if applicable)

---

## Additional Notes

Add any important context (deployment instructions, screenshots,
security considerations, etc.)

---------

Co-authored-by: Dirk Brand <[email protected]>
2025-04-02 15:16:49 +02:00

28 lines
711 B
Python

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)