mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-27 06:13:07 +00:00
fix: recognize OpenAI context_length_exceeded errors (#47954)
This commit is contained in:
parent
3188c6ba6a
commit
bc18e10f6b
2 changed files with 7 additions and 0 deletions
|
|
@ -102,6 +102,7 @@ class ExceptionCheckers:
|
|||
"`inputs` tokens + `max_new_tokens` must be",
|
||||
"exceeds the available context size", # llama.cpp/Lemonade
|
||||
"exceeds the maximum number of tokens allowed", # Gemini
|
||||
'"code": "context_length_exceeded"',
|
||||
]
|
||||
for substring in known_exception_substrings:
|
||||
if substring in _error_str_lowercase:
|
||||
|
|
|
|||
|
|
@ -160,6 +160,12 @@ def test_api_base_line_keeps_an_at_sign_in_the_path(api_base: str) -> None:
|
|||
# Tuple format: (error_message, expected_result)
|
||||
context_window_test_cases = [
|
||||
# Positive cases (should return True)
|
||||
(
|
||||
'"{\n "error": {\n "message": "Your input exceeds the context window of this model. '
|
||||
'Please adjust your input and try again.",\n "type": "invalid_request_error",\n'
|
||||
' "param": "input",\n "code": "context_length_exceeded"\n }\n}"',
|
||||
True,
|
||||
),
|
||||
(
|
||||
"An error occurred: The input exceeds the model's maximum context limit of 8192 tokens.",
|
||||
True,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue