diff --git a/litellm/utils.py b/litellm/utils.py index 00d627c6b..713861dad 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -500,7 +500,10 @@ class ModelResponse(OpenAIObject): if choices is not None and isinstance(choices, list): new_choices = [] for choice in choices: - _new_choice = StreamingChoices(**choice) + if isinstance(choice, StreamingChoices): + _new_choice = choice + elif isinstance(choice, dict): + _new_choice = StreamingChoices(**choice) new_choices.append(_new_choice) choices = new_choices else: @@ -513,7 +516,10 @@ class ModelResponse(OpenAIObject): if choices is not None and isinstance(choices, list): new_choices = [] for choice in choices: - _new_choice = Choices(**choice) + if isinstance(choice, Choices): + _new_choice = choice + elif isinstance(choice, dict): + _new_choice = Choices(**choice) new_choices.append(_new_choice) choices = new_choices else: