Spaces:
Runtime error
Runtime error
File size: 2,924 Bytes
aa8170a ac5468a 33ffec6 | 1 2 3 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | ---
title: EmailAgentwithMemory
emoji: π¦
colorFrom: green
colorTo: indigo
sdk: docker
pinned: false
license: apache-2.0
short_description: Email ai agent project with memory.
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
# π§ AI-Driven Email Agent π§
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.
---
## π Key Features
- **Advanced Learning Implementation**
Implemented **Semantic Memory**, **Checkpointer Persistence**, and **Functional Interrupts**, enabling the agent to maintain state and handle user feedback reliably.
- **Multi-Agent Workflow**
Specialized agents for:
- Triage
- Context Synthesis
- Email Drafting
- **Intelligent Triage**
Automatically classifies emails, assigns priority, and determines if a reply is required.
- **Semantic Memory**
Uses `langmem` and `PostgresStore` to retrieve past interactions, allowing the agent to remember previous project details.
- **Resource Management**
A dedicated **Token Count Node** ensures large emails (e.g., deployment logs) are summarized before processing to optimize costs.
- **Human-in-the-Loop**
The graph pauses using `interrupt()` to allow users to:
- Review drafts
- Approve responses
- Provide feedback via `Command(resume=...)`
- **Scalable Architecture**
Built with **FastAPI**, **Docker**, and a modular structure for enterprise-grade deployment.
---
## π οΈ Tech Stack
- **Orchestration:** `langgraph` (Functional API), `langchain`
- **LLM Interface:** `langchain-groq`
- **Memory & Persistence:**
- `langmem`
- `PostgresCheckpoint`
- `PostgresStore` (Neon/PostgreSQL)
- **Database ORM:** SQLAlchemy 2.0
- **Embeddings:** `langchain_huggingface` (DistilBERT)
- **Backend:** FastAPI + Uvicorn
- **Configuration:** `pydantic-settings` (.env management)
- **Authentication:** `google-auth` (Gmail API Integration)
---
## π Project Structure
```bash
app/
βββ agents/ # Brains: Specialized LLM logic (Triage, Writer, Context)
βββ database/ # Data: SQLAlchemy models and Connection Pooling
βββ nodes/ # Workflow: Functional steps of the graph (Safety, Tokens)
βββ persistance/ # Persistence: Postgres Checkpointer & Memory Store config
βββ state/ # Schema: Pydantic & TypedDict state definitions
βββ utils/ # Toolbox: Token counters, Embeddings, and Auth helpers
βββ graph.py # Logic: StateGraph construction and compilation
βββ main.py # Entry: FastAPI app and Controller logic
|