vicfeuga commited on
Commit
c368cf9
Β·
verified Β·
1 Parent(s): 4a09f2e

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +111 -13
README.md CHANGED
@@ -1,13 +1,111 @@
1
- ---
2
- title: Chat Bot Sentinel
3
- emoji: πŸ“‰
4
- colorFrom: indigo
5
- colorTo: blue
6
- sdk: gradio
7
- sdk_version: 6.15.1
8
- python_version: '3.13'
9
- app_file: app.py
10
- pinned: false
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Market Performance Sentinel (Demo)
3
+ emoji: 🧬
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: streamlit
7
+ sdk_version: 1.39.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ short_description: Multi-agent LangGraph chatbot for market analytics.
12
+ ---
13
+
14
+ # Market Performance Sentinel β€” Demo
15
+
16
+ A multi-agent **LangGraph** chatbot that answers natural-language questions about pharma market
17
+ performance β€” built around a *supervisor + specialised agents* architecture.
18
+
19
+ > **This Space runs on 100% fictional data.**
20
+ > All company names, product names, and metric values are **synthetic** and were generated
21
+ > procedurally for demonstration purposes. The fictional company in the demo is **NovaPharma**
22
+ > and its products (NOVACOR, NOVAGLU, etc.) do **not** exist.
23
+
24
+ ## What this demo showcases
25
+
26
+ The chatbot answers questions like:
27
+
28
+ - *"What's the market share of the top 3 products in France for the Growth Hormone market?"*
29
+ - *"In LATAM, which country has the biggest QTR-QoQ value change in the Hypothyroid market in 25Q3?"*
30
+ - *"Which cluster is leading the change in APAC for the Anti-EGFR market?"*
31
+ - *"What are the clusters for the Injectable Platform in APAC?"*
32
+
33
+ It is **not** a Retrieval-Augmented-Generation chatbot β€” it is a **multi-agent system** where
34
+ each agent has a specific responsibility:
35
+
36
+ ```text
37
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
38
+ β”‚ query_analyzer β”‚ ← LLM classifies intent
39
+ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
40
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
41
+ data_retrieval parameter_info out_of_scope
42
+ β”‚ β”‚ β”‚
43
+ β–Ό β–Ό β”‚
44
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
45
+ β”‚ data_extractionβ”‚ β”‚ data_knowledge β”‚β”‚ ← LLM-assisted filter parsing,
46
+ β”‚ (SQL query) β”‚ β”‚ (param tables) β”‚β”‚ fuzzy parameter lookup
47
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
48
+ β”‚ (optional) β”‚ β”‚
49
+ β–Ό β”‚ β”‚
50
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
51
+ β”‚ leading_countryβ”‚ β”‚ β”‚ ← deterministic country
52
+ β”‚ (delta calc) β”‚ β”‚ β”‚ delta calculation
53
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
54
+ β”‚ β”‚ β”‚
55
+ β–Ό β–Ό β–Ό
56
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
57
+ β”‚ generate_response β”‚ ← LLM synthesises final
58
+ β”‚ (LLM synthesis + fallback) β”‚ business-friendly answer
59
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
60
+ ```
61
+
62
+ | Node | Role |
63
+ |------|------|
64
+ | `query_analyzer` | LLM classifies user intent: `data_retrieval`, `parameter_info`, `both`, or `out_of_scope`. |
65
+ | `data_extraction` | LLM parses filters (region, period, product, market, …) from the user query, then issues a **targeted SQL** query β€” no full-table scan. |
66
+ | `data_knowledge` | Keyword-scored lookup into the parameter tables (clusters, markets, country-region mapping). |
67
+ | `leading_country` | Deterministic, no-LLM calculation that reconstructs prior-period deltas and ranks countries by contribution. |
68
+ | `generate_response` | LLM synthesises a natural-language answer from extracted data + filters + conversation history; falls back to a deterministic CSV-formatted answer if the LLM is unavailable. |
69
+
70
+ ## Tech stack
71
+
72
+ - **Streamlit** for the UI
73
+ - **LangGraph** for the agent graph
74
+ - **Hugging Face Inference Providers** (`InferenceClient`) for the LLM calls β€” free serverless tier
75
+ - **SQLite** (single-file `demo.sqlite`) as the metrics store β€” pre-seeded with synthetic data
76
+ - **Python 3.10+**
77
+
78
+ ## Configuration
79
+
80
+ The Space needs **one secret**:
81
+
82
+ | Secret | Where to set it | Notes |
83
+ |---|---|---|
84
+ | `HF_TOKEN` | Space β†’ Settings β†’ Variables and secrets | A free Hugging Face read token works fine. |
85
+
86
+ Optional environment variables:
87
+
88
+ | Variable | Default | Description |
89
+ |---|---|---|
90
+ | `HF_MODEL` | `meta-llama/Llama-3.3-70B-Instruct` | Model used for all LLM calls. Any OpenAI-compatible chat model on HF Inference Providers will work. |
91
+ | `HF_PROVIDER` | `auto` | HF inference provider routing (`auto`, `hf-inference`, `together`, …). |
92
+
93
+ ## Running locally
94
+
95
+ ```bash
96
+ pip install -r requirements.txt
97
+ python seed_data.py # creates demo.sqlite (one-off; idempotent)
98
+ export HF_TOKEN=hf_xxx # Linux/macOS
99
+ # $env:HF_TOKEN = "hf_xxx" # Windows PowerShell
100
+ streamlit run app.py
101
+ ```
102
+
103
+ ## Disclaimer
104
+
105
+ This is a **demonstration project**. The data, products, and company branding are entirely
106
+ fictional. Numbers were generated procedurally and have no relationship to any real-world
107
+ pharmaceutical market.
108
+
109
+ ## License
110
+
111
+ MIT