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'; | ||||
| }; | ||||
| 
 | ||||
| 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; | ||||
| 
 | ||||
| 	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. | ||||
| 			 | ||||
| 			Response: | ||||
| 			` | ||||
| 			`,
 | ||||
| 			...body | ||||
| 		}) | ||||
| 	}).catch((err) => { | ||||
| 		console.log(err); | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| <script lang="ts"> | ||||
| 	import { generatePrompt } from '$lib/apis/ollama'; | ||||
| 	import { models } from '$lib/stores'; | ||||
| 	import { models, settings } from '$lib/stores'; | ||||
| 	import { splitStream } from '$lib/utils'; | ||||
| 	import { tick } from 'svelte'; | ||||
| 	import toast from 'svelte-french-toast'; | ||||
|  | @ -53,7 +53,7 @@ | |||
| 			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) { | ||||
| 			const reader = res.body | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ | |||
| 
 | ||||
| 	// Advanced | ||||
| 	let requestFormat = ''; | ||||
| 	let keepAlive = ''; | ||||
| 	let options = { | ||||
| 		// Advanced | ||||
| 		seed: 0, | ||||
|  | @ -38,6 +39,7 @@ | |||
| 		let settings = JSON.parse(localStorage.getItem('settings') ?? '{}'); | ||||
| 
 | ||||
| 		requestFormat = settings.requestFormat ?? ''; | ||||
| 		keepAlive = settings.keepAlive ?? ''; | ||||
| 
 | ||||
| 		options.seed = settings.seed ?? 0; | ||||
| 		options.temperature = settings.temperature ?? ''; | ||||
|  | @ -85,6 +87,19 @@ | |||
| 				</button> | ||||
| 			</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 class="flex justify-end pt-3 text-sm font-medium"> | ||||
|  | @ -106,7 +121,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'); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Zohaib Rauf
						Zohaib Rauf