jmisak commited on
Commit
b81ee10
Β·
verified Β·
1 Parent(s): 56589d3

Upload 5 files

Browse files
Files changed (4) hide show
  1. DEPLOYMENT_READY.md +216 -0
  2. MINIMUM_FILES_REQUIRED.txt +65 -0
  3. QUICK_START.txt +82 -0
  4. app.py +31 -1
DEPLOYMENT_READY.md ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # βœ… DEPLOYMENT READY FOR HUGGINGFACE SPACES
2
+
3
+ ## Status: All Import Errors Fixed!
4
+
5
+ Your app will no longer crash on missing files. Optional modules gracefully degrade.
6
+
7
+ ---
8
+
9
+ ## πŸ”§ What Was Fixed
10
+
11
+ ### Issue 1: `ModuleNotFoundError: No module named 'quote_extractor'`
12
+ **Status:** βœ… FIXED
13
+ - Made `quote_extractor` optional
14
+ - If missing: Shows warning, disables quote features
15
+ - App continues to work
16
+
17
+ ### Issue 2: `ModuleNotFoundError: No module named 'production_logger'`
18
+ **Status:** βœ… FIXED
19
+ - Made `production_logger` optional
20
+ - If missing: Shows warning, uses basic logging
21
+ - App continues to work
22
+
23
+ ### Issue 3: Quality Score 0.00
24
+ **Status:** βœ… FIXED
25
+ - Removed hardcoded LM Studio configuration
26
+ - Configured local model inference (Phi-3-mini)
27
+ - Works on HuggingFace Spaces without .env
28
+
29
+ ---
30
+
31
+ ## πŸ“¦ Files to Upload
32
+
33
+ ### MINIMUM (9 files - core functionality):
34
+ ```
35
+ 1. app.py
36
+ 2. llm.py
37
+ 3. extractors.py
38
+ 4. tagging.py
39
+ 5. chunking.py
40
+ 6. validation.py
41
+ 7. reporting.py
42
+ 8. dashboard.py
43
+ 9. requirements.txt
44
+ ```
45
+
46
+ ### RECOMMENDED (11 files - full features):
47
+ ```
48
+ Same as above PLUS:
49
+ 10. production_logger.py
50
+ 11. quote_extractor.py
51
+ ```
52
+
53
+ ---
54
+
55
+ ## πŸš€ Deploy Now
56
+
57
+ ### Step 1: Create Space
58
+ 1. Go to: https://huggingface.co/new-space
59
+ 2. SDK: **Gradio**
60
+ 3. Hardware: **GPU (T4)** ⚠️ Required for good performance
61
+
62
+ ### Step 2: Upload Files
63
+ 1. Click "Files" β†’ "Upload files"
64
+ 2. Drag the 9-11 files listed above
65
+ 3. Click "Commit"
66
+
67
+ ### Step 3: Wait for Build
68
+ - First time: ~5-10 minutes (installs dependencies + downloads model)
69
+ - Watch "Logs" tab for progress
70
+
71
+ ### Step 4: Verify
72
+ Check logs for:
73
+ ```
74
+ βœ… Configuration loaded for HuggingFace Spaces
75
+ πŸš€ TranscriptorAI Enterprise - LLM Backend: local
76
+ [Local Model] Loading microsoft/Phi-3-mini-4k-instruct...
77
+ [Local Model] βœ… Model loaded on cuda:0
78
+ ```
79
+
80
+ ---
81
+
82
+ ## βš™οΈ What Happens on Startup
83
+
84
+ ### With All 11 Files:
85
+ ```
86
+ βœ… Configuration loaded for HuggingFace Spaces
87
+ πŸš€ TranscriptorAI Enterprise - LLM Backend: local
88
+ πŸ”§ USE_HF_API: False
89
+ πŸ”§ USE_LMSTUDIO: False
90
+ πŸ”§ DEBUG_MODE: False
91
+ [Local Model] Loading microsoft/Phi-3-mini-4k-instruct...
92
+ [Local Model] βœ… Model loaded on cuda:0
93
+ Running on local URL: http://0.0.0.0:7860
94
+ ```
95
+
96
+ ### With Only 9 Core Files (Missing Optional):
97
+ ```
98
+ ⚠️ Production logging not available - using basic logging
99
+ ⚠️ Quote extraction not available - reports will not include storytelling quotes
100
+ βœ… Configuration loaded for HuggingFace Spaces
101
+ πŸš€ TranscriptorAI Enterprise - LLM Backend: local
102
+ [Local Model] Loading microsoft/Phi-3-mini-4k-instruct...
103
+ [Local Model] βœ… Model loaded on cuda:0
104
+ Running on local URL: http://0.0.0.0:7860
105
+ ```
106
+
107
+ **Both work!** Warnings are normal if you skip optional files.
108
+
109
+ ---
110
+
111
+ ## πŸ§ͺ Test Your Deployment
112
+
113
+ 1. Upload a DOCX transcript
114
+ 2. Select "HCP" as interviewee type
115
+ 3. Click "Analyze Transcripts"
116
+ 4. Wait ~5-10 minutes
117
+
118
+ **Expected Results:**
119
+ - βœ… Quality Score: 0.7-1.0 (not 0.00!)
120
+ - βœ… CSV download available
121
+ - βœ… PDF download available
122
+ - βœ… Dashboard shows charts
123
+
124
+ ---
125
+
126
+ ## πŸ› Troubleshooting
127
+
128
+ ### Issue: Still getting `ModuleNotFoundError`
129
+ **Check:** Did you upload the right `app.py`?
130
+ - Make sure you're uploading the UPDATED app.py (with optional imports)
131
+ - Re-download/copy from your local directory
132
+
133
+ ### Issue: Quality Score still 0.00
134
+ **Enable debug mode:**
135
+ 1. Settings β†’ Variables
136
+ 2. Add: `DEBUG_MODE=True`
137
+ 3. Restart Space
138
+ 4. Check logs for detailed error messages
139
+
140
+ ### Issue: Very slow processing
141
+ **Check:**
142
+ 1. Settings β†’ Hardware
143
+ 2. Should be "GPU (T4)" not "CPU"
144
+ 3. Restart Space if you changed it
145
+
146
+ ### Issue: Out of memory
147
+ **Use smaller model:**
148
+ 1. Settings β†’ Variables
149
+ 2. Add: `LOCAL_MODEL=TinyLlama/TinyLlama-1.1B-Chat-v1.0`
150
+ 3. Restart Space
151
+
152
+ ---
153
+
154
+ ## πŸ“‹ Quick Checklist
155
+
156
+ Before uploading, verify:
157
+
158
+ - [ ] You have app.py (the UPDATED one with optional imports)
159
+ - [ ] You have llm.py (with local model support)
160
+ - [ ] You have requirements.txt (with transformers, torch, accelerate)
161
+ - [ ] You selected GPU hardware in Space settings
162
+ - [ ] You did NOT upload .env file
163
+ - [ ] You did NOT upload test_*.py files
164
+
165
+ ---
166
+
167
+ ## πŸ’Ύ File Verification
168
+
169
+ Run this to verify you have all files:
170
+
171
+ ```bash
172
+ # Check required files
173
+ ls -1 app.py llm.py extractors.py tagging.py chunking.py validation.py reporting.py dashboard.py requirements.txt
174
+
175
+ # Check optional files
176
+ ls -1 production_logger.py quote_extractor.py
177
+ ```
178
+
179
+ All should show the filename (not "No such file").
180
+
181
+ ---
182
+
183
+ ## ✨ You're Ready!
184
+
185
+ 1. βœ… Import errors fixed
186
+ 2. βœ… Local model configured
187
+ 3. βœ… Optional modules gracefully degrade
188
+ 4. βœ… No .env needed
189
+ 5. βœ… No terminal commands needed
190
+
191
+ **Just upload the files and it works!**
192
+
193
+ ---
194
+
195
+ ## πŸ“ž Still Having Issues?
196
+
197
+ **Most common causes:**
198
+ 1. Uploaded old `app.py` (without optional import fixes)
199
+ 2. Selected CPU instead of GPU
200
+ 3. Missing a core file (one of the 9 required)
201
+
202
+ **Quick fix:**
203
+ - Re-download/copy `app.py` from your directory
204
+ - Make sure it has the lines:
205
+ ```python
206
+ try:
207
+ from production_logger import ...
208
+ except ImportError:
209
+ print("⚠️ Production logging not available...")
210
+ ```
211
+
212
+ ---
213
+
214
+ **Last Updated:** October 2025
215
+
216
+ **Status:** READY TO DEPLOY πŸš€
MINIMUM_FILES_REQUIRED.txt ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ================================================================================
2
+ MINIMUM FILES REQUIRED FOR HUGGINGFACE SPACES
3
+ ================================================================================
4
+
5
+ THESE 9 FILES ARE ABSOLUTELY REQUIRED:
6
+ (App will crash without these)
7
+
8
+ 1. app.py ← MAIN FILE (HF Spaces entry point)
9
+ 2. llm.py ← LLM inference
10
+ 3. extractors.py ← Document extraction
11
+ 4. tagging.py ← Speaker tagging
12
+ 5. chunking.py ← Text chunking
13
+ 6. validation.py ← Quality validation
14
+ 7. reporting.py ← CSV/PDF reports
15
+ 8. dashboard.py ← Dashboard generation
16
+ 9. requirements.txt ← Python dependencies
17
+
18
+ ================================================================================
19
+ OPTIONAL FILES:
20
+ (App will work without these, but with reduced features)
21
+
22
+ 10. production_logger.py ← Advanced logging (now optional)
23
+ 11. quote_extractor.py ← Market research quotes (now optional)
24
+
25
+ If missing, you'll see warnings like:
26
+ ⚠️ Production logging not available - using basic logging
27
+ ⚠️ Quote extraction not available - reports will not include storytelling quotes
28
+
29
+ ================================================================================
30
+ RECOMMENDED UPLOAD:
31
+ ================================================================================
32
+
33
+ Upload all 11 files for full functionality:
34
+
35
+ 1. app.py
36
+ 2. llm.py
37
+ 3. extractors.py
38
+ 4. tagging.py
39
+ 5. chunking.py
40
+ 6. validation.py
41
+ 7. reporting.py
42
+ 8. dashboard.py
43
+ 9. requirements.txt
44
+ 10. production_logger.py
45
+ 11. quote_extractor.py
46
+
47
+ ================================================================================
48
+ SPACE SETTINGS:
49
+ ================================================================================
50
+
51
+ SDK: Gradio
52
+ Hardware: GPU (T4 or better)
53
+
54
+ ================================================================================
55
+ STATUS: READY TO DEPLOY
56
+ ================================================================================
57
+
58
+ βœ… Import errors fixed - app will not crash on missing optional files
59
+ βœ… Local model inference configured
60
+ βœ… No .env file needed
61
+ βœ… No terminal commands needed
62
+
63
+ Just upload the files and it works!
64
+
65
+ ================================================================================
QUICK_START.txt ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ================================================================================
2
+ HUGGINGFACE SPACES - QUICK START GUIDE
3
+ ================================================================================
4
+
5
+ FIXED: Import errors resolved! App will not crash on missing files.
6
+
7
+ ================================================================================
8
+ STEP 1: CREATE SPACE
9
+ ================================================================================
10
+
11
+ Go to: https://huggingface.co/new-space
12
+
13
+ Settings:
14
+ SDK: Gradio
15
+ Hardware: GPU (T4) ← IMPORTANT!
16
+
17
+ ================================================================================
18
+ STEP 2: UPLOAD THESE FILES
19
+ ================================================================================
20
+
21
+ REQUIRED (9 files minimum):
22
+
23
+ [βœ“] app.py
24
+ [βœ“] llm.py
25
+ [βœ“] extractors.py
26
+ [βœ“] tagging.py
27
+ [βœ“] chunking.py
28
+ [βœ“] validation.py
29
+ [βœ“] reporting.py
30
+ [βœ“] dashboard.py
31
+ [βœ“] requirements.txt
32
+
33
+ OPTIONAL (recommended):
34
+
35
+ [ ] production_logger.py
36
+ [ ] quote_extractor.py
37
+
38
+ ================================================================================
39
+ STEP 3: WAIT FOR BUILD
40
+ ================================================================================
41
+
42
+ First time: ~5-10 minutes
43
+ - Installing dependencies
44
+ - Downloading Phi-3-mini model
45
+
46
+ Watch "Logs" tab for:
47
+ βœ… Model loaded on cuda:0
48
+ βœ… Running on local URL
49
+
50
+ ================================================================================
51
+ STEP 4: TEST
52
+ ================================================================================
53
+
54
+ 1. Upload a transcript (DOCX or PDF)
55
+ 2. Select "HCP" interviewee type
56
+ 3. Click "Analyze Transcripts"
57
+ 4. Wait ~5-10 minutes
58
+
59
+ Expected: Quality Score 0.7-1.0 (not 0.00!)
60
+
61
+ ================================================================================
62
+ TROUBLESHOOTING
63
+ ================================================================================
64
+
65
+ Still getting ModuleNotFoundError?
66
+ β†’ Make sure you uploaded the UPDATED app.py
67
+
68
+ Very slow processing?
69
+ β†’ Check Hardware is set to GPU (not CPU)
70
+
71
+ Quality Score 0.00?
72
+ β†’ Settings β†’ Variables β†’ Add DEBUG_MODE=True
73
+ β†’ Check logs for error messages
74
+
75
+ ================================================================================
76
+ YOU'RE READY!
77
+ ================================================================================
78
+
79
+ Just upload the 9-11 files and it works.
80
+ No .env needed. No terminal commands needed.
81
+
82
+ ================================================================================
app.py CHANGED
@@ -9,7 +9,37 @@ from llm import query_llm, extract_structured_data
9
  from reporting import generate_enhanced_csv, generate_enhanced_pdf
