M-N-S/ai-email-agent
0
๐ค AI Email Agent โ Interactive Training & Simulation
A smart AI-powered platform that simulates how intelligent agents read, classify, and act on emails โ with step-by-step execution and transparent scoring.
๐ Overview
Most email systems stop at classification.
This project goes further by simulating a complete decision-making workflow, where an AI agent:
- Reads emails
- Classifies them
- Decides actions (reply / archive / escalate)
- Processes emails sequentially
- Produces a final performance score
Unlike traditional systems, every step is visible and measurable, making it easier to understand how decisions are made.
๐ฏ What This Project Demonstrates
- Sequential decision-making in AI systems
- How agents move beyond prediction to action
- The importance of workflow order and efficiency
- The role of fallback systems in real-world reliability
โจ Key Features
๐ฏ Training Mode (Interactive Setup)
- Select inbox size:
- Starter โ 5 emails
- Medium โ 10 emails
- Advanced โ 15 emails
- Preview all emails before execution
- Understand the dataset before running the agent
โถ๏ธ Step-by-Step Execution (Core Highlight)
Run the simulation and observe:
- Emails processed one-by-one
- For each email:
- Subject
- Classification
- Action taken
- Reward earned
This ensures complete transparency of agent behavior.
๐ Analyze Email (Custom Input)
- Input any custom email
- System returns:
- Predicted email type
- Suggested action
System behavior:
- Uses Gemini API (primary)
- Falls back to internal agent if unavailable
๐ค Hybrid AI System
๐ข Fallback Agent (Default)
- Fast and reliable
- No external API required
- Handles the majority of emails
๐ต Gemini API (Advanced Layer)
- Used selectively for:
- Complex inputs
- High-uncertainty cases
- Response generation
๐ Automatic Fallback (Reliability Layer)
If API fails due to:
- Rate limits
- Invalid key
- Timeout
๐ System automatically switches to fallback ๐ Execution continues without interruption
โก Performance-Focused Design
- Fast execution
- Minimal latency
- Efficient API usage
๐จ UI Experience
- Dark-themed interface
- Clean and readable layout
- Designed for clarity during step-by-step execution
๐ง How It Works
Step 1
User selects inbox size
Step 2
System displays all emails
Step 3
User runs the simulation
Step 4
Agent processes emails sequentially:
Email โ Classification โ Action โ RewardStep 5
Final score is calculated and displayed
๐ Scoring System
Each run is evaluated across the following dimensions:
โ๏ธ Run Locally
git clone https://github.com/your-username/ai-email-agent.git
cd ai-email-agentpip install -r requirements.txt# Optional (for advanced AI features)
set GEMINI_API_KEY=your_key_herestreamlit run app.py๐งช CLI Mode
Run without UI:
python inference.py๐ณ Docker
docker build -t ai-email-agent .
docker run -p 8501:8501 ai-email-agent๐ Deployment (Hugging Face)
- Create a Streamlit Space
- Push this repository
- Ensure
requirements.txtis included
Optional:
- Add
GEMINI_API_KEYin repository secrets
๐ Project Structure
EmailEnv/
โโโ app.py
โโโ inference.py
โโโ agent.py
โโโ models/
โโโ tests/
โโโ requirements.txt
โโโ Dockerfile
โโโ README.md๐ง Core Components Explained
- app.py Handles the Streamlit UI, user interaction, and visualization of the simulation.
- agent.py Implements the core logic for classification and action selection, including fallback and API integration.
- inference.py Runs the simulation in CLI mode without UI.
- models/ Contains data structures and representations used across the system.
- tests/ Includes test cases to validate system functionality.
๐ฏ What Makes This Project Stand Out
- Moves beyond classification โ full workflow simulation
- Step-by-step explainable AI system
- Hybrid architecture (API + fallback)
- Interactive and beginner-friendly
- Designed for reliability and real-world behavior
๐ง Learnings
- Fallback systems are essential for robust AI applications
- Not all problems require heavy AI models
- Transparency improves trust in AI systems
- Workflow design is as important as prediction accuracy
๐จโ๐ป Author
Sumanth Mamidi
๐ License
MIT License
