From dfd91c5d464b64e91d3cb4e89a7c67e5e6576afc Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 10 Oct 2023 21:56:14 -0700 Subject: [PATCH] fix(openai-py): fix linting errors --- litellm/llms/openai.py | 4 +++- litellm/tests/test_exceptions.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/llms/openai.py b/litellm/llms/openai.py index febef17a26..257238a544 100644 --- a/litellm/llms/openai.py +++ b/litellm/llms/openai.py @@ -210,8 +210,10 @@ class OpenAIChatCompletion(BaseLLM): headers["Authorization"] = f"Bearer {api_key}" return headers - def convert_to_model_response_object(self, response_object: dict, model_response_object: ModelResponse): + def convert_to_model_response_object(self, response_object: Optional[dict]=None, model_response_object: Optional[ModelResponse]=None): try: + if response_object is None or model_response_object is None: + raise CustomOpenAIError(status_code=500, message="Error in response object format") choice_list=[] for idx, choice in enumerate(response_object["choices"]): message = Message(content=choice["message"]["content"], role=choice["message"]["role"]) diff --git a/litellm/tests/test_exceptions.py b/litellm/tests/test_exceptions.py index 8a29950a2d..4c37732a1b 100644 --- a/litellm/tests/test_exceptions.py +++ b/litellm/tests/test_exceptions.py @@ -12,7 +12,6 @@ from litellm import ( embedding, completion, # AuthenticationError, - InvalidRequestError, ContextWindowExceededError, # RateLimitError, # ServiceUnavailableError,