forked from open-webui/open-webui
		
	feat: ollamahub modelfile import
This commit is contained in:
		
							parent
							
								
									6df1b197aa
								
							
						
					
					
						commit
						cbcce68c61
					
				
					 3 changed files with 56 additions and 18 deletions
				
			
		|  | @ -103,7 +103,7 @@ | ||||||
| 						<a | 						<a | ||||||
| 							class=" w-fit text-sm px-3 py-2 border dark:border-gray-600 rounded-xl" | 							class=" w-fit text-sm px-3 py-2 border dark:border-gray-600 rounded-xl" | ||||||
| 							type="button" | 							type="button" | ||||||
| 							href={`/modelfiles/edit/${modelfile.tagName}`} | 							href={`/modelfiles/edit?tag=${modelfile.tagName}`} | ||||||
| 						> | 						> | ||||||
| 							Edit</a | 							Edit</a | ||||||
| 						> | 						> | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ | ||||||
| 
 | 
 | ||||||
| 	import Advanced from '$lib/components/chat/Settings/Advanced.svelte'; | 	import Advanced from '$lib/components/chat/Settings/Advanced.svelte'; | ||||||
| 	import { splitStream } from '$lib/utils'; | 	import { splitStream } from '$lib/utils'; | ||||||
|  | 	import { onMount, tick } from 'svelte'; | ||||||
| 
 | 
 | ||||||
| 	let loading = false; | 	let loading = false; | ||||||
| 
 | 
 | ||||||
|  | @ -209,6 +210,39 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, ''); | ||||||
| 		loading = false; | 		loading = false; | ||||||
| 		success = false; | 		success = false; | ||||||
| 	}; | 	}; | ||||||
|  | 
 | ||||||
|  | 	onMount(() => { | ||||||
|  | 		window.addEventListener('message', async (event) => { | ||||||
|  | 			if ( | ||||||
|  | 				!['https://ollamahub.com', 'https://www.ollamahub.com', 'http://localhost:5173'].includes( | ||||||
|  | 					event.origin | ||||||
|  | 				) | ||||||
|  | 			) | ||||||
|  | 				return; | ||||||
|  | 			const modelfile = JSON.parse(event.data); | ||||||
|  | 			console.log(modelfile); | ||||||
|  | 
 | ||||||
|  | 			imageUrl = modelfile.imageUrl; | ||||||
|  | 			title = modelfile.title; | ||||||
|  | 			await tick(); | ||||||
|  | 			tagName = `${modelfile.user.username}/${modelfile.tagName}`; | ||||||
|  | 			desc = modelfile.desc; | ||||||
|  | 			content = modelfile.content; | ||||||
|  | 			suggestions = | ||||||
|  | 				modelfile.suggestionPrompts.length != 0 | ||||||
|  | 					? modelfile.suggestionPrompts | ||||||
|  | 					: [ | ||||||
|  | 							{ | ||||||
|  | 								content: '' | ||||||
|  | 							} | ||||||
|  | 					  ]; | ||||||
|  | 
 | ||||||
|  | 			for (const category of modelfile.categories) { | ||||||
|  | 				categories[category.toLowerCase()] = true; | ||||||
|  | 			} | ||||||
|  | 		}); | ||||||
|  | 		window.opener.postMessage('loaded', '*'); | ||||||
|  | 	}); | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <div class="min-h-screen w-full flex justify-center dark:text-white"> | <div class="min-h-screen w-full flex justify-center dark:text-white"> | ||||||
|  |  | ||||||
|  | @ -50,27 +50,31 @@ | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	onMount(() => { | 	onMount(() => { | ||||||
| 		tagName = $page.params.tag; | 		tagName = $page.url.searchParams.get('tag'); | ||||||
| 
 | 
 | ||||||
| 		modelfile = $modelfiles.filter((modelfile) => modelfile.tagName === tagName)[0]; | 		if (tagName) { | ||||||
|  | 			modelfile = $modelfiles.filter((modelfile) => modelfile.tagName === tagName)[0]; | ||||||
| 
 | 
 | ||||||
| 		console.log(modelfile); | 			console.log(modelfile); | ||||||
| 
 | 
 | ||||||
| 		imageUrl = modelfile.imageUrl; | 			imageUrl = modelfile.imageUrl; | ||||||
| 		title = modelfile.title; | 			title = modelfile.title; | ||||||
| 		desc = modelfile.desc; | 			desc = modelfile.desc; | ||||||
| 		content = modelfile.content; | 			content = modelfile.content; | ||||||
| 		suggestions = | 			suggestions = | ||||||
| 			modelfile.suggestionPrompts.length != 0 | 				modelfile.suggestionPrompts.length != 0 | ||||||
| 				? modelfile.suggestionPrompts | 					? modelfile.suggestionPrompts | ||||||
| 				: [ | 					: [ | ||||||
| 						{ | 							{ | ||||||
| 							content: '' | 								content: '' | ||||||
| 						} | 							} | ||||||
| 				  ]; | 					  ]; | ||||||
| 
 | 
 | ||||||
| 		for (const category of modelfile.categories) { | 			for (const category of modelfile.categories) { | ||||||
| 			categories[category.toLowerCase()] = true; | 				categories[category.toLowerCase()] = true; | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			goto('/modelfiles'); | ||||||
| 		} | 		} | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek