From f7d0dbb7ce51ef1ebaa62d39686d76520bba5480 Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Mon, 15 Jul 2024 19:15:35 -0400 Subject: [PATCH] ping Sentry when Claude response is too long --- backend/llm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/llm.py b/backend/llm.py index 9314dcc..6e9de32 100644 --- a/backend/llm.py +++ b/backend/llm.py @@ -151,7 +151,11 @@ async def stream_claude_response( # Return final message response = await stream.get_final_message() + + # Log stop reason print("[STOP REASON] " + str(response.stop_reason)) + if response.stop_reason == "max_tokens": + sentry_sdk.capture_exception(Exception("Claude response too long")) # Close the Anthropic client await client.close()