github-actions
Initial sync to Hugging Face
6793beb
|
Raw History Blame Contribute Delete
4.61 kB
metadata
title: Customer EMAIL Agent
emoji: πŸ“§
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false

πŸ“§ Customer Support Email Agent

An AI-powered customer support email agent built with LangGraph, LangChain, and FastAPI.

The agent automatically classifies incoming support emails, retrieves relevant knowledge, drafts responses, and optionally escalates complex issues β€” all orchestrated as a stateful LangGraph workflow.

Architecture

Incoming Email
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Classifier β”‚  ← Categorizes intent (billing, technical, general, etc.)
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Retriever  β”‚  ← Fetches relevant knowledge base articles
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Responder  β”‚  ← Drafts a reply using context + LLM
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Escalation β”‚  ← Routes to human agent if confidence is low
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

cust_support_system/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.py              # FastAPI application entry point
β”‚   β”œβ”€β”€ api/                  # API routes & dependencies
β”‚   β”œβ”€β”€ core/                 # Config, logging, constants
β”‚   β”œβ”€β”€ graph/                # LangGraph workflow definition
β”‚   β”œβ”€β”€ nodes/                # Individual graph nodes
β”‚   β”œβ”€β”€ schemas/              # Pydantic models
β”‚   β”œβ”€β”€ services/             # Email & LLM services
β”‚   β”œβ”€β”€ prompts/              # Prompt templates
β”‚   └── utils/                # Helper utilities
β”œβ”€β”€ knowledge_base/           # Support articles & FAQ docs
β”œβ”€β”€ tests/                    # Pytest test suite
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example              # Credential-free configuration template
└── README.md

Setup

# 1. Create & activate a virtual environment (Python 3.12)
python3.12 -m venv venv
source venv/bin/activate

# 2. Install dependencies
pip install -r requirements.txt

# 3. Configure environment variables
cp .env.example .env   # then fill in your keys

# 4. Run the server
uvicorn src.main:app --reload

OpenAI inference configuration

Chat and knowledge-base embeddings use the backend-only OPENAI_API_KEY:

OPENAI_API_KEY=your-openai-api-key
LLM_BASE_URL=https://api.openai.com/v1
LLM_MODEL=gpt-6-luna
EMBEDDING_MODEL=text-embedding-3-small

The chat model ID gpt-6-luna is passed through exactly as configured. Its availability and API compatibility have not been verified; it must be accessible on your OpenAI account. The application no longer uses GITHUB_TOKEN for inference. Do not use a GitHub token as an OpenAI key or expose provider keys in frontend VITE_* variables.

For an existing installation, update the provider entries in .env rather than replacing the file and losing unrelated credentials. Environment variables take precedence over .env, which takes precedence over the code defaults. On your backend host (for example, Hugging Face Spaces), set OPENAI_API_KEY as a secret and update or remove stale LLM_BASE_URL, LLM_MODEL, and EMBEDDING_MODEL overrides. Restart the backend after configuration changes. /config reports the effective chat model; it does not modify inference settings.

Embeddings remain on the text-embedding-3-small model family with default dimensions. The migration does not rebuild the FAISS index. If the old index used a different embedding model or dimensions, rebuild it explicitly with python -m src.services.kb_service after setting a valid key; that command makes billable embedding requests.

Backend API authentication

Set API_TOKEN in the backend environment to a long random value. Production startup fails when APP_ENV=production and the token is missing. For local development, the frontend sends the same value from frontend/.env as VITE_API_TOKEN; this value is visible to browser users and should not be treated as a production-grade user authentication secret.

Tech Stack

Layer Technology
LLM OpenAI (gpt-6-luna)
Orchestration LangGraph + LangChain
API FastAPI
Validation Pydantic v2
Language Python 3.12