From fd26e5635d2d318ed7ac4589ab902e9ff3f0bd2a Mon Sep 17 00:00:00 2001 From: Zhuoran Date: Tue, 20 Aug 2024 08:44:09 +0800 Subject: [PATCH] Fix type errors. --- src/lib/apis/index.ts | 1 + src/lib/apis/ollama/index.ts | 2 +- .../components/admin/Settings/Models.svelte | 2 +- .../chat/ModelSelector/Selector.svelte | 5 +++-- .../components/chat/Settings/General.svelte | 4 ++-- .../components/chat/Settings/Models.svelte | 2 +- src/lib/stores/index.ts | 19 +++++++++++++++++++ 7 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index c4778cadb..2343d1c09 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -913,6 +913,7 @@ export interface ModelConfig { export interface ModelMeta { description?: string; capabilities?: object; + profile_image_url?: string; } export interface ModelParams {} diff --git a/src/lib/apis/ollama/index.ts b/src/lib/apis/ollama/index.ts index c4c449156..d4e994312 100644 --- a/src/lib/apis/ollama/index.ts +++ b/src/lib/apis/ollama/index.ts @@ -396,7 +396,7 @@ export const deleteModel = async (token: string, tagName: string, urlIdx: string return res; }; -export const pullModel = async (token: string, tagName: string, urlIdx: string | null = null) => { +export const pullModel = async (token: string, tagName: string, urlIdx: number | null = null) => { let error = null; const controller = new AbortController(); diff --git a/src/lib/components/admin/Settings/Models.svelte b/src/lib/components/admin/Settings/Models.svelte index 5e975ec0a..f6106fec4 100644 --- a/src/lib/components/admin/Settings/Models.svelte +++ b/src/lib/components/admin/Settings/Models.svelte @@ -37,7 +37,7 @@ let ollamaEnabled = null; let OLLAMA_URLS = []; - let selectedOllamaUrlIdx: string | null = null; + let selectedOllamaUrlIdx: number | null = null; let updateModelId = null; let updateProgress = null; diff --git a/src/lib/components/chat/ModelSelector/Selector.svelte b/src/lib/components/chat/ModelSelector/Selector.svelte index 96a963a26..409f364e6 100644 --- a/src/lib/components/chat/ModelSelector/Selector.svelte +++ b/src/lib/components/chat/ModelSelector/Selector.svelte @@ -12,7 +12,7 @@ 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, Model } from '$lib/stores'; import { toast } from 'svelte-sonner'; import { capitalizeFirstLetter, sanitizeResponseContent, splitStream } from '$lib/utils'; import { getModels } from '$lib/apis'; @@ -35,9 +35,10 @@ export let items: { label: string; value: string; + model: Model; // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; - } = []; + }[] = []; export let className = 'w-[32rem]'; diff --git a/src/lib/components/chat/Settings/General.svelte b/src/lib/components/chat/Settings/General.svelte index 427bc4a7c..6e4410acf 100644 --- a/src/lib/components/chat/Settings/General.svelte +++ b/src/lib/components/chat/Settings/General.svelte @@ -17,7 +17,7 @@ let themes = ['dark', 'light', 'rose-pine dark', 'rose-pine-dawn light', 'oled-dark']; let selectedTheme = 'system'; - let languages = []; + let languages: Awaited> = []; let lang = $i18n.language; let notificationEnabled = false; let system = ''; @@ -41,7 +41,7 @@ // Advanced let requestFormat = ''; - let keepAlive = null; + let keepAlive: string | null = null; let params = { // Advanced diff --git a/src/lib/components/chat/Settings/Models.svelte b/src/lib/components/chat/Settings/Models.svelte index ee825dfa7..3a81effe3 100644 --- a/src/lib/components/chat/Settings/Models.svelte +++ b/src/lib/components/chat/Settings/Models.svelte @@ -31,7 +31,7 @@ let ollamaEnabled = null; let OLLAMA_URLS = []; - let selectedOllamaUrlIdx: string | null = null; + let selectedOllamaUrlIdx: number | null = null; let updateModelId = null; let updateProgress = null; diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index 30c467640..1b4544170 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -52,20 +52,39 @@ type BaseModel = { id: string; name: string; info?: ModelConfig; + owned_by: 'ollama' | 'openai'; }; export interface OpenAIModel extends BaseModel { + owned_by: 'openai'; external: boolean; source?: string; } export interface OllamaModel extends BaseModel { + owned_by: 'ollama'; details: OllamaModelDetails; size: number; description: string; model: string; modified_at: string; digest: string; + ollama?: { + name?: string; + model?: string; + modified_at: string; + size?: number; + digest?: string; + details?: { + parent_model?: string; + format?: string; + family?: string; + families?: string[]; + parameter_size?: string; + quantization_level?: string; + }; + urls?: number[]; + }; } type OllamaModelDetails = {