mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
add context window exceeded error for anthropic
This commit is contained in:
parent
4b6922918f
commit
509120bf61
4 changed files with 23 additions and 6 deletions
|
@ -1357,6 +1357,14 @@ def exception_type(model, original_exception, custom_llm_provider):
|
|||
else:
|
||||
exception_type = ""
|
||||
if "claude" in model: # one of the anthropics
|
||||
if hasattr(original_exception, "message"):
|
||||
if "prompt is too long" in original_exception.message:
|
||||
exception_mapping_worked = True
|
||||
raise ContextWindowExceededError(
|
||||
message=original_exception.message,
|
||||
model=model,
|
||||
llm_provider="anthropic"
|
||||
)
|
||||
if hasattr(original_exception, "status_code"):
|
||||
print_verbose(f"status_code: {original_exception.status_code}")
|
||||
if original_exception.status_code == 401:
|
||||
|
@ -1372,6 +1380,12 @@ def exception_type(model, original_exception, custom_llm_provider):
|
|||
model=model,
|
||||
llm_provider="anthropic",
|
||||
)
|
||||
elif original_exception.status_code == 413:
|
||||
exception_mapping_worked = True
|
||||
raise ContextWindowExceededError(
|
||||
message=f"AnthropicException - {original_exception.message}",
|
||||
llm_provider="anthropic",
|
||||
)
|
||||
elif original_exception.status_code == 429:
|
||||
exception_mapping_worked = True
|
||||
raise RateLimitError(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue