Spaces:
Sleeping
Sleeping
Upload README.md
Browse files
README.md
CHANGED
|
@@ -1,13 +1,111 @@
|
|
| 1 |
-
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom: indigo
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|