From 72559ce4185edaf78642baa9ddd31767552ea567 Mon Sep 17 00:00:00 2001 From: Fernando Maclen Date: Sat, 21 Sep 2024 12:09:45 -0400 Subject: [PATCH] chore: update types for OllamaOptions REF https://github.com/ollama/ollama-js/issues/145 --- src/lib/ollama.ts | 64 ++++++++++++------------ src/routes/sessions/[id]/+page.svelte | 14 ++++-- src/routes/sessions/[id]/Controls.svelte | 2 +- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/src/lib/ollama.ts b/src/lib/ollama.ts index 711b73d9..8609a2e5 100644 --- a/src/lib/ollama.ts +++ b/src/lib/ollama.ts @@ -12,37 +12,39 @@ import { get } from 'svelte/store'; import { settingsStore } from '$lib/localStorage'; export interface OllamaOptions { - numa?: boolean; - num_ctx?: number; - num_batch?: number; - num_gpu?: number; - main_gpu?: number; - low_vram?: boolean; - f16_kv?: boolean; - logits_all?: boolean; - vocab_only?: boolean; - use_mmap?: boolean; - use_mlock?: boolean; - embedding_only?: boolean; - num_thread?: number; - num_keep?: number; - seed?: number; - num_predict?: number; - top_k?: number; - top_p?: number; - min_p?: number; // Prop is supported but the type is missing in the Ollama types - tfs_z?: number; - typical_p?: number; - repeat_last_n?: number; - temperature?: number; - repeat_penalty?: number; - presence_penalty?: number; - frequency_penalty?: number; - mirostat?: number; - mirostat_tau?: number; - mirostat_eta?: number; - penalize_newline?: boolean; - stop?: string[]; // Should be an array of strings + numa: boolean + num_ctx: number + num_batch: number + num_gpu: number + main_gpu: number + low_vram: boolean + f16_kv: boolean + logits_all: boolean // REF https://github.com/ollama/ollama-js/issues/145 + vocab_only: boolean + use_mmap: boolean + use_mlock: boolean + embedding_only: boolean // REF https://github.com/ollama/ollama-js/issues/145 + num_thread: number + + // Runtime options + num_keep: number + seed: number + num_predict: number + top_k: number + top_p: number + min_p: number // REF https://github.com/ollama/ollama-js/issues/145 + tfs_z: number + typical_p: number + repeat_last_n: number + temperature: number + repeat_penalty: number + presence_penalty: number + frequency_penalty: number + mirostat: number + mirostat_tau: number + mirostat_eta: number + penalize_newline: boolean + stop: string[] } function getServerFromSettings() { diff --git a/src/routes/sessions/[id]/+page.svelte b/src/routes/sessions/[id]/+page.svelte index cdbde1d7..4ebbebd6 100644 --- a/src/routes/sessions/[id]/+page.svelte +++ b/src/routes/sessions/[id]/+page.svelte @@ -55,7 +55,7 @@ let shouldFocusTextarea = false; let userScrolledUp = false; - const ollamaOptions: Writable = writable({}); + const ollamaOptions: Writable> = writable({}); const shouldConfirmDeletion = writable(false); $: session = loadSession(data.id); @@ -141,10 +141,14 @@ completion = ''; try { - await ollamaChat({ ...payload, options: $ollamaOptions }, abortController.signal, async (chunk) => { - completion += chunk; - await scrollToBottom(); - }); + await ollamaChat( + { ...payload, options: $ollamaOptions }, + abortController.signal, + async (chunk) => { + completion += chunk; + await scrollToBottom(); + } + ); // After the completion save the session const message: Message = { role: 'assistant', content: completion }; diff --git a/src/routes/sessions/[id]/Controls.svelte b/src/routes/sessions/[id]/Controls.svelte index d9adf631..50e6d5d9 100644 --- a/src/routes/sessions/[id]/Controls.svelte +++ b/src/routes/sessions/[id]/Controls.svelte @@ -16,7 +16,7 @@ const DEFAULT_REPEAT_PENALTY = '1.1'; const DEFAULT_TEMPERATURE = '0.8'; const DEFAULT_SEED = '0'; - const DEFAULT_STOP = '\\n'; + const DEFAULT_STOP = 'AI assistant:'; const DEFAULT_TFS_Z = '1'; const DEFAULT_NUM_PREDICT = '128'; const DEFAULT_TOP_K = '40';