wip: direct models

This commit is contained in:
Timothy Jaeryang Baek
2025-02-12 01:17:30 -08:00
parent 982b1fb7e2
commit 431e97b03a
20 changed files with 194 additions and 61 deletions
@@ -12,7 +12,14 @@
import { deleteModel, getOllamaVersion, pullModel } from '$lib/apis/ollama';
import { user, MODEL_DOWNLOAD_POOL, models, mobile, temporaryChatEnabled } from '$lib/stores';
import {
user,
MODEL_DOWNLOAD_POOL,
models,
mobile,
temporaryChatEnabled,
settings
} from '$lib/stores';
import { toast } from 'svelte-sonner';
import { capitalizeFirstLetter, sanitizeResponseContent, splitStream } from '$lib/utils';
import { getModels } from '$lib/apis';
@@ -186,7 +193,7 @@
})
);
models.set(await getModels(localStorage.token));
models.set(await getModels(localStorage.token, $settings?.directConnections ?? null));
} else {
toast.error($i18n.t('Download canceled'));
}
@@ -358,7 +365,24 @@
<!-- {JSON.stringify(item.info)} -->
{#if item.model.owned_by === 'openai'}
{#if item.model?.direct}
<Tooltip content={`${'Direct'}`}>
<div class="translate-y-[1px]">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="size-3"
>
<path
fill-rule="evenodd"
d="M2 2.75A.75.75 0 0 1 2.75 2C8.963 2 14 7.037 14 13.25a.75.75 0 0 1-1.5 0c0-5.385-4.365-9.75-9.75-9.75A.75.75 0 0 1 2 2.75Zm0 4.5a.75.75 0 0 1 .75-.75 6.75 6.75 0 0 1 6.75 6.75.75.75 0 0 1-1.5 0C8 10.35 5.65 8 2.75 8A.75.75 0 0 1 2 7.25ZM3.5 11a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z"
clip-rule="evenodd"
/>
</svg>
</div>
</Tooltip>
{:else if item.model.owned_by === 'openai'}
<Tooltip content={`${'External'}`}>
<div class="translate-y-[1px]">
<svg
@@ -58,14 +58,6 @@
});
};
const submitHandler = async () => {
await updateHandler();
await saveSettings({
directConnections: config
});
};
onMount(async () => {
config = $settings?.directConnections ?? {
OPENAI_API_BASE_URLS: [],
@@ -77,7 +69,12 @@
<AddConnectionModal direct bind:show={showConnectionModal} onSubmit={addConnectionHandler} />
<form class="flex flex-col h-full justify-between text-sm" on:submit|preventDefault={submitHandler}>
<form
class="flex flex-col h-full justify-between text-sm"
on:submit|preventDefault={() => {
updateHandler();
}}
>
<div class=" overflow-y-scroll scrollbar-hidden h-full">
{#if config !== null}
<div class="">
+3 -3
View File
@@ -322,7 +322,7 @@
};
const getModels = async () => {
return await _getModels(localStorage.token);
return await _getModels(localStorage.token, $settings?.directConnections ?? null);
};
let selectedTab = 'general';
@@ -654,8 +654,8 @@
/>
{:else if selectedTab === 'connections'}
<Connections
{saveSettings}
on:save={() => {
saveSettings={async (updated) => {
await saveSettings(updated);
toast.success($i18n.t('Settings saved successfully!'));
}}
/>