forked from open-webui/open-webui
		
	fix: check existing model before model creation
This commit is contained in:
		
							parent
							
								
									59fb1b933d
								
							
						
					
					
						commit
						fbb64406d8
					
				
					 3 changed files with 5 additions and 15 deletions
				
			
		|  | @ -97,8 +97,6 @@ | |||
| 
 | ||||
| 			console.log(); | ||||
| 			await settings.set(JSON.parse(localStorage.getItem('settings') ?? '{}')); | ||||
| 			// await models.set(await getModels()); | ||||
| 			// JSON.parse(localStorage.getItem('modelfiles') ?? '[]') | ||||
| 			await modelfiles.set(await getModelfiles(localStorage.token)); | ||||
| 			console.log($modelfiles); | ||||
| 
 | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ | |||
| 	import { splitStream } from '$lib/utils'; | ||||
| 	import { onMount, tick } from 'svelte'; | ||||
| 	import { createModel } from '$lib/apis/ollama'; | ||||
| 	import { createNewModelfile, getModelfiles } from '$lib/apis/modelfiles'; | ||||
| 	import { createNewModelfile, getModelfileByTagName, getModelfiles } from '$lib/apis/modelfiles'; | ||||
| 
 | ||||
| 	let loading = false; | ||||
| 
 | ||||
|  | @ -117,7 +117,10 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, ''); | |||
| 			return success; | ||||
| 		} | ||||
| 
 | ||||
| 		if ($models.includes(tagName)) { | ||||
| 		if ( | ||||
| 			$models.map((model) => model.name).includes(tagName) || | ||||
| 			(await getModelfileByTagName(localStorage.token, tagName).catch(() => false)) | ||||
| 		) { | ||||
| 			toast.error( | ||||
| 				`Uh-oh! It looks like you already have a model named '${tagName}'. Please choose a different name to complete your modelfile.` | ||||
| 			); | ||||
|  |  | |||
|  | @ -85,17 +85,6 @@ | |||
| 	}); | ||||
| 
 | ||||
| 	const updateModelfile = async (modelfile) => { | ||||
| 		// await modelfiles.set( | ||||
| 		// 	$modelfiles.map((e) => { | ||||
| 		// 		if (e.tagName === modelfile.tagName) { | ||||
| 		// 			return modelfile; | ||||
| 		// 		} else { | ||||
| 		// 			return e; | ||||
| 		// 		} | ||||
| 		// 	}) | ||||
| 		// ); | ||||
| 		// localStorage.setItem('modelfiles', JSON.stringify($modelfiles)); | ||||
| 
 | ||||
| 		await updateModelfileByTagName(localStorage.token, modelfile.tagName, modelfile); | ||||
| 		await modelfiles.set(await getModelfiles(localStorage.token)); | ||||
| 	}; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek