forked from open-webui/open-webui
		
	feat: modelfile builder
This commit is contained in:
		
							parent
							
								
									45ff3ae204
								
							
						
					
					
						commit
						19ec26ab63
					
				
					 1 changed files with 44 additions and 15 deletions
				
			
		|  | @ -3,18 +3,6 @@ | ||||||
| 	import { goto } from '$app/navigation'; | 	import { goto } from '$app/navigation'; | ||||||
| 	import Advanced from '$lib/components/chat/Settings/Advanced.svelte'; | 	import Advanced from '$lib/components/chat/Settings/Advanced.svelte'; | ||||||
| 
 | 
 | ||||||
| 	let categories = { |  | ||||||
| 		Character: false, |  | ||||||
| 		Assistant: false, |  | ||||||
| 		Writing: false, |  | ||||||
| 		Productivity: false, |  | ||||||
| 		Programming: false, |  | ||||||
| 		'Data Analysis': false, |  | ||||||
| 		Lifestyle: false, |  | ||||||
| 		Education: false, |  | ||||||
| 		Business: false |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 	let loading = false; | 	let loading = false; | ||||||
| 
 | 
 | ||||||
| 	let filesInputElement; | 	let filesInputElement; | ||||||
|  | @ -27,12 +15,17 @@ | ||||||
| 	let raw = true; | 	let raw = true; | ||||||
| 	let advanced = false; | 	let advanced = false; | ||||||
| 
 | 
 | ||||||
|  | 	// Raw Mode | ||||||
|  | 	let content = ''; | ||||||
|  | 
 | ||||||
|  | 	// Builder Mode | ||||||
| 	let model = ''; | 	let model = ''; | ||||||
| 	let system = ''; | 	let system = ''; | ||||||
| 	let template = ''; | 	let template = ''; | ||||||
| 	let options = { | 	let options = { | ||||||
| 		// Advanced | 		// Advanced | ||||||
| 		seed: 0, | 		seed: 0, | ||||||
|  | 		stop: '', | ||||||
| 		temperature: '', | 		temperature: '', | ||||||
| 		repeat_penalty: '', | 		repeat_penalty: '', | ||||||
| 		repeat_last_n: '', | 		repeat_last_n: '', | ||||||
|  | @ -41,11 +34,29 @@ | ||||||
| 		mirostat_tau: '', | 		mirostat_tau: '', | ||||||
| 		top_k: '', | 		top_k: '', | ||||||
| 		top_p: '', | 		top_p: '', | ||||||
| 		stop: '', |  | ||||||
| 		tfs_z: '', | 		tfs_z: '', | ||||||
| 		num_ctx: '' | 		num_ctx: '' | ||||||
| 	}; | 	}; | ||||||
| 	let content = ''; | 
 | ||||||
|  | 	$: if (!raw) { | ||||||
|  | 		content = `FROM ${model} | ||||||
|  | ${template !== '' ? `TEMPLATE """${template}"""` : ''} | ||||||
|  | ${options.seed !== 0 ? `PARAMETER seed ${options.seed}` : ''} | ||||||
|  | ${options.stop !== '' ? `PARAMETER stop ${options.stop}` : ''} | ||||||
|  | ${options.temperature !== '' ? `PARAMETER temperature ${options.temperature}` : ''} | ||||||
|  | ${options.repeat_penalty !== '' ? `PARAMETER repeat_penalty ${options.repeat_penalty}` : ''} | ||||||
|  | ${options.repeat_last_n !== '' ? `PARAMETER repeat_last_n ${options.repeat_last_n}` : ''} | ||||||
|  | ${options.mirostat !== '' ? `PARAMETER mirostat ${options.mirostat}` : ''} | ||||||
|  | ${options.mirostat_eta !== '' ? `PARAMETER mirostat_eta ${options.mirostat_eta}` : ''} | ||||||
|  | ${options.mirostat_tau !== '' ? `PARAMETER mirostat_tau ${options.mirostat_tau}` : ''} | ||||||
|  | ${options.top_k !== '' ? `PARAMETER top_k ${options.top_k}` : ''} | ||||||
|  | ${options.top_p !== '' ? `PARAMETER top_p ${options.top_p}` : ''} | ||||||
|  | ${options.tfs_z !== '' ? `PARAMETER tfs_z ${options.tfs_z}` : ''} | ||||||
|  | ${options.num_ctx !== '' ? `PARAMETER num_ctx ${options.num_ctx}` : ''} | ||||||
|  | SYSTEM """${system}"""`.replace(/^\s*\n/gm, ''); | ||||||
|  | 	} else { | ||||||
|  | 		// content = ''; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	let suggestions = [ | 	let suggestions = [ | ||||||
| 		{ | 		{ | ||||||
|  | @ -53,8 +64,27 @@ | ||||||
| 		} | 		} | ||||||
| 	]; | 	]; | ||||||
| 
 | 
 | ||||||
|  | 	let categories = { | ||||||
|  | 		Character: false, | ||||||
|  | 		Assistant: false, | ||||||
|  | 		Writing: false, | ||||||
|  | 		Productivity: false, | ||||||
|  | 		Programming: false, | ||||||
|  | 		'Data Analysis': false, | ||||||
|  | 		Lifestyle: false, | ||||||
|  | 		Education: false, | ||||||
|  | 		Business: false | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
| 	const submitHandler = async () => { | 	const submitHandler = async () => { | ||||||
| 		loading = true; | 		loading = true; | ||||||
|  | 
 | ||||||
|  | 		if (Object.keys(categories).filter((category) => categories[category]).length == 0) { | ||||||
|  | 			toast.error( | ||||||
|  | 				'Uh-oh! It looks like you missed selecting a category. Please choose one to complete your modelfile.' | ||||||
|  | 			); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		if ( | 		if ( | ||||||
| 			title !== '' && | 			title !== '' && | ||||||
| 			desc !== '' && | 			desc !== '' && | ||||||
|  | @ -389,7 +419,6 @@ | ||||||
| 									class="px-3 py-1.5 text-sm w-full bg-transparent outline-none border-r dark:border-gray-600" | 									class="px-3 py-1.5 text-sm w-full bg-transparent outline-none border-r dark:border-gray-600" | ||||||
| 									placeholder="Write a prompt suggestion (e.g. Who are you?)" | 									placeholder="Write a prompt suggestion (e.g. Who are you?)" | ||||||
| 									bind:value={prompt.content} | 									bind:value={prompt.content} | ||||||
| 									required |  | ||||||
| 								/> | 								/> | ||||||
| 
 | 
 | ||||||
| 								<button | 								<button | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek