mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #22302] [CLOSED] perf(models): deduplicate action/filter objects in /api/models response #26600
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22302
Author: @Classic298
Created: 3/6/2026
Status: ❌ Closed
Base:
dev← Head:perf/dedup-action-icons📝 Commits (1)
4344937perf(models): deduplicate action/filter objects in /api/models response📊 Changes
2 files changed (+50 additions, -2 deletions)
View changed files
📝
backend/open_webui/main.py(+30 -1)📝
src/lib/apis/index.ts(+20 -1)📄 Description
Performance: Deduplicate action/filter objects in /api/models response
Why this matters
The savings scale with (models × actions/filters) and compound quickly:
is transmitted once instead of twice
9 times
sending 5 icon blobs 29 extra times each — easily dozens of megabytes
The payload reduction can exceed 100MB
This endpoint is called on every page load and every refresh, so this
is not a one-time cost — it is the tax paid every time a user opens
the app. Especially noticeable on setups with poor network conditions,
large model catalogs, or both.
Problem
The /api/models endpoint embeds full action and filter objects (including base64 icon data) directly on every model in the response. Since global actions/filters are shared across all models, this means M identical action blobs are serialized N times — once per model.
In a concrete scenario with 20 models sharing 3 global actions where each action has a ~500KB base64 icon, the JSON payload bloats to ~30MB of redundant data. This directly impacts initial page load time, network bandwidth, and time-to-interactive.
Solution
The backend extracts unique action/filter objects into top-level "actions" and "filters" dicts, keyed by ID. Each model carries only action_ids/filter_ids string arrays.
Move unique action and filter objects into top-level "actions" and "filters" dicts in the API response, keyed by their ID. Each model now carries only action_ids and filter_ids arrays (lightweight string arrays) instead of full embedded objects.
Response shape before:
Response shape after:
The frontend API layer rehydrates these back into model.actions and model.filters arrays using object references, so no downstream component changes are needed. Since JavaScript passes objects by reference, the rehydrated models all point to the same action objects in memory — there is no duplication on the client side either.
Impact
Payload reduction of 90%+ for action/filter data (from N x M duplicated blobs to M unique blobs)
Zero breaking changes for frontend components — model.actions and model.filters are still accessible as before
Backend-only response transformation, no changes to the model computation logic
Changes
Backend (main.py):
After building the final model list, extract unique actions and filters into top-level dicts
Replace per-model actions/filters arrays with action_ids/filter_ids string arrays
Frontend (apis/index.ts):
After receiving the response, rehydrate action_ids/filter_ids back to full objects using the top-level dicts
Gracefully handles responses without the new fields (backwards compatible)
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.