open-webui/backend/open_webui/routers
Classic298 54f06d8c53
perf: build chat responses without deep-copying the blob through model_dump (#27388)
Chat search built each result row with ChatTitleIdResponse(**chat.model_dump(), ...), which recursively copies the entire chat blob per row only for the constructor to ignore everything except id, title and timestamps: a 60-row search page deep-copied up to 60 full conversations. The folder listing, archived and export endpoints and every single-chat response did the same dump-and-revalidate dance via ChatResponse(**chat.model_dump()).

Search rows are now built from the five fields the response actually has (the snippet helper receives the blob by reference as before), and all 18 ChatResponse constructions use ChatResponse.model_validate(chat, from_attributes=True), which reads the fields off the already-validated ChatModel without copying the blob.

Benchmark (~500 KB chat blob):

| metric | before | after |
| --- | --- | --- |
| search result row | 0.05 ms | 0.003 ms |
| ChatResponse construction | 0.05 ms | 0.003 ms |
| per search page (60 rows) | 3 ms | 0.2 ms |

Beyond CPU, each converted row also stops materializing a second full copy of the conversation in memory while the page is being built.

Functionally verified: both construction styles produce identical model_dump() output for ChatResponse (including defaulted fields absent on ChatModel) and for search rows including the snippet.
2026-07-26 18:57:52 -04:00
..
analytics.py refac 2026-06-29 01:38:41 -05:00
audio.py fix: preserve chunk order when assembling multi-chunk transcriptions (#27417) 2026-07-26 18:55:52 -04:00
auths.py feat: add a master OAuth / OIDC enable toggle in Authentication settings (#26988) 2026-07-26 18:43:21 -04:00
automations.py refac 2026-06-29 13:03:14 -05:00
calendar.py refac 2026-06-29 13:03:14 -05:00
channels.py fix: require message authorship for standard-channel message edit and delete (#27197) 2026-07-23 23:40:03 -04:00
chats.py perf: build chat responses without deep-copying the blob through model_dump (#27388) 2026-07-26 18:57:52 -04:00
configs.py refac 2026-07-14 00:10:28 -04:00
evaluations.py refac 2026-07-24 02:36:10 -04:00
files.py chore: format 2026-07-20 22:11:42 -04:00
folders.py refac 2026-07-23 19:17:19 -04:00
functions.py refac 2026-07-09 17:28:34 -05:00
groups.py refac 2026-06-29 05:47:21 -05:00
images.py refac 2026-07-23 21:29:33 -04:00
knowledge.py feat: sortable title and updated at columns on the knowledge workspace page (#27457) 2026-07-26 18:19:31 -04:00
memories.py refac 2026-06-29 13:03:14 -05:00
models.py refac 2026-07-24 00:47:12 -04:00
notes.py chore: format 2026-07-20 22:11:42 -04:00
notifications.py refac 2026-07-16 01:27:52 -04:00
ollama.py refac 2026-07-23 21:29:33 -04:00
openai.py refac 2026-07-23 21:29:33 -04:00
pipelines.py refac 2026-07-23 21:29:33 -04:00
prompts.py refac 2026-06-29 13:03:14 -05:00
retrieval.py feat: add OpenSERP self-hosted web search backend (#27437) 2026-07-26 18:52:08 -04:00
scim.py refac 2026-06-25 03:31:45 +01:00
skills.py refac 2026-07-17 04:11:11 -04:00
tasks.py refac 2026-07-16 21:57:43 -04:00
terminals.py fix: apply the verified-user role gate to WebSocket authentication (#27537) 2026-07-26 17:27:54 -04:00
tools.py refac 2026-07-09 17:28:34 -05:00
users.py refac 2026-07-24 01:44:30 -04:00
utils.py refac 2026-06-17 02:52:35 +02:00