CoolFace
Apppublic

M-N-S/ai-email-agent

sourceHugging Faceupdated 1mo agoView on Hugging Face
0likes
App README

๐Ÿค– 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:

id="flow_block"
Email โ†’ Classification โ†’ Action โ†’ Reward

Step 5

Final score is calculated and displayed


๐Ÿ“Š Scoring System

Each run is evaluated across the following dimensions:

MetricDescription
ClassificationAccuracy of labels
ActionCorrect decision-making
WorkflowLogical order of actions
EfficiencyOptimal step usage

โš™๏ธ Run Locally

bash id="setup_1"
git clone https://github.com/your-username/ai-email-agent.git
cd ai-email-agent
bash id="setup_2"
pip install -r requirements.txt
bash id="setup_3"
# Optional (for advanced AI features)
set GEMINI_API_KEY=your_key_here
bash id="setup_4"
streamlit run app.py

๐Ÿงช CLI Mode

Run without UI:

bash id="cli_mode"
python inference.py

๐Ÿณ Docker

bash id="docker_block"
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.txt is included

Optional:

  • โ€”Add GEMINI_API_KEY in repository secrets

๐Ÿ“‚ Project Structure

id="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