This commit is contained in:
mgeorgaklis 2026-08-27 19:53:11 -05:00 committed by GitHub
commit 9e9da0ba2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View file

@ -91,6 +91,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
"prompt is too long",
]
for substring in known_exception_substrings:
if substring in _error_str_lowercase:

View file

@ -406,6 +406,24 @@ def test_anthropic_context_window_error_mapping(error_message):
assert excinfo.value.llm_provider == "anthropic"
def test_vertex_ai_anthropic_context_window_error_mapping():
error_message = (
'{"type":"error","error":{"type":"invalid_request_error",'
'"message":"prompt is too long: 1000423 tokens > 1000000 maximum"}}'
)
with pytest.raises(litellm.ContextWindowExceededError) as excinfo:
exception_type(
model="claude-opus-5",
original_exception=Exception(error_message),
custom_llm_provider="vertex_ai",
)
assert excinfo.value.status_code == 400
assert excinfo.value.llm_provider == "vertex_ai"
assert excinfo.value.model == "claude-opus-5"
# Test cases for Vertex AI RateLimitError mapping
# As per https://github.com/BerriAI/litellm/issues/16189
vertex_rate_limit_test_cases = [