refac: usage info

This commit is contained in:
Timothy Jaeryang Baek 2025-09-16 10:28:25 -05:00
parent 83699cf3ef
commit c2f98a4cd2
1 changed files with 14 additions and 14 deletions

View File

@ -2031,6 +2031,20 @@ async def process_chat_response(
)
else:
choices = data.get("choices", [])
# 17421
usage = data.get("usage", {})
usage.update(data.get("timings", {})) # llama.cpp
if usage:
await event_emitter(
{
"type": "chat:completion",
"data": {
"usage": usage,
},
}
)
if not choices:
error = data.get("error", {})
if error:
@ -2042,20 +2056,6 @@ async def process_chat_response(
},
}
)
usage = data.get("usage", {})
usage.update(
data.get("timings", {})
) # llama.cpp
if usage:
await event_emitter(
{
"type": "chat:completion",
"data": {
"usage": usage,
},
}
)
continue
delta = choices[0].get("delta", {})