Merge pull request #2656 from TashaSkyUp/patch-1

fix for: when using ModelResponse.json() to save and then reconstruct a ModelResponse the choices field ends up empty
This commit is contained in:
Krish Dholakia 2024-03-26 08:36:55 -07:00 committed by GitHub
commit 6f11f300fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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:
@ -497,6 +497,9 @@ class ModelResponse(OpenAIObject):
object = "embedding"
else:
object = "chat.completion"
if choices:
choices = [Choices(*choices)]
else:
choices = [Choices()]
if id is None:
id = _generate_id()