👨⚖️ AI Legal Agent Team
A beautiful, friendly app that reads your legal PDFs and lets a team of smart AI helpers analyze them for you.
🚀 Quick Start • 🛠️ Detailed Setup • 🧯 Help
A Streamlit application that simulates a full-service legal team using multiple AI agents to analyze legal documents and provide comprehensive legal insights. Each agent represents a different legal specialist role, from research and contract analysis to strategic planning, working together to provide thorough legal analysis and recommendations.
🗂️ Table of Contents
- Features
- How to Run
- 🚀 Super-Simple Setup (So easy a 5‑year‑old can follow!)
- 🎯 What this app does
- 🧪 Supported Models & Services
- 🛠️ Detailed Setup (Grown‑ups)
- 🧭 How it works
- 🧯 Troubleshooting
- ❓ FAQ
- 🌟 Make it yours
- 📸 Pretty Buttons
Features
-
Specialized Legal AI Agent Team
-
Legal Researcher: Equipped with DuckDuckGo search tool to find and cite relevant legal cases and precedents. Provides detailed research summaries with sources and references specific sections from uploaded documents.
-
Contract Analyst: Specializes in thorough contract review, identifying key terms, obligations, and potential issues. References specific clauses from documents for detailed analysis.
-
Legal Strategist: Focuses on developing comprehensive legal strategies, providing actionable recommendations while considering both risks and opportunities.
-
Team Lead: Coordinates analysis between team members, ensures comprehensive responses, properly sourced recommendations, and references to specific document parts. Acts as an Agent Team coordinator for all three agents.
-
-
Document Analysis Types
- Contract Review - Done by Contract Analyst
- Legal Research - Done by Legal Researcher
- Risk Assessment - Done by Legal Strategist, Contract Analyst
- Compliance Check - Done by Legal Strategist, Legal Researcher, Contract Analyst
- Custom Queries - Done by Agent Team - Legal Researcher, Legal Strategist, Contract Analyst
How to Run
-
Setup Environment
bash# Clone the repository git clone "repo link" cd advanced_ai_agents/multi_agent_apps/agent_teams/ai_legal_agent_team # Install dependencies pip install -r requirements.txt -
Configure API Keys
- Get OpenAI API key from OpenAI Platform
- Get Qdrant API key and URL from Qdrant Cloud
-
Run the Application
bashstreamlit run legal_agent_team.py -
Use the Interface
- Enter API credentials
- Upload a legal document (PDF)
- Select analysis type
- Add custom queries if needed
- View analysis results
🚀 Super-Simple Setup (So easy a 5‑year‑old can follow!)
-
🧰 What you need
- A computer with internet
- Python 3.10+
- An OpenAI key and a Qdrant account (don’t worry, steps below!)
-
🎁 Get the tools
-
📦 Install
bashpip install -r requirements.txt -
🔐 Put your secrets in a magic box (.env) Create a file named
.envin the project folder and add:iniOPENAI_API_KEY=your_openai_api_key_here QDRANT_URL=https://YOUR-CLUSTER-URL.qdrant.io QDRANT_API_KEY=your_qdrant_api_key_here -
▶️ Run the app
bashstreamlit run legal_agent_team.py -
🖱️ Click & Go
- Paste keys if not auto-filled
- Upload a PDF
- Pick an analysis
- Press Analyze → ✨ Magic!
🎯 What this app does (Like story time!)
- 📄 You give it a PDF (a contract or legal doc)
- 🧠 The app reads it and remembers the important bits
- 🤖 Three helpful AI friends look at it:
- 🕵️ Legal Researcher: finds references and cases
- 🧾 Contract Analyst: spots key terms and issues
- 🧭 Legal Strategist: gives smart next steps
- 🧩 A Team Lead combines all answers into one helpful result
🧪 Supported Models & Services
- 🔊 Chat model:
gpt-4o(via OpenAI) - 🧩 Embeddings:
text-embedding-3-small(via OpenAI) - 🧠 Vector database: Qdrant Cloud
- 🔎 Web search: DuckDuckGo (no key needed)
Tip: Using a local stack? See
local_ai_legal_agent_team/local_legal_agent.py(Ollama + local Qdrant).
🛠️ Detailed Setup (Grown‑ups section)
- Create accounts/keys
- OpenAI → create a project and API key
- Qdrant Cloud → create a cluster, copy HTTPS URL + API key
- Configure
.env
- Put
OPENAI_API_KEY,QDRANT_URL,QDRANT_API_KEY - The app auto-loads them on start via
python-dotenv
- Install Python deps
bashpip install -r requirements.txt
- Launch
bashstreamlit run legal_agent_team.py
🧭 How it works (Under the hood)
- You upload a PDF → it’s turned into chunks
- 📚 Chunks get embeddings (OpenAI) → stored in Qdrant
- 🔎 When you ask, agents search the knowledge base
- 🧩 Team Lead merges answers → you get a clean report
🗃️ Repository Structure
textai_legal_agent_team/ ├─ legal_agent_team.py # Main Streamlit app (OpenAI + Qdrant Cloud) ├─ local_ai_legal_agent_team/ │ ├─ local_legal_agent.py # Local app (Ollama + local Qdrant) │ └─ requirements.txt ├─ requirements.txt # Python dependencies ├─ README.md # You are here 📘 └─ .gitignore # Keeps secrets and junk out of git
🧰 Advanced: Local (No OpenAI) Setup
Run fully local with Ollama + local Qdrant (click to expand)
- Install and start Qdrant locally (Docker)
bashdocker run -p 6333:6333 -p 6334:6334 qdrant/qdrant
- Install Ollama and pull models
bashhttps://ollama.com/download ollama pull llama3.1:8b ollama pull openhermes
- Install deps for local app and run
bashpip install -r local_ai_legal_agent_team/requirements.txt streamlit run local_ai_legal_agent_team/local_legal_agent.py
🧯 Troubleshooting
- “ddgs not installed” → run:
pip install -r requirements.txt - “Failed to connect to Qdrant” → check
QDRANT_URL&QDRANT_API_KEY - “OpenAI key invalid” → verify billing and key value in
.env - Blank results → ensure your PDF has selectable text (not just images)
❓ FAQ
- Can I use it without OpenAI?
- Yes, try the local app in
local_ai_legal_agent_team/(Ollama + local Qdrant)
- Yes, try the local app in
- What files are supported?
- PDFs for now
- Is there a cost?
- OpenAI and Qdrant usage may incur costs
🌟 Make it yours
- Change model: edit
OpenAIChat(id="gpt-4o") - Change embedding: edit
text-embedding-3-small - Add new agents or tools using
agno
❤️ Credits
- Built with Streamlit, Agno, OpenAI, Qdrant, DuckDuckGo
🤝 Contributing
- Fork this repo
- Create a feature branch:
git checkout -b feat/amazing-idea - Commit changes:
git commit -m "feat: add amazing idea" - Push:
git push origin feat/amazing-idea - Open a Pull Request 🚀
📜 License
This project is open-source. Add your preferred license in a LICENSE file.
⭐ Star this repo
If this helped you, please star the repo — it motivates continued improvements!