This commit is contained in:
Timothy Jaeryang Baek 2025-02-12 01:22:53 -08:00
parent 431e97b03a
commit 0bec9122c1
17 changed files with 211 additions and 47 deletions

View File

@ -126,7 +126,12 @@
toast.success($i18n.t('Function deleted successfully')); toast.success($i18n.t('Function deleted successfully'));
functions.set(await getFunctions(localStorage.token)); 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)); 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) => { on:change={async (e) => {
toggleFunctionById(localStorage.token, func.id); toggleFunctionById(localStorage.token, func.id);
models.set( 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} id={selectedFunction?.id ?? null}
on:save={async () => { on:save={async () => {
await tick(); 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')); toast.success($i18n.t('Functions imported successfully'));
functions.set(await getFunctions(localStorage.token)); 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]); reader.readAsText(importFiles[0]);

View File

@ -51,11 +51,12 @@
if (TTS_ENGINE === '') { if (TTS_ENGINE === '') {
models = []; models = [];
} else { } else {
const res = await _getModels(localStorage.token, $settings?.directConnections ?? null).catch( const res = await _getModels(
(e) => { localStorage.token,
toast.error(`${e}`); $config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
} ).catch((e) => {
); toast.error(`${e}`);
});
if (res) { if (res) {
console.log(res); console.log(res);

View File

@ -9,7 +9,7 @@
import { getModels as _getModels } from '$lib/apis'; import { getModels as _getModels } from '$lib/apis';
import { getDirectConnectionsConfig, setDirectConnectionsConfig } from '$lib/apis/configs'; 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 Switch from '$lib/components/common/Switch.svelte';
import Spinner from '$lib/components/common/Spinner.svelte'; import Spinner from '$lib/components/common/Spinner.svelte';
@ -23,7 +23,10 @@
const i18n = getContext('i18n'); const i18n = getContext('i18n');
const getModels = async () => { 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; return models;
}; };

View File

@ -27,7 +27,12 @@
if (config) { if (config) {
toast.success('Settings saved successfully'); 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]; config.EVALUATION_ARENA_MODELS = [...config.EVALUATION_ARENA_MODELS];
await submitHandler(); 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) => { const editModelHandler = async (model, modelIdx) => {
@ -44,7 +54,12 @@
config.EVALUATION_ARENA_MODELS = [...config.EVALUATION_ARENA_MODELS]; config.EVALUATION_ARENA_MODELS = [...config.EVALUATION_ARENA_MODELS];
await submitHandler(); 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) => { const deleteModelHandler = async (modelIdx) => {
@ -53,7 +68,12 @@
); );
await submitHandler(); 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 () => { onMount(async () => {

View File

@ -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(); await init();
}; };
@ -133,7 +138,12 @@
} }
// await init(); // 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 () => { onMount(async () => {
@ -331,7 +341,11 @@
} }
await _models.set( await _models.set(
await getModels(localStorage.token, $settings?.directConnections ?? null) await getModels(
localStorage.token,
$config?.features?.enable_direct_connetions &&
($settings?.directConnections ?? null)
)
); );
init(); init();
}; };

View File

@ -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 { } else {
toast.error($i18n.t('Download canceled')); toast.error($i18n.t('Download canceled'));
} }
@ -394,7 +399,12 @@
modelTransferring = false; modelTransferring = false;
uploadProgress = null; 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 () => { const deleteModelHandler = async () => {
@ -407,7 +417,12 @@
} }
deleteModelTag = ''; 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) => { 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; createModelLoading = false;

View File

@ -2,7 +2,7 @@
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { toast } from 'svelte-sonner'; 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 { getContext, onMount, tick } from 'svelte';
import type { Writable } from 'svelte/store'; import type { Writable } from 'svelte/store';
import type { i18n as i18nType } from 'i18next'; import type { i18n as i18nType } from 'i18next';
@ -63,7 +63,12 @@
if (res) { if (res) {
toast.success($i18n.t('Valves updated successfully')); toast.success($i18n.t('Valves updated successfully'));
setPipelines(); 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(); saveHandler();
} }
} else { } else {
@ -125,7 +130,12 @@
if (res) { if (res) {
toast.success($i18n.t('Pipeline downloaded successfully')); toast.success($i18n.t('Pipeline downloaded successfully'));
setPipelines(); 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; downloading = false;
@ -150,7 +160,12 @@
if (res) { if (res) {
toast.success($i18n.t('Pipeline downloaded successfully')); toast.success($i18n.t('Pipeline downloaded successfully'));
setPipelines(); 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 { } else {
toast.error($i18n.t('No file selected')); toast.error($i18n.t('No file selected'));
@ -179,7 +194,12 @@
if (res) { if (res) {
toast.success($i18n.t('Pipeline deleted successfully')); toast.success($i18n.t('Pipeline deleted successfully'));
setPipelines(); setPipelines();
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null)); models.set(
await getModels(
localStorage.token,
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
)
);
} }
}; };

View File

@ -18,7 +18,8 @@
models, models,
mobile, mobile,
temporaryChatEnabled, temporaryChatEnabled,
settings settings,
config
} from '$lib/stores'; } from '$lib/stores';
import { toast } from 'svelte-sonner'; import { toast } from 'svelte-sonner';
import { capitalizeFirstLetter, sanitizeResponseContent, splitStream } from '$lib/utils'; 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 { } else {
toast.error($i18n.t('Download canceled')); toast.error($i18n.t('Download canceled'));
} }

View File

@ -322,7 +322,10 @@
}; };
const getModels = async () => { 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'; let selectedTab = 'general';

View File

@ -68,7 +68,12 @@
toast.success($i18n.t(`Deleted {{name}}`, { name: model.id })); 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); 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); models = await getWorkspaceModels(localStorage.token);
}; };
@ -372,7 +382,11 @@
on:change={async (e) => { on:change={async (e) => {
toggleModelById(localStorage.token, model.id); toggleModelById(localStorage.token, model.id);
_models.set( _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 _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); models = await getWorkspaceModels(localStorage.token);
}; };

View File

@ -93,7 +93,12 @@
settings.set(localStorageSettings); 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)); banners.set(await getBanners(localStorage.token));
tools.set(await getTools(localStorage.token)); tools.set(await getTools(localStorage.token));

