Spaces:
Sleeping
Sleeping
Graham Paasch commited on
Commit ·
cab0365
1
Parent(s): 3afb190
Fix syntax error in Hugging Face response handling
Browse files- agent/llm_client.py +3 -3
agent/llm_client.py
CHANGED
|
@@ -475,14 +475,14 @@ class LLMClient:
|
|
| 475 |
resp.raise_for_status()
|
| 476 |
data = resp.json()
|
| 477 |
# Response can be list or dict
|
| 478 |
-
text =
|
| 479 |
if isinstance(data, list) and data:
|
| 480 |
if isinstance(data[0], dict):
|
| 481 |
-
text = data[0].get(
|
| 482 |
else:
|
| 483 |
text = str(data[0])
|
| 484 |
elif isinstance(data, dict):
|
| 485 |
-
text = data.get(
|
| 486 |
if monitor:
|
| 487 |
monitor.complete_call(call_id, success=True)
|
| 488 |
return text
|
|
|
|
| 475 |
resp.raise_for_status()
|
| 476 |
data = resp.json()
|
| 477 |
# Response can be list or dict
|
| 478 |
+
text = ""
|
| 479 |
if isinstance(data, list) and data:
|
| 480 |
if isinstance(data[0], dict):
|
| 481 |
+
text = data[0].get("generated_text", "") or data[0].get("generated_texts", "")
|
| 482 |
else:
|
| 483 |
text = str(data[0])
|
| 484 |
elif isinstance(data, dict):
|
| 485 |
+
text = data.get("generated_text", "") or data.get("generated_texts", "") or ""
|
| 486 |
if monitor:
|
| 487 |
monitor.complete_call(call_id, success=True)
|
| 488 |
return text
|