adding context window exceeded error to huggingface

This commit is contained in:
Krrish Dholakia 2023-08-29 16:46:04 -07:00
parent ad493a3109
commit 546ad43b15
3 changed files with 11 additions and 1 deletions

View file

@ -1462,6 +1462,13 @@ def exception_type(model, original_exception, custom_llm_provider):
llm_provider="cohere",
)
elif custom_llm_provider == "huggingface":
if "length limit exceeded" in error_str:
exception_mapping_worked = True
raise ContextWindowExceededError(
message=error_str,
model=model,
llm_provider="huggingface"
)
if hasattr(original_exception, "status_code"):
if original_exception.status_code == 401:
exception_mapping_worked = True