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
let requestFormat = '';
let keepAlive = null;
let options = {
// Advanced
seed: 0,
@ -38,6 +40,7 @@
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
requestFormat = settings.requestFormat ?? '';
keepAlive = settings.keepAlive ?? null;
options.seed = settings.seed ?? 0;
options.temperature = settings.temperature ?? '';
@ -57,6 +60,37 @@
<AdvancedParams bind:options />
<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 class=" py-1 flex w-full justify-between">
<div class=" self-center text-sm font-medium">Request Mode</div>
@ -106,7 +140,8 @@
tfs_z: options.tfs_z !== '' ? options.tfs_z : undefined,
num_ctx: options.num_ctx !== '' ? options.num_ctx : undefined,
num_predict: options.num_predict !== '' ? options.num_predict : undefined
}
},
keepAlive: keepAlive ? keepAlive : undefined
});
dispatch('save');

View file

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

View file

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