From c4b12bd226f822dc5fe80683148f152b162549bd Mon Sep 17 00:00:00 2001 From: srexrg <114612234+srexrg@users.noreply.github.com> Date: Mon, 30 Dec 2024 20:32:15 +0530 Subject: [PATCH] Added a Legal Advisor Agent (#1629) ## Description Added a legal advisor agent ## 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 - [ ] My code follows Phidata's style guidelines and best practices - [ ] I have performed a self-review of my code - [ ] 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: Yash Pratap Solanky <101447028+ysolanky@users.noreply.github.com> --- cookbook/examples/agents/08_legal_agent.py | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cookbook/examples/agents/08_legal_agent.py diff --git a/cookbook/examples/agents/08_legal_agent.py b/cookbook/examples/agents/08_legal_agent.py new file mode 100644 index 000000000..9b322fc66 --- /dev/null +++ b/cookbook/examples/agents/08_legal_agent.py @@ -0,0 +1,32 @@ +from phi.agent import Agent +from phi.knowledge.pdf import PDFUrlKnowledgeBase +from phi.model.openai import OpenAIChat +from phi.vectordb.pgvector import PgVector + +db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai" + +knowledge_base = PDFUrlKnowledgeBase( + urls=[ + "https://www.justice.gov/d9/criminal-ccips/legacy/2015/01/14/ccmanual_0.pdf", + ], + vector_db=PgVector(table_name="legal_docs", db_url=db_url), +) +knowledge_base.load(recreate=False) + +legal_agent = Agent( + name="LegalAdvisor", + knowledge=knowledge_base, + search_knowledge=True, + model=OpenAIChat(id="gpt-4o"), + markdown=True, + instructions=[ + "Provide legal information and advice based on the knowledge base.", + "Include relevant legal citations and sources when answering questions.", + "Always clarify that you're providing general legal information, not professional legal advice.", + "Recommend consulting with a licensed attorney for specific legal situations.", + ], +) + +legal_agent.print_response( + "What are the legal consequences and criminal penalties for spoofing Email Address ?", stream=True +)