Spaces:
Runtime error
Runtime error
chnages
Browse files- github_readme.md +41 -53
github_readme.md
CHANGED
|
@@ -1,43 +1,59 @@
|
|
| 1 |
-
π§ AI-Driven Email Agent π§
|
| 2 |
|
| 3 |
-
A production-grade, multi-agent system built with LangGraph and FastAPI that automates email triage, context retrieval, and drafting. This project demonstrates advanced implementation of Long-term Memory, State Persistence, and Human-in-the-Loop Interrupts using LangGraph's Functional API Command pattern.
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
Backend: FastAPI + Uvicorn
|
| 34 |
-
|
| 35 |
-
Configuration: pydantic-settings (Type-safe .env management)
|
| 36 |
-
|
| 37 |
-
Authentication: google-auth (Gmail API Integration)
|
| 38 |
-
|
| 39 |
-
π Project Structure
|
| 40 |
|
|
|
|
| 41 |
app/
|
| 42 |
βββ agents/ # Brains: Specialized LLM logic (Triage, Writer, Context)
|
| 43 |
βββ database/ # Data: SQLAlchemy models and Connection Pooling
|
|
@@ -46,32 +62,4 @@ app/
|
|
| 46 |
βββ state/ # Schema: Pydantic & TypedDict state definitions
|
| 47 |
βββ utils/ # Toolbox: Token counters, Embeddings, and Auth helpers
|
| 48 |
βββ graph.py # Logic: StateGraph construction and compilation
|
| 49 |
-
βββ main.py # Entry: FastAPI app and Controller logic
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
π Graph Architecture
|
| 53 |
-
|
| 54 |
-
The system follows a pre-processing pipeline before reaching the agentic loop:
|
| 55 |
-
|
| 56 |
-
Safety Check: Filters out malicious content.
|
| 57 |
-
|
| 58 |
-
Token Check: Routes large bodies to a Summarization Node.
|
| 59 |
-
|
| 60 |
-
Triage: Analyzes intent and priority.
|
| 61 |
-
|
| 62 |
-
Context Retrieval: Queries PostgresStore for relevant past facts.
|
| 63 |
-
|
| 64 |
-
Drafting Agent: Creates a reply based on the full context.
|
| 65 |
-
|
| 66 |
-
Interrupt: Pauses for User Review and feedback.
|
| 67 |
-
|
| 68 |
-
π‘οΈ Integrated Security
|
| 69 |
-
|
| 70 |
-
The safety classification in this agent is informed by my specialized project on threat detection:
|
| 71 |
-
|
| 72 |
-
Hybrid Phishing Detection Model: GitHub Repository
|
| 73 |
-
|
| 74 |
-
π¨βπ» Author
|
| 75 |
-
|
| 76 |
-
Atharva Gaykar AI Engineer | IIIT Nagpur
|
| 77 |
-
|
|
|
|
| 1 |
+
# π§ AI-Driven Email Agent π§
|
| 2 |
|
| 3 |
+
A production-grade, multi-agent system built with LangGraph and FastAPI that automates email triage, context retrieval, and drafting. This project demonstrates advanced implementation of **Long-term Memory**, **State Persistence**, and **Human-in-the-Loop Interrupts** using LangGraph's Functional API Command pattern.
|
| 4 |
|
| 5 |
+
---
|
| 6 |
|
| 7 |
+
## π Key Features
|
| 8 |
|
| 9 |
+
- **Advanced Learning Implementation**
|
| 10 |
+
Implemented **Semantic Memory**, **Checkpointer Persistence**, and **Functional Interrupts**, enabling the agent to maintain state and handle user feedback reliably.
|
| 11 |
|
| 12 |
+
- **Multi-Agent Workflow**
|
| 13 |
+
Specialized agents for:
|
| 14 |
+
- Triage
|
| 15 |
+
- Context Synthesis
|
| 16 |
+
- Email Drafting
|
| 17 |
|
| 18 |
+
- **Intelligent Triage**
|
| 19 |
+
Automatically classifies emails, assigns priority, and determines if a reply is required.
|
| 20 |
|
| 21 |
+
- **Semantic Memory**
|
| 22 |
+
Uses `langmem` and `PostgresStore` to retrieve past interactions, allowing the agent to remember previous project details.
|
| 23 |
|
| 24 |
+
- **Resource Management**
|
| 25 |
+
A dedicated **Token Count Node** ensures large emails (e.g., deployment logs) are summarized before processing to optimize costs.
|
| 26 |
|
| 27 |
+
- **Human-in-the-Loop**
|
| 28 |
+
The graph pauses using `interrupt()` to allow users to:
|
| 29 |
+
- Review drafts
|
| 30 |
+
- Approve responses
|
| 31 |
+
- Provide feedback via `Command(resume=...)`
|
| 32 |
|
| 33 |
+
- **Scalable Architecture**
|
| 34 |
+
Built with **FastAPI**, **Docker**, and a modular structure for enterprise-grade deployment.
|
| 35 |
|
| 36 |
+
---
|
| 37 |
|
| 38 |
+
## π οΈ Tech Stack
|
| 39 |
|
| 40 |
+
- **Orchestration:** `langgraph` (Functional API), `langchain`
|
| 41 |
+
- **LLM Interface:** `langchain-groq`
|
| 42 |
+
- **Memory & Persistence:**
|
| 43 |
+
- `langmem`
|
| 44 |
+
- `PostgresCheckpoint`
|
| 45 |
+
- `PostgresStore` (Neon/PostgreSQL)
|
| 46 |
+
- **Database ORM:** SQLAlchemy 2.0
|
| 47 |
+
- **Embeddings:** `langchain_huggingface` (DistilBERT)
|
| 48 |
+
- **Backend:** FastAPI + Uvicorn
|
| 49 |
+
- **Configuration:** `pydantic-settings` (.env management)
|
| 50 |
+
- **Authentication:** `google-auth` (Gmail API Integration)
|
| 51 |
|
| 52 |
+
---
|
| 53 |
|
| 54 |
+
## π Project Structure
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
```bash
|
| 57 |
app/
|
| 58 |
βββ agents/ # Brains: Specialized LLM logic (Triage, Writer, Context)
|
| 59 |
βββ database/ # Data: SQLAlchemy models and Connection Pooling
|
|
|
|
| 62 |
βββ state/ # Schema: Pydantic & TypedDict state definitions
|
| 63 |
βββ utils/ # Toolbox: Token counters, Embeddings, and Auth helpers
|
| 64 |
βββ graph.py # Logic: StateGraph construction and compilation
|
| 65 |
+
βββ main.py # Entry: FastAPI app and Controller logic
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|