diff --git a/litellm/__pycache__/utils.cpython-311.pyc b/litellm/__pycache__/utils.cpython-311.pyc index d59bb1d5e..27a856762 100644 Binary files a/litellm/__pycache__/utils.cpython-311.pyc and b/litellm/__pycache__/utils.cpython-311.pyc differ diff --git a/litellm/tests/test_exceptions.py b/litellm/tests/test_exceptions.py index 4d8edca17..8dfad1dcb 100644 --- a/litellm/tests/test_exceptions.py +++ b/litellm/tests/test_exceptions.py @@ -35,12 +35,12 @@ litellm.failure_callback = ["sentry"] # Approach: Run each model through the test -> assert if the correct error (always the same one) is triggered # models = ["gpt-3.5-turbo", "chatgpt-test", "claude-instant-1", "command-nightly"] -test_model = "claude-instant-1" -models = ["claude-instant-1"] +test_model = "gpt-3.5-turbo" +models = ["gpt-3.5-turbo"] def logging_fn(model_call_dict): - return + # return if "model" in model_call_dict: print(f"model_call_dict: {model_call_dict['model']}") else: @@ -59,7 +59,6 @@ def test_context_window(model): messages=messages, logger_fn=logging_fn, ) - print(f"response: {response}") except ContextWindowExceededError as e: print(f"ContextWindowExceededError: {e.llm_provider}") return diff --git a/litellm/utils.py b/litellm/utils.py index ac0ca8d4a..a43da00c8 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 47069b9e8..87c7e2ab7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "0.1.501" +version = "0.1.502" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License"