Skip to content

Commit

Permalink
chore: update types for OllamaOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaclen committed Sep 21, 2024
1 parent d359195 commit 72559ce
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 37 deletions.
64 changes: 33 additions & 31 deletions src/lib/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
14 changes: 9 additions & 5 deletions src/routes/sessions/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
let shouldFocusTextarea = false;
let userScrolledUp = false;
const ollamaOptions: Writable<OllamaOptions> = writable({});
const ollamaOptions: Writable<Partial<OllamaOptions>> = writable({});
const shouldConfirmDeletion = writable(false);
$: session = loadSession(data.id);
Expand Down Expand Up @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion src/routes/sessions/[id]/Controls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 72559ce

Please sign in to comment.