mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
fix: fix value error if model returns empty completion
This commit is contained in:
parent
9ec4b0902b
commit
cc0e4f4f9f
21 changed files with 84 additions and 50 deletions
|
@ -513,7 +513,10 @@ def completion(
|
|||
## RESPONSE OBJECT
|
||||
choices_list = []
|
||||
for idx, item in enumerate(response["choices"]):
|
||||
message_obj = Message(content=item["text"])
|
||||
if len(item["text"]) > 0:
|
||||
message_obj = Message(content=item["text"])
|
||||
else:
|
||||
message_obj = Message(content=None)
|
||||
choice_obj = Choices(finish_reason=item["finish_reason"], index=idx+1, message=message_obj)
|
||||
choices_list.append(choice_obj)
|
||||
model_response["choices"] = choices_list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue