mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +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
|
@ -154,7 +154,8 @@ def completion(
|
|||
)
|
||||
else:
|
||||
try:
|
||||
model_response["choices"][0]["message"]["content"] = completion_response[0]["generation"]
|
||||
if len(completion_response[0]["generation"]) > 0:
|
||||
model_response["choices"][0]["message"]["content"] = completion_response[0]["generation"]
|
||||
except:
|
||||
raise SagemakerError(message=json.dumps(completion_response), status_code=response.status_code)
|
||||
|
||||
|
@ -163,7 +164,7 @@ def completion(
|
|||
encoding.encode(prompt)
|
||||
)
|
||||
completion_tokens = len(
|
||||
encoding.encode(model_response["choices"][0]["message"]["content"])
|
||||
encoding.encode(model_response["choices"][0]["message"].get("content", ""))
|
||||
)
|
||||
|
||||
model_response["created"] = time.time()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue