mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-30 17:05:16 -05:00
perf: show the Admin Settings > Models list sooner (#34873)
The Models tab in Admin Settings loaded the models config, the workspace models and the model list one after another, then loaded the provider model list, and after showing the list loaded the model list again. Every one of those waits costs a network round trip, so admins on a remote instance waited noticeably longer than needed. The first three now load together and the model list is only loaded once. The provider model list still loads after the model list, so the provider is still asked only once per visit. <table> <tr><th>Time until the list shows, provider answering in 500 ms, median of 7</th><th>Before</th><th>After</th></tr> <tr><td>no added latency (localhost)</td><td>619 ms</td><td>620 ms</td></tr> <tr><td>40 ms latency</td><td>730 ms</td><td>654 ms</td></tr> <tr><td>100 ms latency</td><td>911 ms</td><td>710 ms</td></tr> </table> Fixes #34872
This commit is contained in:
1 parent
2065ec9a80
commit
d59de004bb
1 file changed
+10
-9
@@ -280,25 +280,28 @@
|
||||
const init = async () => {
|
||||
models = null;
|
||||
|
||||
modelsConfig = await getModelsConfig(localStorage.token);
|
||||
[modelsConfig, savedModels, allModels] = await Promise.all([
|
||||
getModelsConfig(localStorage.token),
|
||||
getAllModels(localStorage.token),
|
||||
getModels(localStorage.token)
|
||||
]);
|
||||
_models.set(allModels);
|
||||
|
||||
modelOrderList = modelsConfig?.MODEL_ORDER_LIST ?? [];
|
||||
defaultModelIds = (modelsConfig?.DEFAULT_MODELS ?? '').split(',').filter((id) => id);
|
||||
defaultPinnedModelIds = (modelsConfig?.DEFAULT_PINNED_MODELS ?? '')
|
||||
.split(',')
|
||||
.filter((id) => id);
|
||||
|
||||
savedModels = (await getAllModels(localStorage.token)).filter(
|
||||
(model: ModelListItem) => !model.id.startsWith('agent:')
|
||||
);
|
||||
savedModels = savedModels.filter((model: ModelListItem) => !model.id.startsWith('agent:'));
|
||||
tags = [...new Set(savedModels.flatMap(modelTags))].sort();
|
||||
if (selectedTag && !tags.includes(selectedTag)) {
|
||||
selectedTag = '';
|
||||
}
|
||||
|
||||
allModels = (await getModels(localStorage.token)).filter(
|
||||
(model: ModelListItem) => !isMachine(model.owned_by)
|
||||
);
|
||||
allModels = allModels.filter((model: ModelListItem) => !isMachine(model.owned_by));
|
||||
|
||||
// run after /api/models to reuse its cached provider response
|
||||
const providerModels = await getModels(localStorage.token, true);
|
||||
const allModelIds = new Set<string>(allModels.map((model: ModelListItem) => model.id));
|
||||
allModels = [
|
||||
@@ -335,8 +338,6 @@
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
];
|
||||
modelOrderDirty = false;
|
||||
|
||||
_models.set(await getModels(localStorage.token));
|
||||
};
|
||||
|
||||
const saveModelOrder = async (orderedModelIds: string[]) => {
|
||||
|
||||
Reference in new issue
Block a user