LaelaZ commited on
Commit
c411f00
Β·
verified Β·
1 Parent(s): 8981bf6

Add Space card front-matter

Browse files
Files changed (1) hide show
  1. README.md +150 -5
README.md CHANGED
@@ -1,10 +1,155 @@
1
  ---
2
- title: Ecom Support Copilot
3
- emoji: πŸ”₯
4
- colorFrom: pink
5
  colorTo: blue
6
  sdk: docker
7
- pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: SupportCopilot
3
+ emoji: "πŸ’¬"
4
+ colorFrom: green
5
  colorTo: blue
6
  sdk: docker
7
+ app_port: 8000
8
+ pinned: true
9
+ short_description: AI e-commerce support automation + ROI dashboard
10
  ---
11
 
12
+ # SupportCopilot
13
+
14
+ **An AI agent that automates first-line e-commerce customer support and proves the ROI β€” runs end-to-end with zero paid API keys.**
15
+
16
+ [![CI](https://github.com/LaelaZorana/ecom-support-copilot/actions/workflows/ci.yml/badge.svg)](https://github.com/LaelaZorana/ecom-support-copilot/actions/workflows/ci.yml)
17
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue)
18
+ ![License](https://img.shields.io/badge/license-MIT-green)
19
+
20
+ ## The problem
21
+
22
+ E-commerce support teams drown in repetitive tier-1 tickets β€” "where's my order?", "what's
23
+ your return policy?", "can I get a refund?". Each one costs an agent ~5–8 minutes and ~$0.50–$3
24
+ in loaded labour, and customers wait in a queue for answers that already exist in the catalog and
25
+ policy pages. Generic chatbots either hallucinate policy (creating refund liability) or escalate
26
+ everything (saving nothing). Teams need automation that is **grounded in their own data**, makes
27
+ **policy-correct refund decisions**, knows **when to hand off to a human**, and can **prove the
28
+ savings** to the people who sign off on it.
29
+
30
+ ## What it does
31
+
32
+ SupportCopilot is a vertical support agent for an example store (Northwind Outdoors). It:
33
+
34
+ - **Answers inquiries with citations** β€” RAG over the store's product catalog + policy documents,
35
+ every answer linked to the exact policy section or product it used.
36
+ - **Looks up order status** via a mock Orders API (swap in a real OMS/Shopify endpoint in one file).
37
+ - **Drafts return/refund decisions** with deterministic, unit-tested logic that respects the
38
+ written policy (return window, final-sale, worn/used, return-shipping fee, defect β†’ warranty).
39
+ - **Escalates to a human** when confidence is low or the situation is sensitive (defect claims,
40
+ billing disputes, manager requests) β€” so it never auto-approves money it shouldn't.
41
+ - **Proves ROI** on an ops dashboard whose numbers are computed by replaying seeded tickets through
42
+ the live agent β€” not hard-coded.
43
+
44
+ ```mermaid
45
+ flowchart TD
46
+ A[Customer message] --> B{Intent router}
47
+ B -->|order status| C[Mock Orders API]
48
+ B -->|refund / return| D[Refund decision engine<br/>policy rules]
49
+ B -->|general question| E[RAG retrieval<br/>TF-IDF over catalog + policies]
50
+ C --> F[LLM provider<br/>real API or offline stub]
51
+ D --> F
52
+ E --> F
53
+ F --> G{Confident & in-policy?}
54
+ G -->|yes| H[Auto-resolved answer<br/>+ citations]
55
+ G -->|no| I[Escalate to human]
56
+ H --> J[(ROI dashboard:<br/>deflection, time &amp; cost saved)]
57
+ I --> J
58
+ ```
59
+
60
+ ## Results / impact
61
+
62
+ Metrics below are produced by replaying the **20 seeded support tickets** in `data/tickets.json`
63
+ through the live agent (`make roi`). Change the policies, catalog, or ticket set and the numbers
64
+ move β€” they are earned, not hard-coded.
65
+
66
+ | Metric | Value |
67
+ | --- | --- |
68
+ | Tickets handled | 20 |
69
+ | **Auto-resolved (deflection rate)** | **80%** (16 / 20) |
70
+ | Escalated to human | 20% (4 / 20) β€” both defect claims, the billing dispute, the manager demand |
71
+ | Baseline human handle time | 7 min / ticket |
72
+ | Agent handle time saved (sample) | 1.87 h |
73
+ | Loaded agent cost | $28 / hr |
74
+ | **Projected monthly savings** | **β‰ˆ $7,840** at 3,000 tickets/mo |
75
+
76
+ At a typical mid-market volume of 3,000 tickets/month, an 80% deflection rate frees roughly
77
+ **280 agent-hours per month**. The agent's conservative escalation policy means the 20% that *do*
78
+ reach a human are the genuinely hard cases (unverified physical defects, billing/fraud, irate
79
+ customers) β€” exactly where human judgement adds value.
80
+
81
+ > **The vertical is swappable** β€” replace the knowledge base (catalog/policies) to retarget legal
82
+ > intake, real-estate lead handling, or healthcare admin. The agent, retrieval, escalation, and
83
+ > ROI machinery stay the same; only `data/` changes.
84
+
85
+ ## Quickstart
86
+
87
+ Runs fully **offline** with a deterministic stub provider β€” **no API keys required**.
88
+
89
+ ```bash
90
+ # 1. install (CPython 3.10+)
91
+ python -m venv .venv && source .venv/bin/activate
92
+ pip install -r requirements-dev.txt
93
+
94
+ # 2. run the test suite (offline, green)
95
+ make test # or: python -m pytest -q
96
+
97
+ # 3. see the ROI report in your terminal
98
+ make roi
99
+
100
+ # 4. launch the app (prints the URL)
101
+ make demo # -> http://localhost:8000/ (chat) + /dashboard (ROI)
102
+ ```
103
+
104
+ Ask it things from the command line, too:
105
+
106
+ ```bash
107
+ python -m supportcopilot.cli ask "what is your return policy?"
108
+ python -m supportcopilot.cli ask "return my tent, it's unused" --order NW-1001 --email alex@example.com
109
+ ```
110
+
111
+ **Using a real LLM (optional).** Install the provider extras and set a key; the app switches from
112
+ the stub automatically:
113
+
114
+ ```bash
115
+ pip install -r requirements-llm.txt
116
+ export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY=sk-...
117
+ make demo
118
+ ```
119
+
120
+ ## Tech stack
121
+
122
+ - **Python 3.10+**, **FastAPI** + **Jinja2** + **htmx** β€” single-container web app (chat UI + dashboard), no JS build step.
123
+ - **scikit-learn TF-IDF** cosine retrieval, with a **dependency-free pure-Python fallback** so retrieval never breaks the build.
124
+ - **Provider interface** with real **Anthropic**/**OpenAI** backends and a **deterministic offline stub** β€” zero-key by default.
125
+ - **pytest** (49 tests: retrieval, policy/refund logic, agent routing, ROI math, web layer).
126
+ - **Docker** + **docker-compose**, **GitHub Actions** CI (tests on 3.10–3.12 + container smoke test).
127
+
128
+ ## Deploy
129
+
130
+ Single container β€” deploy anywhere that runs a Docker image. The container needs **no secrets** to
131
+ run (it uses the offline stub); add `ANTHROPIC_API_KEY`/`OPENAI_API_KEY` to enable a real model.
132
+
133
+ **Local Docker**
134
+
135
+ ```bash
136
+ make docker && make docker-run # http://localhost:8000
137
+ # or: docker compose up --build
138
+ ```
139
+
140
+ **Render / Fly.io** β€” point at the `Dockerfile`; the app binds `0.0.0.0:$PORT` (both platforms set
141
+ `$PORT`). On Fly: `fly launch` then `fly deploy`. On Render: new **Web Service** β†’ Docker β†’ no start
142
+ command needed. Set provider keys as environment variables if you want a real model.
143
+
144
+ **Hugging Face Spaces (Docker SDK)** β€” create a Docker Space, push this repo; Spaces sets `$PORT`
145
+ (usually 7860) and the container honours it. Add keys under *Settings β†’ Secrets* to enable a real
146
+ provider.
147
+
148
+ ## Screenshots
149
+
150
+ > _Screenshots placeholder β€” add `docs/chat.png` and `docs/dashboard.png`._
151
+ > Run `make demo` and open `http://localhost:8000/` (chat) and `/dashboard` (ROI) to capture them.
152
+
153
+ | Chat (grounded answers + citations) | ROI dashboard (deflection, time & cost saved) |
154
+ | --- | --- |
155
+ | _`docs/chat.png`_ | _`docs/dashboard.png`_ |