From 9201c122e75dede6ba596d8670a3770aeab6e6f1 Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Fri, 22 Mar 2024 23:13:24 -0400 Subject: [PATCH 1/3] Update utils.py fix for #2655 --- litellm/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index 8e9b67694..b2bacb094 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -497,7 +497,7 @@ class ModelResponse(OpenAIObject): object = "embedding" else: object = "chat.completion" - choices = [Choices()] + choices = [Choices(*choices)] if id is None: id = _generate_id() else: From 79201449d214d92b5d85b914476c80ac344bc17d Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Fri, 22 Mar 2024 23:39:17 -0400 Subject: [PATCH 2/3] Update utils.py Fix for creating an empty choices if no choices passed in --- litellm/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index b2bacb094..99e225556 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -497,7 +497,10 @@ class ModelResponse(OpenAIObject): object = "embedding" else: object = "chat.completion" - choices = [Choices(*choices)] + if choices: + choices = [Choices(*choices)] + else: + choices = [Choices()] if id is None: id = _generate_id() else: From ab919004a2183e772474c9535dca7bccbcf6cf4b Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Sat, 23 Mar 2024 00:12:24 -0400 Subject: [PATCH 3/3] Update utils.py fix for constructed from dict choices.message being a dict still instead of Message class. --- litellm/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index 99e225556..c0abbd714 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -354,7 +354,7 @@ class Choices(OpenAIObject): if message is None: self.message = Message(content=None) else: - self.message = message + self.message = Message(**message) if logprobs is not None: self.logprobs = logprobs if enhancements is not None: