Spaces:
Sleeping
Sleeping
axeronis commited on
Commit ·
9964b82
1
Parent(s): cc60d0c
Fix IndentationError in llm_client.py
Browse files
backend/app/services/llm_client.py
CHANGED
|
@@ -217,26 +217,26 @@ class GeminiLLMClient:
|
|
| 217 |
"""
|
| 218 |
|
| 219 |
# Use simple generation
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
)
|
| 230 |
)
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
|
|
|
| 240 |
|
| 241 |
async def transcribe_audio(self, audio_bytes: bytes, mime_type: str = "audio/ogg") -> str:
|
| 242 |
"""
|
|
|
|
| 217 |
"""
|
| 218 |
|
| 219 |
# Use simple generation
|
| 220 |
+
try:
|
| 221 |
+
# Native JSON mode
|
| 222 |
+
model = genai.GenerativeModel(self.default_model_name)
|
| 223 |
+
response = await asyncio.to_thread(
|
| 224 |
+
model.generate_content,
|
| 225 |
+
prompt,
|
| 226 |
+
generation_config=genai.GenerationConfig(
|
| 227 |
+
response_mime_type="application/json",
|
| 228 |
+
temperature=0.1
|
|
|
|
| 229 |
)
|
| 230 |
+
)
|
| 231 |
+
data = json.loads(response.text)
|
| 232 |
+
return AISummary(**data).model_dump()
|
| 233 |
+
except Exception as e:
|
| 234 |
+
logger.error(f"Summary failed: {e}")
|
| 235 |
+
# Return fallback (same as before)
|
| 236 |
+
return {
|
| 237 |
+
"intent": "Error", "heat_score": 50, "recommendation": "Manual review needed",
|
| 238 |
+
"pain_points": [], "objections": [], "draft_reply": "Error"
|
| 239 |
+
} # Simplified fallback
|
| 240 |
|
| 241 |
async def transcribe_audio(self, audio_bytes: bytes, mime_type: str = "audio/ogg") -> str:
|
| 242 |
"""
|