mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix: add ProxyException handling to count_tokens endpoint
Match the error handling pattern used in the Anthropic count_tokens endpoint: catch ProxyException separately to surface its status code and message, and include error details in the generic 500 fallback.
This commit is contained in:
parent
c185652577
commit
28a20c180f
1 changed files with 7 additions and 1 deletions
|
|
@ -520,6 +520,12 @@ async def count_response_input_tokens(
|
|||
|
||||
except HTTPException:
|
||||
raise
|
||||
except ProxyException as e:
|
||||
status_code = int(e.code) if e.code and e.code.isdigit() else 500
|
||||
raise HTTPException(
|
||||
status_code=status_code,
|
||||
detail={"error": e.message},
|
||||
)
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.exception(
|
||||
"litellm.proxy.response_api_endpoints.count_response_input_tokens(): Exception occurred - {}".format(
|
||||
|
|
@ -527,7 +533,7 @@ async def count_response_input_tokens(
|
|||
)
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=500, detail={"error": "Internal server error"}
|
||||
status_code=500, detail={"error": f"Internal server error: {str(e)}"}
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue