This example demonstrates how to create a specialized AI agent that provides legal information and guidance based on a knowledge base of legal documents. The Legal Consultant agent is designed to help users understand legal concepts, consequences, and procedures by leveraging a vector database of legal content.Key Features:
Legal Knowledge Base: Integrates with a PostgreSQL vector database containing legal documents and resources
Document Processing: Automatically ingests and indexes legal PDFs from authoritative sources (e.g., Department of Justice manuals)
Contextual Responses: Provides relevant legal information with proper citations and sources
Professional Disclaimers: Always clarifies that responses are for informational purposes only, not professional legal advice
Attorney Referrals: Recommends consulting licensed attorneys for specific legal situations
Use Cases:
Legal research and education
Understanding criminal penalties and consequences
Learning about legal procedures and requirements
Getting preliminary legal information before consulting professionals
import asynciofrom agno.agent import Agentfrom agno.knowledge.knowledge import Knowledgefrom agno.models.openai import OpenAIChatfrom agno.vectordb.pgvector import PgVectordb_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"knowledge = Knowledge( vector_db=PgVector(table_name="legal_docs", db_url=db_url),)asyncio.run( knowledge.add_content_async( url="https://www.justice.gov/d9/criminal-ccips/legacy/2015/01/14/ccmanual_0.pdf", ))legal_agent = Agent( name="LegalAdvisor", knowledge=knowledge, search_knowledge=True, model=OpenAIChat(id="gpt-5-mini"), 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,)