add context window exceeded error mapping to openai

This commit is contained in:
Krrish Dholakia 2023-08-29 16:08:00 -07:00
parent d7fe4f6c90
commit f7955d52b5
4 changed files with 10 additions and 5 deletions

View file

@ -1343,6 +1343,12 @@ def exception_type(model, original_exception, custom_llm_provider):
original_exception.llm_provider = "azure"
else:
original_exception.llm_provider = "openai"
if "This model's maximum context length is" in original_exception:
raise ContextWindowExceededError(
message=str(original_exception),
model=model,
llm_provider=original_exception.llm_provider
)
raise original_exception
elif model:
error_str = str(original_exception)