diff --git a/src/lib/apis/ollama/index.ts b/src/lib/apis/ollama/index.ts index 9964e227..341871ee 100644 --- a/src/lib/apis/ollama/index.ts +++ b/src/lib/apis/ollama/index.ts @@ -32,7 +32,7 @@ export const getOllamaVersion = async ( throw error; } - return res?.version ?? '0'; + return res?.version ?? ''; }; export const getOllamaModels = async ( diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 4baf6c91..c86cc77f 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -9,10 +9,11 @@ } from '$lib/constants'; import toast from 'svelte-french-toast'; import { onMount } from 'svelte'; - import { config, info, models, settings, user } from '$lib/stores'; + import { config, models, settings, user } from '$lib/stores'; import { splitStream, getGravatarURL } from '$lib/utils'; import Advanced from './Settings/Advanced.svelte'; import { stringify } from 'postcss'; + import { getOllamaVersion } from '$lib/apis/ollama'; export let show = false; @@ -79,6 +80,9 @@ let authType = 'Basic'; let authContent = ''; + // About + let ollamaVersion = ''; + const checkOllamaConnection = async () => { if (API_BASE_URL === '') { API_BASE_URL = OLLAMA_API_BASE_URL; @@ -553,7 +557,7 @@ return models; }; - onMount(() => { + onMount(async () => { let settings = JSON.parse(localStorage.getItem('settings') ?? '{}'); console.log(settings); @@ -586,6 +590,13 @@ authType = settings.authHeader.split(' ')[0]; authContent = settings.authHeader.split(' ')[1]; } + + ollamaVersion = await getOllamaVersion( + API_BASE_URL ?? OLLAMA_API_BASE_URL, + localStorage.token + ).catch((error) => { + return ''; + }); }); @@ -1607,7 +1618,7 @@
Ollama Version
- {$info?.ollama?.version ?? 'N/A'} + {ollamaVersion ?? 'N/A'}
diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 9962b4ac..342e6494 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -1,7 +1,6 @@ import { writable } from 'svelte/store'; // Backend -export const info = writable({}); export const config = writable(undefined); export const user = writable(undefined); diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 5bcc6c1a..9353d7f3 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -100,3 +100,13 @@ export const copyToClipboard = (text) => { } ); }; + +export const checkVersion = (required, current) => { + return ( + current.localeCompare(required, undefined, { + numeric: true, + sensitivity: 'case', + caseFirst: 'upper' + }) < 0 + ); +}; diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index e91a776d..27e2af61 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -1,24 +1,31 @@ {#if loaded} @@ -121,7 +122,7 @@ - {:else if ($info?.ollama?.version ?? '0').localeCompare( REQUIRED_OLLAMA_VERSION, undefined, { numeric: true, sensitivity: 'case', caseFirst: 'upper' } ) < 0} + {:else if checkVersion(REQUIRED_OLLAMA_VERSION, ollamaVersion ?? '0')}