View File

@ -3,7 +3,7 @@
import { onMount, getContext } from 'svelte'; import { onMount, getContext } from 'svelte';
import { goto } from '$app/navigation'; 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 { createNewFunction, getFunctions } from '$lib/apis/functions';
import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte'; import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte';
import { getModels } from '$lib/apis'; import { getModels } from '$lib/apis';
@ -47,7 +47,12 @@
if (res) { if (res) {
toast.success($i18n.t('Function created successfully')); toast.success($i18n.t('Function created successfully'));
functions.set(await getFunctions(localStorage.token)); 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'); await goto('/admin/functions');
} }

View File

@ -4,7 +4,7 @@
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { page } from '$app/stores'; 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 { updateFunctionById, getFunctions, getFunctionById } from '$lib/apis/functions';
import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte'; import FunctionEditor from '$lib/components/admin/Functions/FunctionEditor.svelte';
@ -48,7 +48,12 @@
if (res) { if (res) {
toast.success($i18n.t('Function updated successfully')); toast.success($i18n.t('Function updated successfully'));
functions.set(await getFunctions(localStorage.token)); 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)
)
);
} }
}; };

View File

@ -1,13 +1,18 @@
<script> <script>
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { models, settings } from '$lib/stores'; import { config, models, settings } from '$lib/stores';
import { getModels } from '$lib/apis'; import { getModels } from '$lib/apis';
import Models from '$lib/components/workspace/Models.svelte'; import Models from '$lib/components/workspace/Models.svelte';
onMount(async () => { onMount(async () => {
await Promise.all([ await Promise.all([
(async () => { (async () => {
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null)); models.set(
await getModels(
localStorage.token,
$config?.features?.enable_direct_connetions && ($settings?.directConnections ?? null)
)
);
})() })()
]); ]);
}); });

View File

@ -42,7 +42,12 @@
}); });
if (res) { 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!')); toast.success($i18n.t('Model created successfully!'));
await goto('/workspace/models'); await goto('/workspace/models');
} }

View File

@ -6,7 +6,7 @@
const i18n = getContext('i18n'); const i18n = getContext('i18n');
import { page } from '$app/stores'; import { page } from '$app/stores';
import { models } from '$lib/stores'; import { config, models } from '$lib/stores';
import { getModelById, updateModelById } from '$lib/apis/models'; import { getModelById, updateModelById } from '$lib/apis/models';
@ -34,7 +34,12 @@
const res = await updateModelById(localStorage.token, modelInfo.id, modelInfo); const res = await updateModelById(localStorage.token, modelInfo.id, modelInfo);
if (res) { 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')); toast.success($i18n.t('Model updated successfully'));
await goto('/workspace/models'); await goto('/workspace/models');
} }

View File

@ -5,7 +5,7 @@
import dayjs from 'dayjs'; 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 { convertMessagesToHistory, createMessagesList } from '$lib/utils';
import { getChatByShareId, cloneSharedChatById } from '$lib/apis/chats'; import { getChatByShareId, cloneSharedChatById } from '$lib/apis/chats';
@ -61,7 +61,12 @@
////////////////////////// //////////////////////////
const loadSharedChat = async () => { 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); await chatId.set($page.params.id);
chat = await getChatByShareId(localStorage.token, $chatId).catch(async (error) => { chat = await getChatByShareId(localStorage.token, $chatId).catch(async (error) => {
await goto('/'); await goto('/');