Skip to content

Commit

Permalink
Added a Legal Advisor Agent (#1629)
Browse files Browse the repository at this point in the history
## 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>
  • Loading branch information
srexrg and ysolanky authored Dec 30, 2024
1 parent c6f6d86 commit c4b12bd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cookbook/examples/agents/08_legal_agent.py
Original file line number Diff line number Diff line change
@@ -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
)

0 comments on commit c4b12bd

Please sign in to comment.