muddasser commited on
Commit
f143c14
·
verified ·
1 Parent(s): b44c45c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -148
Dockerfile CHANGED
@@ -1,154 +1,20 @@
1
- ---
2
- title: Reem — Virtual Call Centre Voice Bot
3
- emoji: 📞
4
- colorFrom: green
5
- colorTo: yellow
6
- sdk: docker
7
- pinned: false
8
- license: mit
9
- ---
10
 
11
- # 📞 Reem — Real-Time Streaming Voice RAG Bot
 
 
12
 
13
- **XYZ Holdings Virtual Call Centre** — powered by Deepgram STT · Groq LLM · edge-tts
 
 
14
 
15
- ---
16
 
17
- ## Architecture
 
 
18
 
19
- ```
20
- Browser mic → Gradio Audio → Deepgram STT (nova-2, multilingual)
21
- ↓
22
- Router (sql / rag)
23
- ↙ ↘
24
- SQLite orders FAISS + SentenceTransformer
25
- ↘ ↙
26
- Groq LLaMA-3.3-70b (streaming)
27
- ↓
28
- edge-tts TTS
29
- ↓
30
- Gradio Audio (autoplay)
31
- ```
32
 
33
- ---
34
-
35
- ## Features
36
-
37
- | Feature | Details |
38
- |---|---|
39
- | **STT** | Deepgram nova-2, auto language detection (EN / AR / UR) |
40
- | **LLM** | Groq `llama-3.3-70b-versatile` with streaming |
41
- | **TTS** | edge-tts — `en-US-AriaNeural`, `ar-SA-ZariyahNeural`, `ur-PK-UzmaNeural` |
42
- | **Memory** | 10-turn sliding window + entity cache (order IDs, customer name) |
43
- | **Routing** | SQL path for order tracking, RAG path for knowledge base Q&A |
44
- | **Languages** | English · Arabic · Urdu |
45
-
46
- ---
47
-
48
- ## Environment Variables
49
-
50
- Set these in **HF Spaces → Settings → Repository secrets**:
51
-
52
- | Variable | Required | Description |
53
- |---|---|---|
54
- | `GROQ_API_KEY` | ✅ | [console.groq.com](https://console.groq.com) |
55
- | `DEEPGRAM_API_KEY` | ✅ | [console.deepgram.com](https://console.deepgram.com) |
56
- | `LIVEKIT_API_KEY` | ⬜ | Reserved for future WebRTC streaming |
57
-
58
- ---
59
-
60
- ## Deployment — HF Spaces (Gradio SDK)
61
-
62
- 1. Create a new Space → **Gradio** SDK
63
- 2. Push these files — no Dockerfile needed:
64
- ```
65
- app.py
66
- requirements.txt
67
- README.md
68
- ```
69
- 3. Add secrets under **Settings → Repository secrets**: `GROQ_API_KEY`, `DEEPGRAM_API_KEY`
70
- 4. HF installs `requirements.txt` automatically and runs `app.py`
71
-
72
- ---
73
-
74
- ## Knowledge Base Setup
75
-
76
- 1. Open **Admin Panel** (left sidebar) after launch
77
- 2. Upload one or more `.txt` files → click **Build KB**
78
- 3. FAISS index is built in-memory and persisted to `faiss.index` + `chunks.npy`
79
-
80
- ## Orders Database Setup
81
-
82
- 1. Export your SQLite `.db` file with an `orders` table:
83
- ```sql
84
- CREATE TABLE orders (
85
- order_id INTEGER PRIMARY KEY,
86
- order_date TEXT,
87
- customer_name TEXT,
88
- customer_city TEXT,
89
- customer_address TEXT,
90
- status TEXT,
91
- delivery_date TEXT,
92
- comments TEXT
93
- );
94
- ```
95
- 2. Upload via **Admin Panel → Orders Database**
96
-
97
- ---
98
-
99
- ## Usage Flow
100
-
101
- 1. Page loads → **welcome message plays** in EN / AR / UR
102
- 2. Say or click your **language** → Reem confirms
103
- 3. **Speak** into mic or **type** in the text box
104
- 4. Reem routes your query:
105
- - Order number / tracking keywords → **SQL lookup**
106
- - General questions → **RAG knowledge base**
107
- 5. Response **streams** from Groq → TTS plays automatically
108
- 6. Reem **remembers** order IDs and customer name across turns
109
-
110
- ---
111
-
112
- ## Local Development
113
-
114
- ```bash
115
- # Create venv
116
- python -m venv .venv && source .venv/bin/activate
117
-
118
- # Install
119
- pip install -r requirements.txt
120
-
121
- # Set env vars
122
- export GROQ_API_KEY=gsk_...
123
- export DEEPGRAM_API_KEY=...
124
-
125
- # Run
126
- python app.py
127
- # → http://localhost:7860
128
- ```
129
-
130
- ---
131
-
132
- ## File Structure
133
-
134
- ```
135
- ├── app.py # Main Gradio app
136
- ├── requirements.txt
137
- ├── README.md # HF Spaces config frontmatter lives here
138
- ├── faiss.index # Auto-generated after KB build
139
- ├── chunks.npy # Auto-generated after KB build
140
- ├── saudi_orders_database.db # Upload via Admin Panel
141
- └── agent_photo.jpg # Optional — replaces emoji avatar
142
- ```
143
-
144
- ---
145
-
146
- ## Differences from Streamlit Version
147
-
148
- | Aspect | Streamlit + Railway | Gradio on HF Spaces |
149
- |---|---|---|
150
- | Port management | FastAPI proxy required | Single port, native |
151
- | Streaming TTS | `st.components.v1.html` workaround | `gr.Audio(autoplay=True)` |
152
- | STT | `streamlit-mic-recorder` | `gr.Audio(sources=["microphone"])` |
153
- | Re-render issues | Duplicate responses on rerun | State-based, no reruns |
154
- | Barge-in | Manual WebSocket lifecycle | Deepgram `stop_recording` event |
 
1
+ FROM python:3.11-slim
 
 
 
 
 
 
 
 
2
 
3
+ RUN apt-get update && apt-get install -y --no-install-recommends \
4
+ ffmpeg libsndfile1 curl \
5
+ && rm -rf /var/lib/apt/lists/*
6
 
7
+ RUN useradd -m -u 1000 user
8
+ USER user
9
+ ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH PYTHONUNBUFFERED=1
10
 
11
+ WORKDIR $HOME/app
12
 
13
+ COPY --chown=user requirements.txt .
14
+ RUN pip install --no-cache-dir --upgrade pip \
15
+ && pip install --no-cache-dir -r requirements.txt
16
 
17
+ COPY --chown=user . .
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
+ EXPOSE 7860
20
+ CMD ["python", "app.py"]