open-webui/backend/open_webui/utils
Classic298 dfa2511199
fix: persist token usage data for non-streaming chat responses (#22166)
The non-streaming response handler was saving assistant messages without
their usage/token data. While the streaming handler correctly extracted
and saved usage information, the non-streaming path discarded it entirely.

This caused assistant messages from non-streaming completions to have
NULL usage in the chat_message table, making them invisible to the
analytics token aggregation queries and contributing to the '0 tokens'
display in Admin Panel Analytics.

Extract and normalize the usage data from the API response and include
it in the database upsert, matching the pattern already used by the
streaming handler.
2026-03-07 17:17:36 -06:00
..
access_control chore: format 2026-03-02 17:26:18 -06:00
images refac/fix: comfyui filter output node type 2025-12-30 12:24:48 +04:00
mcp Merge pull request #21485 from Classic298/claude/fix-mcp-ssl-check-0janH 2026-02-19 14:08:15 -06:00
telemetry feat: add otel system metrics instrumentation (#22265) 2026-03-06 14:24:24 -06:00
actions.py refac 2026-02-11 16:40:40 -06:00
anthropic.py refac 2026-02-21 15:35:34 -06:00
audit.py chore: format 2026-02-11 16:24:11 -06:00
auth.py refac 2026-02-19 16:29:19 -06:00
channels.py feat: channel/thread @ model 2025-09-17 00:49:44 -05:00
chat.py refac 2026-02-16 15:32:28 -06:00
code_interpreter.py chore: format 2026-02-11 16:24:11 -06:00
embeddings.py chore: format 2026-02-11 16:24:11 -06:00
files.py refac 2026-01-28 01:18:39 +04:00
filter.py fix: resolve valve priority for actions and filters via class instantiation (#21841) 2026-02-24 15:58:23 -06:00
groups.py refac/enh: db session sharing 2025-12-29 00:21:18 +04:00
headers.py refac 2026-02-06 03:23:37 +04:00
logger.py fix: correct ENABLE_AUDIT_STDOUT stdout filter (#21777) 2026-02-23 11:52:29 -06:00
middleware.py fix: persist token usage data for non-streaming chat responses (#22166) 2026-03-07 17:17:36 -06:00
misc.py refac 2026-02-27 16:03:12 -06:00
models.py refac 2026-03-07 17:03:23 -06:00
oauth.py refac 2026-02-24 17:04:07 -06:00
payload.py refac: ollama str think support 2026-02-22 17:11:50 -06:00
pdf_generator.py chore: remove unnecessary Path conversions 2025-03-04 19:53:52 +02:00
plugin.py refac 2026-02-21 15:35:34 -06:00
rate_limit.py feat: signin rate limit 2025-12-02 03:52:38 -05:00
redis.py REDIS_RECONNECT_DELAY as positive float for handle retry delay on timeout/connection errors (#21021) 2026-01-29 17:13:03 +04:00
response.py refac 2026-02-23 18:23:34 -06:00
sanitize.py chore: format 2026-02-11 16:24:11 -06:00
security_headers.py refac 2026-02-24 14:47:28 -06:00
task.py chore: format 2026-02-11 16:24:11 -06:00
tools.py fix: omit None-valued query params in execute_tool_server (#22144) 2026-03-02 16:51:15 -06:00
validate.py chore: format 2026-02-11 16:24:11 -06:00
webhook.py refac 2026-01-08 00:42:29 +04:00