From 17e1485fbe4cb468b1cf1b538d8cf1f43b58c9c8 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 29 Feb 2024 19:30:31 -0800 Subject: [PATCH] refactor(openai.py): more logging around failed openai calls --- litellm/llms/openai.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/litellm/llms/openai.py b/litellm/llms/openai.py index 549f89da8..90846b627 100644 --- a/litellm/llms/openai.py +++ b/litellm/llms/openai.py @@ -334,10 +334,14 @@ class OpenAIChatCompletion(BaseLLM): model_response_object=model_response, ) except Exception as e: + if print_verbose is not None: + print_verbose(f"openai.py: Received openai error - {str(e)}") if ( "Conversation roles must alternate user/assistant" in str(e) or "user and assistant roles should be alternating" in str(e) ) and messages is not None: + if print_verbose is not None: + print_verbose("openai.py: REFORMATS THE MESSAGE!") # reformat messages to ensure user/assistant are alternating, if there's either 2 consecutive 'user' messages or 2 consecutive 'assistant' message, add a blank 'user' or 'assistant' message to ensure compatibility new_messages = [] for i in range(len(messages) - 1): # type: ignore