mirror of
https://github.com/open-webui/open-webui
synced 2025-02-22 21:32:32 +00:00
refac
This commit is contained in:
parent
431e97b03a
commit
0bec9122c1
@ -126,7 +126,12 @@
|
||||
toast.success($i18n.t('Function deleted successfully'));
|
||||
|
||||
functions.set(await getFunctions(localStorage.token));
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -147,7 +152,12 @@
|
||||
}
|
||||
|
||||
functions.set(await getFunctions(localStorage.token));
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -360,7 +370,11 @@
|
||||
on:change={async (e) => {
|
||||
toggleFunctionById(localStorage.token, func.id);
|
||||
models.set(
|
||||
await getModels(localStorage.token, $settings?.directConnections ?? null)
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions &&
|
||||
($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
@ -498,7 +512,12 @@
|
||||
id={selectedFunction?.id ?? null}
|
||||
on:save={async () => {
|
||||
await tick();
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
@ -519,7 +538,12 @@
|
||||
|
||||
toast.success($i18n.t('Functions imported successfully'));
|
||||
functions.set(await getFunctions(localStorage.token));
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
reader.readAsText(importFiles[0]);
|
||||
|
@ -51,11 +51,12 @@
|
||||
if (TTS_ENGINE === '') {
|
||||
models = [];
|
||||
} else {
|
||||
const res = await _getModels(localStorage.token, $settings?.directConnections ?? null).catch(
|
||||
(e) => {
|
||||
toast.error(`${e}`);
|
||||
}
|
||||
);
|
||||
const res = await _getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
).catch((e) => {
|
||||
toast.error(`${e}`);
|
||||
});
|
||||
|
||||
if (res) {
|
||||
console.log(res);
|
||||
|
@ -9,7 +9,7 @@
|
||||
import { getModels as _getModels } from '$lib/apis';
|
||||
import { getDirectConnectionsConfig, setDirectConnectionsConfig } from '$lib/apis/configs';
|
||||
|
||||
import { models, settings, user } from '$lib/stores';
|
||||
import { config, models, settings, user } from '$lib/stores';
|
||||
|
||||
import Switch from '$lib/components/common/Switch.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
@ -23,7 +23,10 @@
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
const getModels = async () => {
|
||||
const models = await _getModels(localStorage.token, $settings?.directConnections ?? null);
|
||||
const models = await _getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
);
|
||||
return models;
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,12 @@
|
||||
|
||||
if (config) {
|
||||
toast.success('Settings saved successfully');
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -36,7 +41,12 @@
|
||||
config.EVALUATION_ARENA_MODELS = [...config.EVALUATION_ARENA_MODELS];
|
||||
|
||||
await submitHandler();
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const editModelHandler = async (model, modelIdx) => {
|
||||
@ -44,7 +54,12 @@
|
||||
config.EVALUATION_ARENA_MODELS = [...config.EVALUATION_ARENA_MODELS];
|
||||
|
||||
await submitHandler();
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const deleteModelHandler = async (modelIdx) => {
|
||||
@ -53,7 +68,12 @@
|
||||
);
|
||||
|
||||
await submitHandler();
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
|
@ -111,7 +111,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
_models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
_models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
await init();
|
||||
};
|
||||
|
||||
@ -133,7 +138,12 @@
|
||||
}
|
||||
|
||||
// await init();
|
||||
_models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
_models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
@ -331,7 +341,11 @@
|
||||
}
|
||||
|
||||
await _models.set(
|
||||
await getModels(localStorage.token, $settings?.directConnections ?? null)
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions &&
|
||||
($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
init();
|
||||
};
|
||||
|
@ -235,7 +235,12 @@
|
||||
})
|
||||
);
|
||||
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
toast.error($i18n.t('Download canceled'));
|
||||
}
|
||||
@ -394,7 +399,12 @@
|
||||
modelTransferring = false;
|
||||
uploadProgress = null;
|
||||
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const deleteModelHandler = async () => {
|
||||
@ -407,7 +417,12 @@
|
||||
}
|
||||
|
||||
deleteModelTag = '';
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const cancelModelPullHandler = async (model: string) => {
|
||||
@ -506,7 +521,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
|
||||
createModelLoading = false;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { models, settings } from '$lib/stores';
|
||||
import { config, models, settings } from '$lib/stores';
|
||||
import { getContext, onMount, tick } from 'svelte';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import type { i18n as i18nType } from 'i18next';
|
||||
@ -63,7 +63,12 @@
|
||||
if (res) {
|
||||
toast.success($i18n.t('Valves updated successfully'));
|
||||
setPipelines();
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
saveHandler();
|
||||
}
|
||||
} else {
|
||||
@ -125,7 +130,12 @@
|
||||
if (res) {
|
||||
toast.success($i18n.t('Pipeline downloaded successfully'));
|
||||
setPipelines();
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
downloading = false;
|
||||
@ -150,7 +160,12 @@
|
||||
if (res) {
|
||||
toast.success($i18n.t('Pipeline downloaded successfully'));
|
||||
setPipelines();
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
toast.error($i18n.t('No file selected'));
|
||||
@ -179,7 +194,12 @@
|
||||
if (res) {
|
||||
toast.success($i18n.t('Pipeline deleted successfully'));
|
||||
setPipelines();
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -18,7 +18,8 @@
|
||||
models,
|
||||
mobile,
|
||||
temporaryChatEnabled,
|
||||
settings
|
||||
settings,
|
||||
config
|
||||
} from '$lib/stores';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { capitalizeFirstLetter, sanitizeResponseContent, splitStream } from '$lib/utils';
|
||||
@ -193,7 +194,12 @@
|
||||
})
|
||||
);
|
||||
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
toast.error($i18n.t('Download canceled'));
|
||||
}
|
||||
|
@ -322,7 +322,10 @@
|
||||
};
|
||||
|
||||
const getModels = async () => {
|
||||
return await _getModels(localStorage.token, $settings?.directConnections ?? null);
|
||||
return await _getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
);
|
||||
};
|
||||
|
||||
let selectedTab = 'general';
|
||||
|
@ -68,7 +68,12 @@
|
||||
toast.success($i18n.t(`Deleted {{name}}`, { name: model.id }));
|
||||
}
|
||||
|
||||
await _models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
await _models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
models = await getWorkspaceModels(localStorage.token);
|
||||
};
|
||||
|
||||
@ -134,7 +139,12 @@
|
||||
);
|
||||
}
|
||||
|
||||
await _models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
await _models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
models = await getWorkspaceModels(localStorage.token);
|
||||
};
|
||||
|
||||
@ -372,7 +382,11 @@
|
||||
on:change={async (e) => {
|
||||
toggleModelById(localStorage.token, model.id);
|
||||
_models.set(
|
||||
await getModels(localStorage.token, $settings?.directConnections ?? null)
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions &&
|
||||
($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
@ -420,7 +434,11 @@
|
||||
}
|
||||
|
||||
await _models.set(
|
||||
await getModels(localStorage.token, $settings?.directConnections ?? null)
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions &&
|
||||
($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
models = await getWorkspaceModels(localStorage.token);
|
||||
};
|
||||
|
@ -93,7 +93,12 @@
|
||||
settings.set(localStorageSettings);
|
||||
}
|
||||
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
banners.set(await getBanners(localStorage.token));
|
||||
tools.set(await getTools(localStorage.token));
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
import { onMount, getContext } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import { functions, models, settings } from '$lib/stores';
|
||||
import { config, functions, models, settings } from '$lib/stores';
|
||||
import { createNewFunction, getFunctions } from '$lib/apis/functions';
|
||||
import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte';
|
||||
import { getModels } from '$lib/apis';
|
||||
@ -47,7 +47,12 @@
|
||||
if (res) {
|
||||
toast.success($i18n.t('Function created successfully'));
|
||||
functions.set(await getFunctions(localStorage.token));
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
|
||||
await goto('/admin/functions');
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { functions, models, settings } from '$lib/stores';
|
||||
import { config, functions, models, settings } from '$lib/stores';
|
||||
import { updateFunctionById, getFunctions, getFunctionById } from '$lib/apis/functions';
|
||||
|
||||
import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte';
|
||||
@ -48,7 +48,12 @@
|
||||
if (res) {
|
||||
toast.success($i18n.t('Function updated successfully'));
|
||||
functions.set(await getFunctions(localStorage.token));
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,13 +1,18 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { models, settings } from '$lib/stores';
|
||||
import { config, models, settings } from '$lib/stores';
|
||||
import { getModels } from '$lib/apis';
|
||||
import Models from '$lib/components/workspace/Models.svelte';
|
||||
|
||||
onMount(async () => {
|
||||
await Promise.all([
|
||||
(async () => {
|
||||
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
})()
|
||||
]);
|
||||
});
|
||||
|
@ -42,7 +42,12 @@
|
||||
});
|
||||
|
||||
if (res) {
|
||||
await models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
await models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
toast.success($i18n.t('Model created successfully!'));
|
||||
await goto('/workspace/models');
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
import { page } from '$app/stores';
|
||||
import { models } from '$lib/stores';
|
||||
import { config, models } from '$lib/stores';
|
||||
|
||||
import { getModelById, updateModelById } from '$lib/apis/models';
|
||||
|
||||
@ -34,7 +34,12 @@
|
||||
const res = await updateModelById(localStorage.token, modelInfo.id, modelInfo);
|
||||
|
||||
if (res) {
|
||||
await models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
await models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
toast.success($i18n.t('Model updated successfully'));
|
||||
await goto('/workspace/models');
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { settings, chatId, WEBUI_NAME, models } from '$lib/stores';
|
||||
import { settings, chatId, WEBUI_NAME, models, config } from '$lib/stores';
|
||||
import { convertMessagesToHistory, createMessagesList } from '$lib/utils';
|
||||
|
||||
import { getChatByShareId, cloneSharedChatById } from '$lib/apis/chats';
|
||||
@ -61,7 +61,12 @@
|
||||
//////////////////////////
|
||||
|
||||
const loadSharedChat = async () => {
|
||||
await models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
|
||||
await models.set(
|
||||
await getModels(
|
||||
localStorage.token,
|
||||
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
|
||||
)
|
||||
);
|
||||
await chatId.set($page.params.id);
|
||||
chat = await getChatByShareId(localStorage.token, $chatId).catch(async (error) => {
|
||||
await goto('/');
|
||||
|
Loading…
Reference in New Issue
Block a user