Spaces:
Sleeping
Sleeping
Commit ·
882becc
1
Parent(s): e2d9873
Fix: Handle list type in context_priority_used extraction
Browse files
app.py
CHANGED
|
@@ -242,9 +242,17 @@ def generate_response(user_message: str, history: List[Dict], context: Dict) ->
|
|
| 242 |
)
|
| 243 |
|
| 244 |
routing_mode = trace.get("routing_mode", "UNKNOWN")
|
| 245 |
-
context_used = list(trace.get("context_priority_used", {}).get("priority_1", {}).keys())
|
| 246 |
|
| 247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
|
| 249 |
return response_text, context_used, routing_mode
|
| 250 |
|
|
|
|
| 242 |
)
|
| 243 |
|
| 244 |
routing_mode = trace.get("routing_mode", "UNKNOWN")
|
|
|
|
| 245 |
|
| 246 |
+
# Extract context_used safely (can be list or dict)
|
| 247 |
+
priority_1 = trace.get("context_priority_used", {}).get("priority_1", [])
|
| 248 |
+
if isinstance(priority_1, dict):
|
| 249 |
+
context_used = list(priority_1.keys())
|
| 250 |
+
elif isinstance(priority_1, list):
|
| 251 |
+
context_used = priority_1
|
| 252 |
+
else:
|
| 253 |
+
context_used = []
|
| 254 |
+
|
| 255 |
+
logger.info(f"[Hybrid] Mode: {routing_mode}, Diagnosis: {str(trace.get('stages', {}).get('confirmation', {}).get('final', 'N/A'))[:50]}")
|
| 256 |
|
| 257 |
return response_text, context_used, routing_mode
|
| 258 |
|