fix(utils.py): fix anthropic streaming return usage tokens

This commit is contained in:
Krrish Dholakia 2024-04-24 20:56:10 -07:00
parent 5f862819e7
commit 68f59e01ae

View file

@ -9758,6 +9758,7 @@ class CustomStreamWrapper:
if response_obj is None:
return
completion_obj["content"] = response_obj["text"]
setattr(model_response, "usage", Usage())
if response_obj.get("prompt_tokens", None) is not None:
model_response.usage.prompt_tokens = response_obj[
"prompt_tokens"