Merge pull request #721 from zabirauf/u/zabirauf/keep-alive

Added support for setting the new KeepAlive property to be sent to Ollama
This commit is contained in:
Timothy Jaeryang Baek 2024-02-13 01:53:27 -08:00 committed by GitHub
commit 26e656228c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 3 deletions

View file

@ -7,6 +7,8 @@
// Advanced // Advanced
let requestFormat = ''; let requestFormat = '';
let keepAlive = null;
let options = { let options = {
// Advanced // Advanced
seed: 0, seed: 0,
@ -38,6 +40,7 @@
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}'); let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
requestFormat = settings.requestFormat ?? ''; requestFormat = settings.requestFormat ?? '';
keepAlive = settings.keepAlive ?? null;
options.seed = settings.seed ?? 0; options.seed = settings.seed ?? 0;
options.temperature = settings.temperature ?? ''; options.temperature = settings.temperature ?? '';
@ -57,6 +60,37 @@
<AdvancedParams bind:options /> <AdvancedParams bind:options />
<hr class=" dark:border-gray-700" /> <hr class=" dark:border-gray-700" />
<div class=" py-1 w-full justify-between">
<div class="flex w-full justify-between">
<div class=" self-center text-xs font-medium">Keep Alive</div>
<button
class="p-1 px-3 text-xs flex rounded transition"
type="button"
on:click={() => {
keepAlive = keepAlive === null ? '5m' : null;
}}
>
{#if keepAlive === null}
<span class="ml-2 self-center"> Default </span>
{:else}
<span class="ml-2 self-center"> Custom </span>
{/if}
</button>
</div>
{#if keepAlive !== null}
<div class="flex mt-1 space-x-2">
<input
class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
type="text"
placeholder={`e.g.) "30s","10m". Valid time units are "s", "m", "h".`}
bind:value={keepAlive}
/>
</div>
{/if}
</div>
<div> <div>
<div class=" py-1 flex w-full justify-between"> <div class=" py-1 flex w-full justify-between">
<div class=" self-center text-sm font-medium">Request Mode</div> <div class=" self-center text-sm font-medium">Request Mode</div>
@ -106,7 +140,8 @@
tfs_z: options.tfs_z !== '' ? options.tfs_z : undefined, tfs_z: options.tfs_z !== '' ? options.tfs_z : undefined,
num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined, num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined,
num_predict: options.num_predict !== '' ? options.num_predict : undefined num_predict: options.num_predict !== '' ? options.num_predict : undefined
} },
keepAlive: keepAlive ? keepAlive : undefined
}); });
dispatch('save'); dispatch('save');

View file

@ -358,7 +358,8 @@
options: { options: {
...($settings.options ?? {}) ...($settings.options ?? {})
}, },
format: $settings.requestFormat ?? undefined format: $settings.requestFormat ?? undefined,
keep_alive: $settings.keepAlive ?? undefined
}); });
if (res && res.ok) { if (res && res.ok) {

View file

@ -372,7 +372,8 @@
options: { options: {
...($settings.options ?? {}) ...($settings.options ?? {})
}, },
format: $settings.requestFormat ?? undefined format: $settings.requestFormat ?? undefined,
keep_alive: $settings.keepAlive ?? undefined
}); });
if (res && res.ok) { if (res && res.ok) {