Spaces:
Sleeping
Sleeping
Graham Paasch commited on
Commit ·
a97abe4
1
Parent(s): 5609762
Log full exception details for Anthropic errors
Browse files- agent/llm_client.py +6 -4
agent/llm_client.py
CHANGED
|
@@ -338,9 +338,10 @@ class LLMClient:
|
|
| 338 |
return content
|
| 339 |
|
| 340 |
except Exception as e:
|
| 341 |
-
|
|
|
|
| 342 |
if monitor:
|
| 343 |
-
monitor.complete_call(call_id, success=False, error_message=
|
| 344 |
# Fallback to OpenAI if available
|
| 345 |
if self.openai_key:
|
| 346 |
logger.info("Falling back to OpenAI due to Anthropic error")
|
|
@@ -392,9 +393,10 @@ class LLMClient:
|
|
| 392 |
)
|
| 393 |
|
| 394 |
except Exception as e:
|
| 395 |
-
|
|
|
|
| 396 |
if monitor:
|
| 397 |
-
monitor.complete_call(call_id, success=False, error_message=
|
| 398 |
if self.openai_key:
|
| 399 |
logger.info("Falling back to OpenAI streaming due to Anthropic error")
|
| 400 |
yield from self._stream_openai(messages, temperature, max_tokens)
|
|
|
|
| 338 |
return content
|
| 339 |
|
| 340 |
except Exception as e:
|
| 341 |
+
err_msg = f"{e} | cause: {repr(getattr(e, '__cause__', ''))}"
|
| 342 |
+
logger.error(f"Anthropic API error: {err_msg}")
|
| 343 |
if monitor:
|
| 344 |
+
monitor.complete_call(call_id, success=False, error_message=err_msg)
|
| 345 |
# Fallback to OpenAI if available
|
| 346 |
if self.openai_key:
|
| 347 |
logger.info("Falling back to OpenAI due to Anthropic error")
|
|
|
|
| 393 |
)
|
| 394 |
|
| 395 |
except Exception as e:
|
| 396 |
+
err_msg = f"{e} | cause: {repr(getattr(e, '__cause__', ''))}"
|
| 397 |
+
logger.error(f"Anthropic streaming error: {err_msg}")
|
| 398 |
if monitor:
|
| 399 |
+
monitor.complete_call(call_id, success=False, error_message=err_msg)
|
| 400 |
if self.openai_key:
|
| 401 |
logger.info("Falling back to OpenAI streaming due to Anthropic error")
|
| 402 |
yield from self._stream_openai(messages, temperature, max_tokens)
|