https://github.com/sagarmaddela/multi-format-autonomous-ai-system
This is a multi-agent system that processes inputs from Email, JSON, and PDF, classifies both format + business intent, routes to specialized agents, and dynamically chains a follow-up action based on extracted data (e.g., triggering an alert, generating a summary, flagging a risk).
https://github.com/sagarmaddela/multi-format-autonomous-ai-system
email-parsing fastapi genai langchain llama3 llm ollama pdf-parsing python
Last synced: 2 months ago
JSON representation
This is a multi-agent system that processes inputs from Email, JSON, and PDF, classifies both format + business intent, routes to specialized agents, and dynamically chains a follow-up action based on extracted data (e.g., triggering an alert, generating a summary, flagging a risk).
- Host: GitHub
- URL: https://github.com/sagarmaddela/multi-format-autonomous-ai-system
- Owner: SagarMaddela
- License: mit
- Created: 2025-06-06T19:49:19.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-07T09:28:05.000Z (about 1 year ago)
- Last Synced: 2025-06-07T10:25:52.573Z (about 1 year ago)
- Topics: email-parsing, fastapi, genai, langchain, llama3, llm, ollama, pdf-parsing, python
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π€ Multi-Format Autonomous AI System with Contextual Decisioning & Chained Actions
A smart, multi-agent system capable of autonomously processing Emails, PDFs, and JSON inputs to classify format and business intent, extract relevant fields, and dynamically trigger follow-up actionsβwhile logging everything in a shared memory for audit and traceability.
## π Features
### π Classifier Agent
* Detects input format: `Email`, `PDF`, or `JSON`
* Identifies business intent: `RFQ`, `Complaint`, `Invoice`, `Regulation`, `Fraud Risk`
* Uses few-shot examples and schema matching
* Stores metadata in shared memory
### π© Email Agent
* Extracts sender, urgency, and request details
* Detects tone: `Polite`, `Escalation`, `Threatening`
* Triggers action:
* Escalation β `POST /crm/escalate`
* Routine β logs and closes
### π¦ JSON Agent
* Parses webhook-style JSON
* Validates schema (e.g., required fields, types)
* Flags anomalies and logs alerts to memory
### π PDF Agent
* Parses PDF using `Tika` and `PyPDF2`
* Extracts invoice or policy information
* Triggers alert if:
* Invoice total > 10,000
* Policy mentions "GDPR", "FDA", etc.
### π§ Shared Memory Store
* Maintains:
* Input metadata
* Extracted fields
* Chained actions taken
* Agent decision traces
* Implemented using Redis
### π Action Router
* Routes outcomes to simulated REST endpoints:
* `POST /crm/escalate`
* `POST /risk_alert`
* `POST /invoice/flag`
## π Project Structure
```
multi_agent_system/
ββ api/
β ββ fake_crm.py
β ββ fake_invoice_api.py
β ββ fake_risk_api.py
β ββ main.py
β ββ schemas.py
ββ classifier_agent/
β ββ agent.py
ββ email_agent/
β ββ agent.py
ββ json_agent/
β ββ agent.py
ββ logs/
ββ memory/
β ββ store.py
ββ pdf_agent/
β ββ agent.py
ββ router/
β ββ action_router.py
ββ samples/
β ββ emails/
β β ββ email_sample1.txt
β β ββ email_sample2.txt
β β ββ email_sample3.txt
β β ββ email_sample4.txt
β β ββ email_sample5.txt
β ββ json/
β β ββ webhook1.json
β β ββ webhook2.json
β β ββ webhook3.json
β β ββ webhook4.json
β β ββ webhook5.json
β ββ pdf/
β ββ invoice_sample.pdf (private)
β ββ invoice_sample2.pdf (private)
ββ tests/
β ββ test_classifier.py
β ββ test_email_agent.py
β ββ test_json_agent.py
β ββ test_pdf_agent.py
ββ utils/
β ββ llm_utils.py
ββ .gitignore
ββ docker-compose.yml
ββ Dockerfile
ββ LICENSE
ββ README.md
ββ requirements.txt
ββ supervisord.conf
```
---
## π‘ Example Workflow
1. User uploads an Email.
2. **Classifier Agent** β Detects: `Email` + `Complaint`
3. **Email Agent** β Tone: `Angry`, Urgency: `High`
4. **Action Router** β Calls `POST /crm/escalate`
5. **Memory** β Logs full trace for audit
---
## π§ͺ Sample Inputs
* `email_sample1.txt`: Escalated complaint email
* `invoice_sample.pdf`: Invoice with line items
* `webhook1.json`: Webhook with anomalies
---
## πΈ Screenshots
| Email Classification | PDF Invoice Parsing | JSON Anomaly |
| ------------------------------- | --------------------------- | ----------------------------- |
|  |  |  |
---
## Detailed Working Video

