diff --git a/litellm/utils.py b/litellm/utils.py index b734ae465..2b9660bfc 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3896,12 +3896,16 @@ def get_formatted_prompt( def get_response_string(response_obj: ModelResponse) -> str: - _choices: List[Choices] = response_obj.choices # type: ignore + _choices: List[Union[Choices, StreamingChoices]] = response_obj.choices response_str = "" for choice in _choices: - if choice.message.content is not None: - response_str += choice.message.content + if isinstance(choice, Choices): + if choice.message.content is not None: + response_str += choice.message.content + elif isinstance(choice, StreamingChoices): + if choice.delta.content is not None: + response_str += choice.delta.content return response_str