From 62013520aaa3af9c322c851ddeb292321427ece3 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 11 Nov 2023 19:25:21 -0800 Subject: [PATCH] fix(utils.py): replacing openai.error import statements --- litellm/tests/test_batch_completions.py | 2 +- litellm/tests/test_completion.py | 4 ++-- litellm/utils.py | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/litellm/tests/test_batch_completions.py b/litellm/tests/test_batch_completions.py index 679181684a2..74f33a67d94 100644 --- a/litellm/tests/test_batch_completions.py +++ b/litellm/tests/test_batch_completions.py @@ -7,7 +7,7 @@ import pytest sys.path.insert( 0, os.path.abspath("../..") ) # Adds the parent directory to the system path -from openai.error import Timeout +from openai import Timeout import litellm from litellm import batch_completion, batch_completion_models, completion, batch_completion_models_all_responses # litellm.set_verbose=True diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py index 37b45976564..14276f020c5 100644 --- a/litellm/tests/test_completion.py +++ b/litellm/tests/test_completion.py @@ -106,7 +106,7 @@ def test_completion_gpt4_turbo(): max_tokens=10, ) print(response) - except openai.error.RateLimitError: + except openai.RateLimitError: print("got a rate liimt error") pass except Exception as e: @@ -137,7 +137,7 @@ def test_completion_gpt4_vision(): ], ) print(response) - except openai.error.RateLimitError: + except openai.RateLimitError: print("got a rate liimt error") pass except Exception as e: diff --git a/litellm/utils.py b/litellm/utils.py index 1ac831fae97..408645914f2 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1136,9 +1136,8 @@ def client(original_function): context_window_fallback_dict = kwargs.get("context_window_fallback_dict", {}) if num_retries: - if (isinstance(e, openai.error.APIError) - or isinstance(e, openai.error.Timeout) - or isinstance(e, openai.error.ServiceUnavailableError)): + if (isinstance(e, openai.APIError) + or isinstance(e, openai.Timeout)): kwargs["num_retries"] = num_retries return litellm.completion_with_retries(*args, **kwargs) elif isinstance(e, litellm.exceptions.ContextWindowExceededError) and context_window_fallback_dict and model in context_window_fallback_dict: