(feat) improve bedrock, sagemaker exception mapping

This commit is contained in:
ishaan-jaff 2024-01-15 21:22:22 -08:00
parent 893a2c3c7b
commit 00ac18e8b7
2 changed files with 18 additions and 2 deletions

View file

@ -5895,6 +5895,7 @@ def exception_type(
"too many tokens" in error_str
or "expected maxLength:" in error_str
or "Input is too long" in error_str
or "prompt: length: 1.." in error_str
or "Too many input tokens" in error_str
):
exception_mapping_worked = True
@ -5988,6 +5989,17 @@ def exception_type(
llm_provider="sagemaker",
response=original_exception.response,
)
elif (
"`inputs` tokens + `max_new_tokens` must be <=" in error_str
or "instance type with more CPU capacity or memory" in error_str
):
exception_mapping_worked = True
raise ContextWindowExceededError(
message=f"SagemakerException - {error_str}",
model=model,
llm_provider="sagemaker",
response=original_exception.response,
)
elif custom_llm_provider == "vertex_ai":
if (
"Vertex AI API has not been used in project" in error_str