---
## π Tech Stack
* **Python** + **FastAPI** for microservice architecture
* **LangChain** + **llama3** LLMs for intent classification and field extraction
* **PyPDF2** for PDF parsing
* **Redis** for shared memory
* **Docker** for containerization
---
## π§° How to Run
```bash
# 1. Clone the repository
git clone https://github.com/SagarMaddela/Multi-Format-Autonomous-AI-System.git
cd Multi-Format-Autonomous-AI-System
# 2. Install and run the LLaMA3 model using Ollama
# (Make sure Ollama is installed: https://ollama.com)
ollama pull llama3
ollama run llama3
```
---
## π³ Docker
```bash
docker compose up --build
```
## Postman or curl
# Make a GET request
GET/http://localhost:8000/ - Then u will get a response like this
```bash
{
"message": "Classifier API is up and running"
}
```
# Make a POST request
POST/http://localhost:8000/classify -->
Go to body --> form-data --> Change the key to file and attach your sample file (email/pdf/json) as value , then u will get some response like this ( A sample response )
```bash
{
"classification": {
"format": "email",
"intent": "complaint",
"confidence": 0.9,
"trace_id": "6aadf26f-0260-4c0b-b4df-97a635974fe0",
"logged_at": "2025-06-07T17:47:32.233307"
},
"agent_output": {
"urgency": "high",
"type": "complaint",
"tone": "angry",
"trigger_action": true,
"action": "escalated",
"agent": "EmailAgent",
"trace_id": "4e328014-47d1-4b40-b0c6-509b63bdd6d3",
"logged_at": "2025-06-07T17:47:50.759806"
},
"action_output": {
"action_triggered": "escalate",
"target_url": "http://localhost:9000/crm/escalate",
"status_code": 200,
"trace_id": "b282fc0c-14a8-4923-8241-78bf41c02950",
"timestamp": "2025-06-07T17:47:50.764720",
"logged_at": "2025-06-07T17:47:50.764763"
}
}
```
## π§ Agent Flow Diagram
```bash
+-----------+
| Input |
+-----------+
|
|
|
+-----------------------------------------------------------------------+
| SHARED MEMORY | |
| | |
| | |
| +-----------+ |
| | Classifier| |
| | Agent | |
| +-----------+ |
| | |
| | |
| ------------------------------------------------ |
| | | | |
| | | | |
| +-----------+ +-----------+ +-----------+ |
| | Email | | Json | | PDF | |
| | Agent | | Agent | | Agent | |
| +-----------+ +-----------+ +-----------+ |
| \ | / |
| \ | / |
| \ | / |
| +---------------------------------------------+ |
| | Action Router | |
| +---------------------------------------------+ |
| |
+----------------------------------------------------------------------+
```
---
## π¨βπ» Developed By
Sagar Maddela
venkatasagar.maddela2004@gmail.com
---
## π License
This project is licensed under the MIT License.
---
## π Acknowledgements
Special thanks to Flowbit Private Limited for providing the challenge specification.
For questions or contributions, feel free to raise an issue or pull request!
All rights reserved Β© 2025