diff --git a/litellm/__init__.py b/litellm/__init__.py index 5812e89bba9..670c19f4c13 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -531,7 +531,7 @@ from .llms.bedrock import ( AmazonLlamaConfig, ) from .llms.openai import OpenAIConfig, OpenAITextCompletionConfig -from .llms.azure import AzureOpenAIConfig +from .llms.azure import AzureOpenAIConfig, AzureOpenAIError from .main import * # type: ignore from .integrations import * from .exceptions import ( diff --git a/litellm/tests/test_stream_chunk_builder.py b/litellm/tests/test_stream_chunk_builder.py index f73265d6588..06ca04116d3 100644 --- a/litellm/tests/test_stream_chunk_builder.py +++ b/litellm/tests/test_stream_chunk_builder.py @@ -93,7 +93,7 @@ def test_stream_chunk_builder_litellm_function_call(): def test_stream_chunk_builder_litellm_tool_call(): try: - litellm.set_verbose = False + litellm.set_verbose = True response = litellm.completion( model="azure/gpt-4-nov-release", messages=messages, @@ -101,6 +101,7 @@ def test_stream_chunk_builder_litellm_tool_call(): stream=True, api_key="os.environ/AZURE_FRANCE_API_KEY", api_base="https://openai-france-1234.openai.azure.com", + api_version="2023-12-01-preview", complete_response=True, ) diff --git a/litellm/utils.py b/litellm/utils.py index 5b6af9271d3..77e4de8e913 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -7147,6 +7147,16 @@ class CustomStreamWrapper: else: logprobs = None + if ( + hasattr(str_line.choices[0], "content_filter_result") + and str_line.choices[0].content_filter_result is not None + ): + error_message = json.dumps( + str_line.choices[0].content_filter_result + ) + raise litellm.AzureOpenAIError( + status_code=400, message=error_message + ) return { "text": text, "is_finished": is_finished, @@ -7695,7 +7705,6 @@ class CustomStreamWrapper: chunk = self.completion_stream else: chunk = next(self.completion_stream) - print_verbose(f"value of chunk: {chunk} ") if chunk is not None and chunk != b"": print_verbose(f"PROCESSED CHUNK PRE CHUNK CREATOR: {chunk}") response = self.chunk_creator(chunk=chunk)