feat: unified /models endpoint

This commit is contained in:
Timothy J. Baek
2024-05-24 01:40:48 -07:00
parent 4d57e08b38
commit 110ed67468
16 changed files with 166 additions and 170 deletions

View File

@@ -9,7 +9,6 @@
import { getAllModels as _getAllModels } from '$lib/utils';
import { getOllamaVersion } from '$lib/apis/ollama';
import { getModels } from '$lib/apis/models';
import { getPrompts } from '$lib/apis/prompts';
import { getDocs } from '$lib/apis/documents';
@@ -50,21 +49,6 @@
return _getAllModels(localStorage.token);
};
const setOllamaVersion = async (version: string = '') => {
if (version === '') {
version = await getOllamaVersion(localStorage.token).catch((error) => {
return '';
});
}
ollamaVersion = version;
console.log(ollamaVersion);
if (compareVersion(REQUIRED_OLLAMA_VERSION, ollamaVersion)) {
toast.error(`Ollama Version: ${ollamaVersion !== '' ? ollamaVersion : 'Not Detected'}`);
}
};
onMount(async () => {
if ($user === undefined) {
await goto('/auth');
@@ -93,9 +77,6 @@
(async () => {
models.set(await getAllModels());
})(),
(async () => {
modelfiles.set(await getModels(localStorage.token));
})(),
(async () => {
prompts.set(await getPrompts(localStorage.token));
})(),
@@ -107,11 +88,6 @@
})()
]);
modelfiles.subscribe(async () => {
// should fetch models
models.set(await getAllModels());
});
document.addEventListener('keydown', function (event) {
const isCtrlPressed = event.ctrlKey || event.metaKey; // metaKey is for Cmd key on Mac
// Check if the Shift key is pressed

View File

@@ -39,10 +39,10 @@
class="flex scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-xl bg-transparent/10 p-1"
>
<a
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/modelfiles')
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/models')
? 'bg-gray-50 dark:bg-gray-850'
: ''} transition"
href="/workspace/modelfiles">{$i18n.t('Modelfiles')}</a
href="/workspace/models">{$i18n.t('Models')}</a
>
<a

View File

@@ -3,6 +3,6 @@
import { onMount } from 'svelte';
onMount(() => {
goto('/workspace/modelfiles');
goto('/workspace/models');
});
</script>

View File

@@ -1,5 +0,0 @@
<script>
import Modelfiles from '$lib/components/workspace/Modelfiles.svelte';
</script>
<Modelfiles />

View File

@@ -0,0 +1,5 @@
<script>
import Models from '$lib/components/workspace/Models.svelte';
</script>
<Models />