-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description - This PR adds CSVUrlKnowledgeBase that allows to loading csv files from a URL ## Type of change Please check the options that are relevant: - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Model update - [ ] Infrastructure change ## Checklist - [x] My code follows Phidata's style guidelines and best practices - [ ] I have performed a self-review of my code - [x] I have added docstrings and comments for complex logic - [ ] My changes generate no new warnings or errors - [ ] I have added cookbook examples for my new addition (if needed) - [ ] I have updated requirements.txt/pyproject.toml (if needed) - [ ] I have verified my changes in a clean environment ## Additional Notes Include any deployment notes, performance implications, or other relevant information: --------- Co-authored-by: Dirk Brand <dirk@volter.ai>
- Loading branch information
1 parent
a2497d4
commit e5c11ac
Showing
7 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from phi.agent import Agent | ||
from phi.knowledge.csv import CSVUrlKnowledgeBase | ||
from phi.vectordb.pgvector import PgVector | ||
|
||
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai" | ||
|
||
knowledge_base = CSVUrlKnowledgeBase( | ||
urls=["https://phi-public.s3.amazonaws.com/csvs/employees.csv"], | ||
vector_db=PgVector(table_name="csv_documents", db_url=db_url), | ||
) | ||
knowledge_base.load(recreate=False) # Comment out after first run | ||
|
||
agent = Agent( | ||
knowledge_base=knowledge_base, | ||
search_knowledge=True, | ||
) | ||
|
||
agent.print_response("What is the average salary of employees in the Marketing department?", markdown=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters