mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Merge 86fd3998d1 into 22a349ee70
This commit is contained in:
commit
9e9da0ba2e
2 changed files with 19 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue