diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 48359f1f..342e6494 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -9,5 +9,6 @@ export const db = writable(undefined); export const chatId = writable(''); export const chats = writable([]); export const models = writable([]); +export const modelfiles = writable([]); export const settings = writable({}); export const showSettings = writable(false); diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 7ead5e40..e837741e 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -4,7 +4,17 @@ import { onMount, tick } from 'svelte'; import { goto } from '$app/navigation'; - import { config, user, showSettings, settings, models, db, chats, chatId } from '$lib/stores'; + import { + config, + user, + showSettings, + settings, + models, + db, + chats, + chatId, + modelfiles + } from '$lib/stores'; import SettingsModal from '$lib/components/chat/SettingsModal.svelte'; import Sidebar from '$lib/components/layout/Sidebar.svelte'; @@ -78,7 +88,7 @@ }; const getDB = async () => { - const _db = await openDB('Chats', 1, { + const DB = await openDB('Chats', 1, { upgrade(db) { const store = db.createObjectStore('chats', { keyPath: 'id', @@ -89,7 +99,7 @@ }); return { - db: _db, + db: DB, getChatById: async function (id) { return await this.db.get('chats', id); }, @@ -162,6 +172,14 @@ let _db = await getDB(); await db.set(_db); + await modelfiles.set( + JSON.parse(localStorage.getItem('modelfiles') ?? JSON.stringify($modelfiles)) + ); + + modelfiles.subscribe(async () => { + await models.set(await getModels()); + }); + await tick(); loaded = true; }); diff --git a/src/routes/(app)/modelfiles/+page.svelte b/src/routes/(app)/modelfiles/+page.svelte index 6229ec14..e8c24806 100644 --- a/src/routes/(app)/modelfiles/+page.svelte +++ b/src/routes/(app)/modelfiles/+page.svelte @@ -1,12 +1,19 @@ + +