forked from open-webui/open-webui
Added Keep alive setting
This commit is contained in:
parent
a8a0ebf3aa
commit
7053f2f67d
5 changed files with 26 additions and 7 deletions
|
@ -167,7 +167,7 @@ export const generateTitle = async (token: string = '', model: string, prompt: s
|
||||||
return res?.response ?? 'New Chat';
|
return res?.response ?? 'New Chat';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const generatePrompt = async (token: string = '', model: string, conversation: string) => {
|
export const generatePrompt = async (token: string = '', model: string, conversation: string, body: object = {}) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
if (conversation === '') {
|
if (conversation === '') {
|
||||||
|
@ -188,7 +188,8 @@ export const generatePrompt = async (token: string = '', model: string, conversa
|
||||||
As USER in the conversation above, your task is to continue the conversation. Remember, Your responses should be crafted as if you're a human conversing in a natural, realistic manner, keeping in mind the context and flow of the dialogue. Please generate a fitting response to the last message in the conversation, or if there is no existing conversation, initiate one as a normal person would.
|
As USER in the conversation above, your task is to continue the conversation. Remember, Your responses should be crafted as if you're a human conversing in a natural, realistic manner, keeping in mind the context and flow of the dialogue. Please generate a fitting response to the last message in the conversation, or if there is no existing conversation, initiate one as a normal person would.
|
||||||
|
|
||||||
Response:
|
Response:
|
||||||
`
|
`,
|
||||||
|
...body
|
||||||
})
|
})
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { generatePrompt } from '$lib/apis/ollama';
|
import { generatePrompt } from '$lib/apis/ollama';
|
||||||
import { models } from '$lib/stores';
|
import { models, settings } from '$lib/stores';
|
||||||
import { splitStream } from '$lib/utils';
|
import { splitStream } from '$lib/utils';
|
||||||
import { tick } from 'svelte';
|
import { tick } from 'svelte';
|
||||||
import toast from 'svelte-french-toast';
|
import toast from 'svelte-french-toast';
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
return `${a}### ${message.role.toUpperCase()}\n${message.content}\n\n`;
|
||||||
}, '');
|
}, '');
|
||||||
|
|
||||||
const res = await generatePrompt(localStorage.token, model.name, convoText);
|
const res = await generatePrompt(localStorage.token, model.name, convoText, { keep_alive: $settings.keepAlive ?? undefined });
|
||||||
|
|
||||||
if (res && res.ok) {
|
if (res && res.ok) {
|
||||||
const reader = res.body
|
const reader = res.body
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
// Advanced
|
// Advanced
|
||||||
let requestFormat = '';
|
let requestFormat = '';
|
||||||
|
let keepAlive = '';
|
||||||
let options = {
|
let options = {
|
||||||
// Advanced
|
// Advanced
|
||||||
seed: 0,
|
seed: 0,
|
||||||
|
@ -38,6 +39,7 @@
|
||||||
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
|
let settings = JSON.parse(localStorage.getItem('settings') ?? '{}');
|
||||||
|
|
||||||
requestFormat = settings.requestFormat ?? '';
|
requestFormat = settings.requestFormat ?? '';
|
||||||
|
keepAlive = settings.keepAlive ?? '';
|
||||||
|
|
||||||
options.seed = settings.seed ?? 0;
|
options.seed = settings.seed ?? 0;
|
||||||
options.temperature = settings.temperature ?? '';
|
options.temperature = settings.temperature ?? '';
|
||||||
|
@ -85,6 +87,19 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class=" py-1 flex w-full justify-between">
|
||||||
|
<div class=" w-20 text-xs font-medium self-center">Keep Alive</div>
|
||||||
|
<div class=" flex-1 self-center">
|
||||||
|
<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="number"
|
||||||
|
placeholder="Default"
|
||||||
|
bind:value={keepAlive}
|
||||||
|
autocomplete="off"
|
||||||
|
min="-1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-end pt-3 text-sm font-medium">
|
<div class="flex justify-end pt-3 text-sm font-medium">
|
||||||
|
@ -106,7 +121,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');
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue