From 37eb7910d2d3f40d8e3021138868c5dc3c9d18d4 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 1 May 2024 13:45:21 -0700 Subject: [PATCH] fix(utils.py): fix azure streaming content filter error chunk --- litellm/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 65cdb8198..6243195ef 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -9603,9 +9603,14 @@ class CustomStreamWrapper: is_finished = True finish_reason = str_line.choices[0].finish_reason if finish_reason == "content_filter": - error_message = json.dumps( - str_line.choices[0].content_filter_result - ) + if hasattr(str_line.choices[0], "content_filter_result"): + error_message = json.dumps( + str_line.choices[0].content_filter_result + ) + else: + error_message = "Azure Response={}".format( + str(dict(str_line)) + ) raise litellm.AzureOpenAIError( status_code=400, message=error_message )