10
  from dashboard import generate_comprehensive_dashboard
11
  from validation import validate_transcript_quality, check_data_completeness
12
- from production_logger import init_session, ProductionLogger, PerformanceMonitor
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # Optional: Quote extraction for market research storytelling
15
  try:
 
9
  from reporting import generate_enhanced_csv, generate_enhanced_pdf
10
  from dashboard import generate_comprehensive_dashboard
11
  from validation import validate_transcript_quality, check_data_completeness
12
+
13
+ # Optional: Production logging for session tracking
14
+ try:
15
+ from production_logger import init_session, ProductionLogger, PerformanceMonitor
16
+ HAS_PRODUCTION_LOGGING = True
17
+ except ImportError:
18
+ HAS_PRODUCTION_LOGGING = False
19
+ print("⚠️ Production logging not available - using basic logging")
20
+
21
+ # Stub classes when production_logger is not available
22
+ class ProductionLogger:
23
+ def __init__(self, session_id):
24
+ self.session_id = session_id
25
+ self.logger = self
26
+ def info(self, msg):
27
+ print(f"[INFO] {msg}")
28
+ def warning(self, msg):
29
+ print(f"[WARNING] {msg}")
30
+ def error(self, msg):
31
+ print(f"[ERROR] {msg}")
32
+
33
+ class PerformanceMonitor:
34
+ def __init__(self, logger):
35
+ self.logger = logger
36
+ def start_timer(self, name):
37
+ pass
38
+ def end_timer(self, name):
39
+ pass
40
+
41
+ def init_session(session_id):
42
+ return ProductionLogger(session_id)
43
 
44
  # Optional: Quote extraction for market research storytelling
45
  try: