copilot-swe-agent[bot] ParamJaiswal commited on
Commit
37f0545
Β·
1 Parent(s): 9aeb41f

Add Hugging Face deployment configuration files

Browse files

Co-authored-by: ParamJaiswal <191017925+ParamJaiswal@users.noreply.github.com>

Files changed (6) hide show
  1. .dockerignore +84 -0
  2. DEPLOYMENT.md +519 -0
  3. Dockerfile +38 -0
  4. HUGGINGFACE_SETUP.md +114 -0
  5. README.md +194 -0
  6. start_huggingface.sh +36 -0
.dockerignore ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python cache
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+ .Python
7
+
8
+ # Virtual environments
9
+ env/
10
+ venv/
11
+ .venv/
12
+ ENV/
13
+ env.bak/
14
+ venv.bak/
15
+
16
+ # Git
17
+ .git/
18
+ .gitignore
19
+ .gitattributes
20
+
21
+ # Environment files
22
+ .env
23
+ .env.*
24
+ !.env.example
25
+
26
+ # Database files
27
+ *.db
28
+ *.sqlite
29
+ *.sqlite3
30
+
31
+ # Logs
32
+ *.log
33
+ error_log.txt
34
+ output.txt
35
+
36
+ # IDE
37
+ .vscode/
38
+ .idea/
39
+ *.swp
40
+ *.swo
41
+ *~
42
+ .DS_Store
43
+
44
+ # Test files
45
+ tests/
46
+ test_*.py
47
+ *_test.py
48
+
49
+ # Documentation (except what's needed)
50
+ *.md
51
+ !README.md
52
+
53
+ # Build artifacts
54
+ build/
55
+ dist/
56
+ *.egg-info/
57
+ .eggs/
58
+
59
+ # Media files
60
+ *.mp3
61
+ *.wav
62
+ *.mp4
63
+ *.avi
64
+ *.mov
65
+ temp_*
66
+
67
+ # Windows batch files
68
+ *.bat
69
+
70
+ # Deployment configs for other platforms
71
+ render.yaml
72
+ docker-compose.yml
73
+ docker-compose.yaml
74
+
75
+ # Node modules (if any)
76
+ node_modules/
77
+
78
+ # Misc
79
+ *.txt
80
+ !requirements.txt
81
+ !backend/requirements.txt
82
+ !frontend/requirements.txt
83
+ models_list.txt
84
+ test.pdf
DEPLOYMENT.md ADDED
@@ -0,0 +1,519 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deployment Guide for TalentTalkPro on Hugging Face Spaces
2
+
3
+ This guide provides comprehensive instructions for deploying TalentTalkPro on Hugging Face Spaces using Docker SDK.
4
+
5
+ ## πŸ“‹ Table of Contents
6
+
7
+ 1. [Prerequisites](#prerequisites)
8
+ 2. [Step-by-Step Deployment](#step-by-step-deployment)
9
+ 3. [Environment Variables Configuration](#environment-variables-configuration)
10
+ 4. [Troubleshooting](#troubleshooting)
11
+ 5. [Local Docker Testing](#local-docker-testing)
12
+ 6. [Advanced Configuration](#advanced-configuration)
13
+
14
+ ## πŸ”§ Prerequisites
15
+
16
+ Before deploying TalentTalkPro, ensure you have:
17
+
18
+ ### 1. Hugging Face Account
19
+ - Create a free account at [huggingface.co](https://huggingface.co)
20
+ - Verify your email address
21
+
22
+ ### 2. Required API Keys
23
+
24
+ You'll need the following API keys:
25
+
26
+ #### Google Generative AI API Key
27
+ - **Purpose**: Powers the AI interview agent and language understanding
28
+ - **How to get**:
29
+ 1. Visit [Google AI Studio](https://makersuite.google.com/app/apikey)
30
+ 2. Sign in with your Google account
31
+ 3. Click "Create API Key"
32
+ 4. Copy and save the key securely
33
+
34
+ #### OpenRouter API Key
35
+ - **Purpose**: Provides access to multiple AI models for enhanced capabilities
36
+ - **How to get**:
37
+ 1. Visit [OpenRouter](https://openrouter.ai)
38
+ 2. Sign up for an account
39
+ 3. Navigate to API Keys section
40
+ 4. Generate a new API key
41
+ 5. Copy and save the key
42
+
43
+ #### AssemblyAI API Key
44
+ - **Purpose**: Converts speech to text for audio responses
45
+ - **How to get**:
46
+ 1. Visit [AssemblyAI](https://www.assemblyai.com)
47
+ 2. Sign up for a free account
48
+ 3. Go to your Dashboard
49
+ 4. Copy your API key from the home page
50
+
51
+ #### ElevenLabs API Key
52
+ - **Purpose**: Converts text to speech for AI interviewer responses
53
+ - **How to get**:
54
+ 1. Visit [ElevenLabs](https://elevenlabs.io)
55
+ 2. Create an account
56
+ 3. Navigate to Profile Settings β†’ API Keys
57
+ 4. Copy your API key
58
+
59
+ ### 3. GitHub Repository Access
60
+ - Fork or clone the TalentTalkPro repository
61
+ - Ensure you have admin access to the repository
62
+
63
+ ## πŸš€ Step-by-Step Deployment
64
+
65
+ Follow these steps to deploy TalentTalkPro on Hugging Face Spaces:
66
+
67
+ ### Step 1: Prepare Your Repository
68
+
69
+ 1. **Fork the Repository** (if you haven't already)
70
+ - Go to [github.com/ParamJaiswal/TalentTalkPro](https://github.com/ParamJaiswal/TalentTalkPro)
71
+ - Click the "Fork" button in the top right
72
+ - Wait for the fork to complete
73
+
74
+ 2. **Clone Your Fork Locally** (optional, for testing)
75
+ ```bash
76
+ git clone https://github.com/YOUR_USERNAME/TalentTalkPro.git
77
+ cd TalentTalkPro
78
+ ```
79
+
80
+ ### Step 2: Create a Hugging Face Space
81
+
82
+ 1. **Navigate to Spaces**
83
+ - Go to [huggingface.co/spaces](https://huggingface.co/spaces)
84
+ - Click "Create new Space"
85
+
86
+ 2. **Configure Your Space**
87
+ - **Space name**: `TalentTalkPro` (or your preferred name)
88
+ - **License**: Choose appropriate license (e.g., MIT)
89
+ - **Select SDK**: Choose **Docker**
90
+ - **Space hardware**: Start with "CPU basic" (free tier)
91
+ - **Visibility**: Choose Public or Private
92
+
93
+ 3. **Click "Create Space"**
94
+
95
+ ### Step 3: Connect GitHub Repository
96
+
97
+ You have two options to connect your code:
98
+
99
+ #### Option A: Push to Hugging Face Git Repository (Recommended)
100
+
101
+ 1. **Add Hugging Face remote**
102
+ ```bash
103
+ cd TalentTalkPro
104
+ git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/TalentTalkPro
105
+ ```
106
+
107
+ 2. **Push your code**
108
+ ```bash
109
+ git push hf main
110
+ ```
111
+
112
+ #### Option B: Use GitHub Integration
113
+
114
+ 1. In your Space settings, go to "Files and versions"
115
+ 2. Look for GitHub repository connection option
116
+ 3. Authorize Hugging Face to access your GitHub
117
+ 4. Select your TalentTalkPro repository
118
+ 5. Enable automatic sync
119
+
120
+ ### Step 4: Configure Environment Variables
121
+
122
+ This is the most critical step for a successful deployment.
123
+
124
+ 1. **Navigate to Space Settings**
125
+ - Go to your Space page
126
+ - Click "Settings" tab
127
+ - Scroll to "Repository secrets"
128
+
129
+ 2. **Add Required Secrets**
130
+
131
+ Click "Add a new secret" for each of the following:
132
+
133
+ | Secret Name | Value | Example |
134
+ |-------------|-------|---------|
135
+ | `GOOGLE_API_KEY` | Your Google AI API key | `AIzaSyC...` |
136
+ | `OPENROUTER_API_KEY` | Your OpenRouter API key | `sk-or-v1-...` |
137
+ | `ASSEMBLYAI_API_KEY` | Your AssemblyAI API key | `abc123def...` |
138
+ | `ELEVENLABS_API_KEY` | Your ElevenLabs API key | `sk_...` |
139
+
140
+ 3. **Add Optional Secrets** (with defaults)
141
+
142
+ | Secret Name | Default Value | Notes |
143
+ |-------------|---------------|-------|
144
+ | `DATABASE_URL` | `sqlite+aiosqlite:///./talenttalk.db` | SQLite database path |
145
+ | `BACKEND_CORS_ORIGINS` | `*` | Allow all origins (for development) |
146
+ | `API_URL` | `http://localhost:8000/api/v1` | Backend API URL |
147
+ | `ENVIRONMENT` | `production` | Deployment environment |
148
+ | `LOG_LEVEL` | `INFO` | Logging level |
149
+
150
+ 4. **Save and Rebuild**
151
+ - After adding all secrets, click "Save"
152
+ - Go back to "App" tab
153
+ - Your Space will automatically rebuild with the new environment variables
154
+
155
+ ### Step 5: Monitor Deployment
156
+
157
+ 1. **Watch Build Logs**
158
+ - Stay on the Space page
159
+ - The build logs will appear in real-time
160
+ - This process typically takes 5-10 minutes
161
+
162
+ 2. **Wait for "Running" Status**
163
+ - Once the build completes, status will change to "Running"
164
+ - A green indicator means your app is live
165
+
166
+ 3. **Access Your Application**
167
+ - Your Space URL: `https://huggingface.co/spaces/YOUR_USERNAME/TalentTalkPro`
168
+ - The Streamlit interface should load automatically
169
+
170
+ ## πŸ” Environment Variables Configuration
171
+
172
+ ### Required Variables
173
+
174
+ #### `GOOGLE_API_KEY`
175
+ - **Description**: Google Generative AI API key for language model
176
+ - **Required**: Yes
177
+ - **Format**: String starting with `AIza`
178
+ - **Where to get**: [Google AI Studio](https://makersuite.google.com/app/apikey)
179
+
180
+ #### `OPENROUTER_API_KEY`
181
+ - **Description**: OpenRouter API key for model access
182
+ - **Required**: Yes
183
+ - **Format**: String starting with `sk-or-v1-`
184
+ - **Where to get**: [OpenRouter](https://openrouter.ai)
185
+
186
+ #### `ASSEMBLYAI_API_KEY`
187
+ - **Description**: AssemblyAI API key for speech-to-text
188
+ - **Required**: Yes
189
+ - **Format**: Alphanumeric string
190
+ - **Where to get**: [AssemblyAI Dashboard](https://www.assemblyai.com/dashboard)
191
+
192
+ #### `ELEVENLABS_API_KEY`
193
+ - **Description**: ElevenLabs API key for text-to-speech
194
+ - **Required**: Yes
195
+ - **Format**: String starting with `sk_`
196
+ - **Where to get**: [ElevenLabs Settings](https://elevenlabs.io/app/settings)
197
+
198
+ ### Optional Variables
199
+
200
+ #### `DATABASE_URL`
201
+ - **Description**: Database connection string
202
+ - **Default**: `sqlite+aiosqlite:///./talenttalk.db`
203
+ - **Format**: SQLAlchemy database URL
204
+ - **Example**: `postgresql+asyncpg://user:pass@host/db` (for PostgreSQL)
205
+
206
+ #### `BACKEND_CORS_ORIGINS`
207
+ - **Description**: Comma-separated list of allowed CORS origins
208
+ - **Default**: `*` (allow all - use only for development)
209
+ - **Format**: `https://domain1.com,https://domain2.com`
210
+ - **Production Example**: `https://huggingface.co`
211
+
212
+ #### `API_URL`
213
+ - **Description**: Backend API URL for frontend to connect
214
+ - **Default**: `http://localhost:8000/api/v1`
215
+ - **Note**: In Docker, localhost works because both services run in same container
216
+
217
+ #### `ENVIRONMENT`
218
+ - **Description**: Application environment
219
+ - **Default**: `production`
220
+ - **Options**: `development`, `staging`, `production`
221
+
222
+ #### `LOG_LEVEL`
223
+ - **Description**: Logging verbosity
224
+ - **Default**: `INFO`
225
+ - **Options**: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`
226
+
227
+ ## πŸ”§ Troubleshooting
228
+
229
+ ### Common Issues and Solutions
230
+
231
+ #### 1. Build Fails During Installation
232
+
233
+ **Symptom**: Error during `pip install` step
234
+
235
+ **Solutions**:
236
+ - Check if `requirements.txt` files are properly formatted
237
+ - Ensure no conflicting package versions
238
+ - Check build logs for specific package errors
239
+ - Try upgrading pip: Add `RUN pip install --upgrade pip` in Dockerfile
240
+
241
+ #### 2. Application Starts But Crashes Immediately
242
+
243
+ **Symptom**: Space shows "Running" then "Error"
244
+
245
+ **Possible Causes**:
246
+ - Missing or invalid API keys
247
+ - Database initialization failure
248
+ - Port conflicts
249
+
250
+ **Solutions**:
251
+ 1. Check all required environment variables are set
252
+ 2. Verify API keys are valid by testing them separately
253
+ 3. Check Space logs for specific error messages
254
+ 4. Ensure `static` directory is created (should be automatic)
255
+
256
+ #### 3. Backend Fails to Start
257
+
258
+ **Symptom**: "Backend failed to start!" in logs
259
+
260
+ **Solutions**:
261
+ - Check if port 8000 is available
262
+ - Verify `app.main:app` path is correct
263
+ - Check for syntax errors in backend code
264
+ - Review backend logs for detailed error messages
265
+
266
+ #### 4. Frontend Can't Connect to Backend
267
+
268
+ **Symptom**: Frontend loads but shows connection errors
269
+
270
+ **Solutions**:
271
+ - Verify `API_URL` environment variable
272
+ - In Docker, use `http://localhost:8000/api/v1` (not external URL)
273
+ - Check CORS settings in backend
274
+ - Ensure backend is fully started before frontend makes requests
275
+
276
+ #### 5. Audio/Video Features Not Working
277
+
278
+ **Symptom**: Audio recording or playback fails
279
+
280
+ **Solutions**:
281
+ - Verify AssemblyAI and ElevenLabs API keys
282
+ - Check API key quotas and limits
283
+ - Ensure `static` directory has write permissions
284
+ - Check browser permissions for microphone/camera
285
+
286
+ #### 6. Database Errors
287
+
288
+ **Symptom**: SQLite or database-related errors
289
+
290
+ **Solutions**:
291
+ - Ensure `DATABASE_URL` is properly formatted
292
+ - Check write permissions for database file location
293
+ - For SQLite, ensure parent directory exists
294
+ - Consider using in-memory database for testing: `sqlite+aiosqlite:///:memory:`
295
+
296
+ #### 7. Out of Memory Errors
297
+
298
+ **Symptom**: Container crashes with memory errors
299
+
300
+ **Solutions**:
301
+ - Upgrade Space hardware tier (Settings β†’ Space hardware)
302
+ - Optimize model loading (load models on-demand)
303
+ - Reduce batch sizes or concurrent requests
304
+ - Consider using smaller model variants
305
+
306
+ #### 8. Slow Performance
307
+
308
+ **Symptom**: Long response times
309
+
310
+ **Solutions**:
311
+ - Upgrade to a better hardware tier (GPU if available)
312
+ - Optimize API calls to external services
313
+ - Implement caching where appropriate
314
+ - Use async/await properly in backend
315
+
316
+ ### Debugging Tips
317
+
318
+ 1. **Enable Debug Logging**
319
+ - Set `LOG_LEVEL=DEBUG` in environment variables
320
+ - Check detailed logs in Space β†’ Logs
321
+
322
+ 2. **Test API Endpoints Separately**
323
+ - Access `https://your-space-url/docs` for API documentation
324
+ - Test individual endpoints to isolate issues
325
+
326
+ 3. **Check API Key Validity**
327
+ - Test each API key independently before deployment
328
+ - Ensure keys have necessary permissions and quotas
329
+
330
+ 4. **Local Testing First**
331
+ - Always test Docker build locally before deploying
332
+ - Use the same environment variables locally
333
+
334
+ ## 🐳 Local Docker Testing
335
+
336
+ Before deploying to Hugging Face, test your Docker setup locally:
337
+
338
+ ### Build the Image
339
+
340
+ ```bash
341
+ cd TalentTalkPro
342
+ docker build -t talenttalkpro:test .
343
+ ```
344
+
345
+ ### Run the Container
346
+
347
+ ```bash
348
+ docker run -p 7860:7860 \
349
+ -e GOOGLE_API_KEY=your_google_api_key \
350
+ -e OPENROUTER_API_KEY=your_openrouter_key \
351
+ -e ASSEMBLYAI_API_KEY=your_assemblyai_key \
352
+ -e ELEVENLABS_API_KEY=your_elevenlabs_key \
353
+ -e DATABASE_URL=sqlite+aiosqlite:///./talenttalk.db \
354
+ -e BACKEND_CORS_ORIGINS=* \
355
+ talenttalkpro:test
356
+ ```
357
+
358
+ ### Using Environment File
359
+
360
+ Create a `.env.docker` file:
361
+
362
+ ```env
363
+ GOOGLE_API_KEY=your_google_api_key
364
+ OPENROUTER_API_KEY=your_openrouter_key
365
+ ASSEMBLYAI_API_KEY=your_assemblyai_key
366
+ ELEVENLABS_API_KEY=your_elevenlabs_key
367
+ DATABASE_URL=sqlite+aiosqlite:///./talenttalk.db
368
+ BACKEND_CORS_ORIGINS=*
369
+ ```
370
+
371
+ Run with env file:
372
+
373
+ ```bash
374
+ docker run -p 7860:7860 --env-file .env.docker talenttalkpro:test
375
+ ```
376
+
377
+ ### Access Locally
378
+
379
+ - Frontend: http://localhost:7860
380
+ - Backend API: http://localhost:8000 (not directly accessible from outside container)
381
+
382
+ ### Check Logs
383
+
384
+ ```bash
385
+ # View logs
386
+ docker logs <container_id>
387
+
388
+ # Follow logs in real-time
389
+ docker logs -f <container_id>
390
+ ```
391
+
392
+ ### Interactive Debugging
393
+
394
+ ```bash
395
+ # Run container with bash
396
+ docker run -it -p 7860:7860 --env-file .env.docker talenttalkpro:test /bin/bash
397
+
398
+ # Inside container, manually run components
399
+ cd /app/backend && python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 &
400
+ cd /app/frontend && streamlit run app.py --server.port 7860 --server.address 0.0.0.0
401
+ ```
402
+
403
+ ## βš™οΈ Advanced Configuration
404
+
405
+ ### Custom Domain
406
+
407
+ To use a custom domain with your Hugging Face Space:
408
+
409
+ 1. Go to Space Settings β†’ Custom domain
410
+ 2. Follow Hugging Face's domain verification process
411
+ 3. Update DNS records as instructed
412
+ 4. Add your domain to `BACKEND_CORS_ORIGINS`
413
+
414
+ ### Scaling and Performance
415
+
416
+ For production workloads:
417
+
418
+ 1. **Upgrade Hardware**
419
+ - Navigate to Settings β†’ Space hardware
420
+ - Choose GPU tier for better performance
421
+ - Consider T4, A10G, or A100 GPUs
422
+
423
+ 2. **Enable Caching**
424
+ - Implement Redis for session caching
425
+ - Cache frequently accessed data
426
+ - Use CDN for static assets
427
+
428
+ 3. **Database Optimization**
429
+ - Consider PostgreSQL for production
430
+ - Set up proper indexes
431
+ - Use connection pooling
432
+
433
+ ### Security Best Practices
434
+
435
+ 1. **API Key Management**
436
+ - Never commit API keys to repository
437
+ - Use Hugging Face Repository Secrets
438
+ - Rotate keys periodically
439
+ - Monitor API usage
440
+
441
+ 2. **CORS Configuration**
442
+ - In production, specify exact origins instead of `*`
443
+ - Example: `BACKEND_CORS_ORIGINS=https://huggingface.co,https://your-domain.com`
444
+
445
+ 3. **Rate Limiting**
446
+ - Implement rate limiting on API endpoints
447
+ - Monitor and set quotas for external API calls
448
+ - Add authentication if needed
449
+
450
+ ### Monitoring and Logging
451
+
452
+ 1. **Application Logs**
453
+ - View logs in Space β†’ Logs tab
454
+ - Increase `LOG_LEVEL` for more details
455
+ - Set up log aggregation for production
456
+
457
+ 2. **Health Checks**
458
+ - Backend health endpoint: `/health`
459
+ - Monitor uptime and response times
460
+ - Set up alerts for failures
461
+
462
+ 3. **Analytics**
463
+ - Track user interactions
464
+ - Monitor API usage and costs
465
+ - Analyze performance metrics
466
+
467
+ ### Backup and Recovery
468
+
469
+ 1. **Database Backups**
470
+ - Regular backups of SQLite database
471
+ - Consider automated backup solutions
472
+ - Test recovery procedures
473
+
474
+ 2. **Configuration Backups**
475
+ - Document all environment variables
476
+ - Keep backup of Space settings
477
+ - Version control all configuration
478
+
479
+ ## πŸ“š Additional Resources
480
+
481
+ - [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces)
482
+ - [Docker Documentation](https://docs.docker.com/)
483
+ - [FastAPI Documentation](https://fastapi.tiangolo.com/)
484
+ - [Streamlit Documentation](https://docs.streamlit.io/)
485
+ - [LangGraph Documentation](https://python.langchain.com/docs/langgraph)
486
+
487
+ ## πŸ†˜ Getting Help
488
+
489
+ If you encounter issues not covered in this guide:
490
+
491
+ 1. **Check the Logs**: Most issues are revealed in the application logs
492
+ 2. **GitHub Issues**: Open an issue on the [GitHub repository](https://github.com/ParamJaiswal/TalentTalkPro/issues)
493
+ 3. **Hugging Face Forums**: Ask in the [Hugging Face community](https://discuss.huggingface.co/)
494
+ 4. **Documentation**: Review the main [README.md](./README.md)
495
+
496
+ ## βœ… Deployment Checklist
497
+
498
+ Use this checklist to ensure successful deployment:
499
+
500
+ - [ ] Hugging Face account created and verified
501
+ - [ ] All API keys obtained and tested
502
+ - [ ] Repository forked or cloned
503
+ - [ ] Hugging Face Space created with Docker SDK
504
+ - [ ] All required environment variables configured
505
+ - [ ] Code pushed to Hugging Face Space
506
+ - [ ] Build completed successfully
507
+ - [ ] Application running without errors
508
+ - [ ] Frontend accessible via Space URL
509
+ - [ ] Backend API responding correctly
510
+ - [ ] Audio recording feature working
511
+ - [ ] Interview flow tested end-to-end
512
+ - [ ] Performance acceptable
513
+ - [ ] Logs reviewed for warnings or errors
514
+
515
+ ---
516
+
517
+ πŸŽ‰ **Congratulations!** Your TalentTalkPro instance should now be running on Hugging Face Spaces.
518
+
519
+ For questions or improvements to this guide, please contribute to the repository or open an issue.
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.10 slim as base image
2
+ FROM python:3.10-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ curl \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Copy and install backend requirements
14
+ COPY backend/requirements.txt /app/backend/requirements.txt
15
+ RUN pip install --no-cache-dir -r /app/backend/requirements.txt
16
+
17
+ # Copy and install frontend requirements
18
+ COPY frontend/requirements.txt /app/frontend/requirements.txt
19
+ RUN pip install --no-cache-dir -r /app/frontend/requirements.txt
20
+
21
+ # Copy backend files
22
+ COPY backend/ /app/backend/
23
+
24
+ # Copy frontend files
25
+ COPY frontend/ /app/frontend/
26
+
27
+ # Create static directory for audio files
28
+ RUN mkdir -p /app/backend/static
29
+
30
+ # Copy startup script
31
+ COPY start_huggingface.sh /app/start_huggingface.sh
32
+ RUN chmod +x /app/start_huggingface.sh
33
+
34
+ # Expose port 7860 (Hugging Face default)
35
+ EXPOSE 7860
36
+
37
+ # Use startup script as entry point
38
+ CMD ["/app/start_huggingface.sh"]
HUGGINGFACE_SETUP.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Quick Hugging Face Space Connection Guide
2
+
3
+ ## Step 1: Find Your Space URL
4
+
5
+ Your Hugging Face Space URL should look like:
6
+ ```
7
+ https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
8
+ ```
9
+
10
+ For example: `https://huggingface.co/spaces/ParamJaiswal/TalentTalkPro`
11
+
12
+ ## Step 2: Add Hugging Face as a Git Remote
13
+
14
+ Run this command in your terminal (replace `YOUR_USERNAME` and `YOUR_SPACE_NAME` with your actual values):
15
+
16
+ ```bash
17
+ cd /home/runner/work/TalentTalkPro/TalentTalkPro
18
+ git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
19
+ ```
20
+
21
+ Example:
22
+ ```bash
23
+ git remote add hf https://huggingface.co/spaces/ParamJaiswal/TalentTalkPro
24
+ ```
25
+
26
+ ## Step 3: Push Code to Hugging Face
27
+
28
+ ```bash
29
+ # Make sure all files are committed
30
+ git add .
31
+ git commit -m "Add Hugging Face deployment configuration"
32
+
33
+ # Push to Hugging Face Space
34
+ git push hf main
35
+ ```
36
+
37
+ **Note**: You'll be prompted for your Hugging Face credentials:
38
+ - **Username**: Your Hugging Face username
39
+ - **Password**: Use your Hugging Face **Access Token** (NOT your account password)
40
+
41
+ ### How to Get Your Hugging Face Access Token:
42
+ 1. Go to https://huggingface.co/settings/tokens
43
+ 2. Click "New token"
44
+ 3. Give it a name (e.g., "TalentTalkPro")
45
+ 4. Select "Write" access
46
+ 5. Click "Generate"
47
+ 6. Copy the token and use it as your password when pushing
48
+
49
+ ## Step 4: Configure Environment Variables
50
+
51
+ After pushing, you need to add your API keys:
52
+
53
+ 1. Go to your Space page: `https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME`
54
+ 2. Click on **"Settings"** tab
55
+ 3. Scroll down to **"Repository secrets"** section
56
+ 4. Click **"Add a new secret"** for each:
57
+
58
+ ### Required Secrets:
59
+ - **Name**: `GOOGLE_API_KEY` β†’ **Value**: Your Google AI API key
60
+ - **Name**: `OPENROUTER_API_KEY` β†’ **Value**: Your OpenRouter API key
61
+ - **Name**: `ASSEMBLYAI_API_KEY` β†’ **Value**: Your AssemblyAI API key
62
+ - **Name**: `ELEVENLABS_API_KEY` β†’ **Value**: Your ElevenLabs API key
63
+
64
+ ### Optional Secrets (with defaults):
65
+ - **Name**: `DATABASE_URL` β†’ **Value**: `sqlite+aiosqlite:///./talenttalk.db`
66
+ - **Name**: `BACKEND_CORS_ORIGINS` β†’ **Value**: `*`
67
+
68
+ 5. Click **"Save"** after adding each secret
69
+
70
+ ## Step 5: Wait for Build
71
+
72
+ - Your Space will automatically start building
73
+ - This takes about 5-10 minutes
74
+ - Watch the build logs in the "Logs" tab
75
+ - Once complete, your app will be live!
76
+
77
+ ## Alternative Method: Upload Files Directly
78
+
79
+ If you prefer not to use Git, you can upload files directly:
80
+
81
+ 1. Go to your Space page
82
+ 2. Click **"Files and versions"** tab
83
+ 3. Click **"Add file"** β†’ **"Upload files"**
84
+ 4. Upload all the files from your repository
85
+ 5. Make sure to include:
86
+ - `Dockerfile`
87
+ - `start_huggingface.sh`
88
+ - `README.md`
89
+ - `.dockerignore`
90
+ - All `backend/` files
91
+ - All `frontend/` files
92
+ 6. Commit the files
93
+
94
+ ## Troubleshooting
95
+
96
+ ### Authentication Failed
97
+ If `git push` fails with authentication error:
98
+ - Make sure you're using your **Access Token** as password, not your account password
99
+ - Check token has "Write" permissions
100
+ - Try: `git config credential.helper store` to save credentials
101
+
102
+ ### Build Failed
103
+ - Check the "Logs" tab in your Space
104
+ - Verify all environment variables are set
105
+ - Make sure all required files are pushed
106
+
107
+ ### Space Not Starting
108
+ - Verify all 4 required API keys are configured
109
+ - Check if the keys are valid
110
+ - Look for error messages in the Logs
111
+
112
+ ## Need Help?
113
+
114
+ See the full deployment guide in [DEPLOYMENT.md](./DEPLOYMENT.md) for detailed troubleshooting and configuration options.
README.md ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: TalentTalkPro
3
+ emoji: 🎀
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
+
11
+ # TalentTalkPro 🎀
12
+
13
+ AI-powered interview assistant using LangGraph, LangChain, and Google Generative AI for comprehensive interview practice and feedback.
14
+
15
+ ## 🎯 Overview
16
+
17
+ TalentTalkPro is an advanced AI interview platform that provides realistic interview experiences with intelligent follow-up questions, real-time feedback, and comprehensive performance reports. The system uses multi-agent architecture powered by LangGraph to simulate professional interview scenarios.
18
+
19
+ ## πŸ—οΈ Architecture
20
+
21
+ The application consists of two main components:
22
+
23
+ ### Backend (FastAPI)
24
+ - **Port**: 8000 (internal)
25
+ - **Technology**: FastAPI, LangGraph, LangChain
26
+ - **Features**:
27
+ - Multi-agent interview system
28
+ - Real-time speech processing
29
+ - Resume analysis
30
+ - Video behavior analysis
31
+ - Performance evaluation
32
+
33
+ ### Frontend (Streamlit)
34
+ - **Port**: 7860 (Hugging Face default)
35
+ - **Technology**: Streamlit
36
+ - **Features**:
37
+ - Interactive chat interface
38
+ - Audio/video input support
39
+ - Real-time feedback display
40
+ - Performance report visualization
41
+
42
+ ## ✨ Features
43
+
44
+ - **πŸ€– AI-Powered Interviews**: Intelligent multi-turn conversations with contextual follow-ups
45
+ - **πŸ“„ Resume Analysis**: Upload your resume for personalized interview questions
46
+ - **πŸŽ™οΈ Voice Interaction**: Record audio responses for a realistic interview experience
47
+ - **πŸ“Ή Video Analysis**: Optional video behavior analysis for non-verbal communication feedback
48
+ - **πŸ“Š Performance Reports**: Comprehensive evaluation with actionable feedback
49
+ - **🎯 Customizable Settings**: Configure difficulty, style, company, and role
50
+ - **πŸ”„ Adaptive Follow-ups**: Dynamic follow-up questions based on your responses
51
+
52
+ ## πŸ” Environment Variables
53
+
54
+ The following environment variables are required:
55
+
56
+ | Variable | Description | Required |
57
+ |----------|-------------|----------|
58
+ | `GOOGLE_API_KEY` | Google Generative AI API key for LLM capabilities | βœ… Yes |
59
+ | `OPENROUTER_API_KEY` | OpenRouter API key for additional model access | βœ… Yes |
60
+ | `ASSEMBLYAI_API_KEY` | AssemblyAI API key for speech-to-text | βœ… Yes |
61
+ | `ELEVENLABS_API_KEY` | ElevenLabs API key for text-to-speech | βœ… Yes |
62
+ | `DATABASE_URL` | Database connection string | ⚠️ Default: `sqlite+aiosqlite:///./talenttalk.db` |
63
+ | `BACKEND_CORS_ORIGINS` | CORS allowed origins | ⚠️ Default: `*` |
64
+ | `API_URL` | Frontend API URL for backend connection | ⚠️ Default: `http://localhost:8000/api/v1` |
65
+
66
+ ## πŸš€ Deployment on Hugging Face Spaces
67
+
68
+ This application is configured for deployment on Hugging Face Spaces using Docker SDK. For detailed deployment instructions, see [DEPLOYMENT.md](./DEPLOYMENT.md).
69
+
70
+ ### Quick Start
71
+
72
+ 1. Fork or clone this repository
73
+ 2. Create a new Space on [huggingface.co/spaces](https://huggingface.co/spaces)
74
+ 3. Select Docker SDK
75
+ 4. Connect your GitHub repository
76
+ 5. Configure environment variables in Space Settings β†’ Repository Secrets
77
+ 6. Your Space will automatically build and deploy!
78
+
79
+ ## πŸ’» Local Development
80
+
81
+ ### Prerequisites
82
+
83
+ - Python 3.10+
84
+ - pip or conda
85
+
86
+ ### Setup
87
+
88
+ 1. **Clone the repository**
89
+ ```bash
90
+ git clone https://github.com/ParamJaiswal/TalentTalkPro.git
91
+ cd TalentTalkPro
92
+ ```
93
+
94
+ 2. **Create environment file**
95
+ ```bash
96
+ cp .env.example .env
97
+ # Edit .env and add your API keys
98
+ ```
99
+
100
+ 3. **Install backend dependencies**
101
+ ```bash
102
+ cd backend
103
+ pip install -r requirements.txt
104
+ ```
105
+
106
+ 4. **Install frontend dependencies**
107
+ ```bash
108
+ cd ../frontend
109
+ pip install -r requirements.txt
110
+ ```
111
+
112
+ 5. **Run backend server**
113
+ ```bash
114
+ cd ../backend
115
+ python -m uvicorn app.main:app --reload
116
+ ```
117
+
118
+ 6. **Run frontend (in a new terminal)**
119
+ ```bash
120
+ cd frontend
121
+ streamlit run app.py
122
+ ```
123
+
124
+ 7. **Access the application**
125
+ - Frontend: http://localhost:8501
126
+ - Backend API: http://localhost:8000
127
+ - API Docs: http://localhost:8000/docs
128
+
129
+ ### Local Docker Testing
130
+
131
+ ```bash
132
+ # Build the Docker image
133
+ docker build -t talenttalkpro .
134
+
135
+ # Run the container
136
+ docker run -p 7860:7860 \
137
+ -e GOOGLE_API_KEY=your_key \
138
+ -e OPENROUTER_API_KEY=your_key \
139
+ -e ASSEMBLYAI_API_KEY=your_key \
140
+ -e ELEVENLABS_API_KEY=your_key \
141
+ talenttalkpro
142
+ ```
143
+
144
+ Access at: http://localhost:7860
145
+
146
+ ## πŸ“š API Documentation
147
+
148
+ Once the backend is running, visit:
149
+ - Swagger UI: http://localhost:8000/docs
150
+ - ReDoc: http://localhost:8000/redoc
151
+
152
+ ## πŸ§ͺ Testing
153
+
154
+ ```bash
155
+ cd backend
156
+ pytest tests/
157
+ ```
158
+
159
+ ## πŸ› οΈ Technology Stack
160
+
161
+ - **Framework**: FastAPI, Streamlit
162
+ - **AI/ML**: LangGraph, LangChain, Google Generative AI
163
+ - **Speech Processing**: AssemblyAI, ElevenLabs
164
+ - **Database**: SQLAlchemy with SQLite/PostgreSQL support
165
+ - **Async**: asyncio, aiosqlite
166
+
167
+ ## πŸ“– Documentation
168
+
169
+ - [Deployment Guide](./DEPLOYMENT.md) - Comprehensive deployment instructions
170
+ - [API Documentation](http://localhost:8000/docs) - Interactive API docs (when running)
171
+
172
+ ## 🀝 Contributing
173
+
174
+ Contributions are welcome! Please feel free to submit a Pull Request.
175
+
176
+ ## πŸ“ License
177
+
178
+ This project is licensed under the MIT License - see the LICENSE file for details.
179
+
180
+ ## πŸ™ Acknowledgments
181
+
182
+ - Google Generative AI for powerful language models
183
+ - LangChain and LangGraph for agent orchestration
184
+ - AssemblyAI for speech recognition
185
+ - ElevenLabs for text-to-speech
186
+ - Hugging Face for hosting platform
187
+
188
+ ## πŸ“§ Contact
189
+
190
+ For questions or support, please open an issue on GitHub.
191
+
192
+ ---
193
+
194
+ Built with ❀️ using AI technologies
start_huggingface.sh ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ echo "=========================================="
6
+ echo "Starting TalentTalkPro on Hugging Face"
7
+ echo "=========================================="
8
+
9
+ # Create static directory if it doesn't exist
10
+ echo "Creating static directory for audio files..."
11
+ mkdir -p /app/backend/static
12
+
13
+ # Start FastAPI backend in the background
14
+ echo "Starting FastAPI backend on port 8000..."
15
+ cd /app/backend && python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 &
16
+ BACKEND_PID=$!
17
+
18
+ # Wait a moment for backend to initialize
19
+ echo "Waiting for backend to initialize..."
20
+ sleep 5
21
+
22
+ # Check if backend is running
23
+ if ! kill -0 $BACKEND_PID 2>/dev/null; then
24
+ echo "ERROR: Backend failed to start!"
25
+ exit 1
26
+ fi
27
+
28
+ echo "Backend started successfully (PID: $BACKEND_PID)"
29
+
30
+ # Start Streamlit frontend on port 7860 (Hugging Face default)
31
+ echo "Starting Streamlit frontend on port 7860..."
32
+ cd /app/frontend && streamlit run app.py --server.port 7860 --server.address 0.0.0.0
33
+
34
+ # If Streamlit exits, kill the backend
35
+ echo "Streamlit stopped, shutting down backend..."
36
+ kill $BACKEND_PID 2>/dev/null || true