Kaynağa Gözat

feat: modelfile builder

Timothy J. Baek 1 yıl önce
ebeveyn
işleme
45ff3ae204

+ 12 - 12
src/lib/components/chat/Settings/Advanced.svelte

@@ -22,7 +22,7 @@
 			<div class=" w-20 text-xs font-medium self-center">Seed</div>
 			<div class=" flex-1 self-center">
 				<input
-					class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-600"
+					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="Enter Seed"
 					bind:value={options.seed}
@@ -38,7 +38,7 @@
 			<div class=" w-20 text-xs font-medium self-center">Stop Sequence</div>
 			<div class=" flex-1 self-center">
 				<input
-					class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-600"
+					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="text"
 					placeholder="Enter Stop Sequence"
 					bind:value={options.stop}
@@ -84,7 +84,7 @@
 					<input
 						bind:value={options.temperature}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -127,7 +127,7 @@
 					<input
 						bind:value={options.mirostat}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -170,7 +170,7 @@
 					<input
 						bind:value={options.mirostat_eta}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -213,7 +213,7 @@
 					<input
 						bind:value={options.mirostat_tau}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -256,7 +256,7 @@
 					<input
 						bind:value={options.top_k}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -299,7 +299,7 @@
 					<input
 						bind:value={options.top_p}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -342,7 +342,7 @@
 					<input
 						bind:value={options.repeat_penalty}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -385,7 +385,7 @@
 					<input
 						bind:value={options.repeat_last_n}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -428,7 +428,7 @@
 					<input
 						bind:value={options.tfs_z}
 						type="number"
-						class=" bg-transparent text-center w-10"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>
@@ -471,7 +471,7 @@
 					<input
 						bind:value={options.num_ctx}
 						type="number"
-						class=" bg-transparent text-center w-16"
+						class=" bg-transparent text-center w-14"
 					/>
 				</div>
 			</div>

+ 91 - 90
src/lib/components/layout/Sidebar.svelte

@@ -24,7 +24,7 @@
 
 	let showDropdown = false;
 
-  let showDeleteHistoryConfirm = false;
+	let showDeleteHistoryConfirm = false;
 
 	onMount(async () => {
 		if (window.innerWidth > 1280) {
@@ -121,11 +121,11 @@
 			</button>
 		</div>
 
-		<!-- <div class="px-2.5 flex justify-center my-1">
+		<div class="px-2.5 flex justify-center my-1">
 			<button
 				class="flex-grow flex space-x-3 rounded-md px-3 py-2 hover:bg-gray-900 transition"
 				on:click={async () => {
-					goto('/presets');
+					goto('/modelfiles');
 				}}
 			>
 				<div class="self-center">
@@ -146,10 +146,10 @@
 				</div>
 
 				<div class="flex self-center">
-					<div class=" self-center font-medium text-sm">Presets</div>
+					<div class=" self-center font-medium text-sm">Modelfiles</div>
 				</div>
 			</button>
-		</div> -->
+		</div>
 
 		<div class="px-2.5 mt-1 mb-2 flex justify-center space-x-2">
 			<div class="flex w-full">
@@ -449,91 +449,92 @@
 						<div class=" self-center">Export</div>
 					</button>
 				</div>
-        {#if showDeleteHistoryConfirm}
-          <div class="flex justify-between rounded-md items-center py-3 px-3.5 w-full transition">
-            <div class="flex items-center">
-              <svg 
-                xmlns="http://www.w3.org/2000/svg"
-                fill="none"
-                viewBox="0 0 24 24"
-                stroke-width="1.5"
-                stroke="currentColor"
-                class="w-5 h-5 mr-3"
-              >
-                <path
-                  stroke-linecap="round"
-                  stroke-linejoin="round"
-                  d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
-                />
-              </svg>
-              <span>Are you sure?</span>
-            </div>
-            
-            <div class="flex space-x-1.5 items-center">
-              <button
-                class="hover:text-white transition"
-                on:click={() => {
-                  deleteChatHistory();
-                  showDeleteHistoryConfirm = false;
-                }}
-              >
-                <svg
-                  xmlns="http://www.w3.org/2000/svg"
-                  viewBox="0 0 20 20"
-                  fill="currentColor"
-                  class="w-4 h-4"
-                >
-                  <path
-                    fill-rule="evenodd"
-                    d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z"
-                    clip-rule="evenodd"
-                  />
-                </svg>
-              </button>
-              <button
-                class="hover:text-white transition"
-                on:click={() => {
-                  showDeleteHistoryConfirm = false;
-                }}
-              >
-                <svg
-                  xmlns="http://www.w3.org/2000/svg"
-                  viewBox="0 0 20 20"
-                  fill="currentColor"
-                  class="w-4 h-4"
-                >
-                  <path
-                    d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
-                  />
-                </svg>
-              </button>
-            </div> 
-          </div>
-        {:else}
-          <button
-					class=" flex rounded-md py-3 px-3.5 w-full hover:bg-gray-900 transition"
-					on:click={() => {
-            showDeleteHistoryConfirm = true;
-					}}>
-            <div class="mr-3">
-              <svg
-                xmlns="http://www.w3.org/2000/svg"
-                fill="none"
-                viewBox="0 0 24 24"
-                stroke-width="1.5"
-                stroke="currentColor"
-                class="w-5 h-5"
-              >
-                <path
-                  stroke-linecap="round"
-                  stroke-linejoin="round"
-                  d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
-                />
-              </svg>
-            </div>
-            <span>Clear conversations</span>
-				</button>
-        {/if}
+				{#if showDeleteHistoryConfirm}
+					<div class="flex justify-between rounded-md items-center py-3 px-3.5 w-full transition">
+						<div class="flex items-center">
+							<svg
+								xmlns="http://www.w3.org/2000/svg"
+								fill="none"
+								viewBox="0 0 24 24"
+								stroke-width="1.5"
+								stroke="currentColor"
+								class="w-5 h-5 mr-3"
+							>
+								<path
+									stroke-linecap="round"
+									stroke-linejoin="round"
+									d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
+								/>
+							</svg>
+							<span>Are you sure?</span>
+						</div>
+
+						<div class="flex space-x-1.5 items-center">
+							<button
+								class="hover:text-white transition"
+								on:click={() => {
+									deleteChatHistory();
+									showDeleteHistoryConfirm = false;
+								}}
+							>
+								<svg
+									xmlns="http://www.w3.org/2000/svg"
+									viewBox="0 0 20 20"
+									fill="currentColor"
+									class="w-4 h-4"
+								>
+									<path
+										fill-rule="evenodd"
+										d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z"
+										clip-rule="evenodd"
+									/>
+								</svg>
+							</button>
+							<button
+								class="hover:text-white transition"
+								on:click={() => {
+									showDeleteHistoryConfirm = false;
+								}}
+							>
+								<svg
+									xmlns="http://www.w3.org/2000/svg"
+									viewBox="0 0 20 20"
+									fill="currentColor"
+									class="w-4 h-4"
+								>
+									<path
+										d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
+									/>
+								</svg>
+							</button>
+						</div>
+					</div>
+				{:else}
+					<button
+						class=" flex rounded-md py-3 px-3.5 w-full hover:bg-gray-900 transition"
+						on:click={() => {
+							showDeleteHistoryConfirm = true;
+						}}
+					>
+						<div class="mr-3">
+							<svg
+								xmlns="http://www.w3.org/2000/svg"
+								fill="none"
+								viewBox="0 0 24 24"
+								stroke-width="1.5"
+								stroke="currentColor"
+								class="w-5 h-5"
+							>
+								<path
+									stroke-linecap="round"
+									stroke-linejoin="round"
+									d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
+								/>
+							</svg>
+						</div>
+						<span>Clear conversations</span>
+					</button>
+				{/if}
 
 				{#if $user !== undefined}
 					<button

+ 1 - 3
src/lib/constants.ts

@@ -3,9 +3,7 @@ import { PUBLIC_API_BASE_URL } from '$env/static/public';
 
 export const OLLAMA_API_BASE_URL =
 	PUBLIC_API_BASE_URL === ''
-		? dev
-			? `http://${location.hostname}:8080/ollama/api`
-			: browser
+		? browser
 			? `http://${location.hostname}:11434/api`
 			: `http://localhost:11434/api`
 		: PUBLIC_API_BASE_URL;

+ 61 - 0
src/routes/(app)/modelfiles/+page.svelte

@@ -0,0 +1,61 @@
+<div class="min-h-screen w-full flex justify-center dark:text-white">
+	<div class=" py-2.5 flex flex-col justify-between w-full">
+		<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
+			<div class=" text-2xl font-semibold mb-6">My Modelfiles</div>
+
+			<a class=" flex space-x-3 cursor-pointer w-full mb-3" href="/modelfiles/create">
+				<div class=" self-center">
+					<div
+						class=" p-2 rounded-full bg-transparent dark:bg-gray-700 border border-dashed border-gray-200"
+					>
+						<svg
+							xmlns="http://www.w3.org/2000/svg"
+							viewBox="0 0 24 24"
+							fill="currentColor"
+							class="w-6"
+						>
+							<path
+								fill-rule="evenodd"
+								d="M12 3.75a.75.75 0 01.75.75v6.75h6.75a.75.75 0 010 1.5h-6.75v6.75a.75.75 0 01-1.5 0v-6.75H4.5a.75.75 0 010-1.5h6.75V4.5a.75.75 0 01.75-.75z"
+								clip-rule="evenodd"
+							/>
+						</svg>
+					</div>
+				</div>
+
+				<div class=" self-center">
+					<div class=" font-bold">Create a modelfile</div>
+					<div class=" text-sm">Customize Ollama models for a specific purpose</div>
+				</div>
+			</a>
+
+			<!-- <div class=" my-16">
+				<div class=" text-2xl font-semibold mb-6">Made by Community</div>
+
+				<a class=" flex space-x-3 cursor-pointer w-full mb-3" href="/presets/create">
+					<div class=" self-center">
+						<div class=" p-2 rounded-full bg-gray-700 border border-dashed border-gray-200">
+							<svg
+								xmlns="http://www.w3.org/2000/svg"
+								viewBox="0 0 24 24"
+								fill="currentColor"
+								class="w-6"
+							>
+								<path
+									fill-rule="evenodd"
+									d="M12 3.75a.75.75 0 01.75.75v6.75h6.75a.75.75 0 010 1.5h-6.75v6.75a.75.75 0 01-1.5 0v-6.75H4.5a.75.75 0 010-1.5h6.75V4.5a.75.75 0 01.75-.75z"
+									clip-rule="evenodd"
+								/>
+							</svg>
+						</div>
+					</div>
+
+					<div class=" self-center">
+						<div class=" font-bold">Create a preset</div>
+						<div class=" text-sm">Customize Ollama models for a specific purpose</div>
+					</div>
+				</a>
+			</div> -->
+		</div>
+	</div>
+</div>

+ 475 - 0
src/routes/(app)/modelfiles/create/+page.svelte

@@ -0,0 +1,475 @@
+<script>
+	import { toast } from 'svelte-french-toast';
+	import { goto } from '$app/navigation';
+	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 filesInputElement;
+	let inputFiles;
+	let imageUrl = null;
+
+	let title = '';
+	let desc = '';
+
+	let raw = true;
+	let advanced = false;
+
+	let model = '';
+	let system = '';
+	let template = '';
+	let options = {
+		// Advanced
+		seed: 0,
+		temperature: '',
+		repeat_penalty: '',
+		repeat_last_n: '',
+		mirostat: '',
+		mirostat_eta: '',
+		mirostat_tau: '',
+		top_k: '',
+		top_p: '',
+		stop: '',
+		tfs_z: '',
+		num_ctx: ''
+	};
+	let content = '';
+
+	let suggestions = [
+		{
+			content: ''
+		}
+	];
+
+	const submitHandler = async () => {
+		loading = true;
+		if (
+			title !== '' &&
+			desc !== '' &&
+			content !== '' &&
+			Object.keys(categories).filter((category) => categories[category]).length > 0
+		) {
+			const res = await fetch(`/api/create`, {
+				method: 'POST',
+				headers: {
+					'Content-Type': 'application/json'
+				},
+				body: JSON.stringify({
+					title: title,
+					desc: desc,
+					content: content,
+					imageUrl: imageUrl,
+					categories: Object.keys(categories).filter((category) => categories[category])
+				})
+			})
+				.then(async (res) => {
+					if (!res.ok) throw await res.json();
+					return res.json();
+				})
+				.catch((error) => {
+					console.log(error);
+					return null;
+				});
+
+			if (res?.status ?? false) {
+				toast.success(`Success! Your model file is now available.`);
+				await goto(`/models/${res.id}`);
+			}
+		}
+		loading = false;
+	};
+</script>
+
+<div class="min-h-screen w-full flex justify-center dark:text-white">
+	<div class=" py-2.5 flex flex-col justify-between w-full">
+		<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
+			<input
+				bind:this={filesInputElement}
+				bind:files={inputFiles}
+				type="file"
+				hidden
+				accept="image/*"
+				on:change={() => {
+					let reader = new FileReader();
+					reader.onload = (event) => {
+						let originalImageUrl = `${event.target.result}`;
+
+						const img = new Image();
+						img.src = originalImageUrl;
+
+						img.onload = function () {
+							const canvas = document.createElement('canvas');
+							const ctx = canvas.getContext('2d');
+
+							// Set canvas dimensions to the original image dimensions
+							canvas.width = img.width;
+							canvas.height = img.height;
+
+							// Draw the original image on the canvas
+							ctx.drawImage(img, 0, 0);
+
+							// Get the base64 representation of the compressed image
+							const compressedSrc = canvas.toDataURL('image/jpeg', 0.1);
+
+							// Display the compressed image
+							imageUrl = compressedSrc;
+
+							inputFiles = null;
+						};
+					};
+
+					if (
+						inputFiles &&
+						inputFiles.length > 0 &&
+						['image/gif', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type'])
+					) {
+						reader.readAsDataURL(inputFiles[0]);
+					} else {
+						console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`);
+						inputFiles = null;
+					}
+				}}
+			/>
+
+			<div class=" text-2xl font-semibold mb-6">My Modelfiles</div>
+
+			<button
+				class="flex space-x-1"
+				on:click={() => {
+					history.back();
+				}}
+			>
+				<div class=" self-center">
+					<svg
+						xmlns="http://www.w3.org/2000/svg"
+						viewBox="0 0 20 20"
+						fill="currentColor"
+						class="w-4 h-4"
+					>
+						<path
+							fill-rule="evenodd"
+							d="M17 10a.75.75 0 01-.75.75H5.612l4.158 3.96a.75.75 0 11-1.04 1.08l-5.5-5.25a.75.75 0 010-1.08l5.5-5.25a.75.75 0 111.04 1.08L5.612 9.25H16.25A.75.75 0 0117 10z"
+							clip-rule="evenodd"
+						/>
+					</svg>
+				</div>
+				<div class=" self-center font-medium text-sm">Back</div>
+			</button>
+			<hr class="my-3 dark:border-gray-700" />
+
+			<form
+				class="flex flex-col"
+				on:submit|preventDefault={() => {
+					submitHandler();
+				}}
+			>
+				<div class="flex justify-center my-4">
+					<div class="self-center">
+						<button
+							class=" {imageUrl
+								? ''
+								: 'p-6'} rounded-full dark:bg-gray-700 border border-dashed border-gray-200"
+							type="button"
+							on:click={() => {
+								filesInputElement.click();
+							}}
+						>
+							{#if imageUrl}
+								<img
+									src={imageUrl}
+									alt="modelfile profile"
+									class=" rounded-full w-20 h-20 object-cover"
+								/>
+							{:else}
+								<svg
+									xmlns="http://www.w3.org/2000/svg"
+									viewBox="0 0 24 24"
+									fill="currentColor"
+									class="w-8"
+								>
+									<path
+										fill-rule="evenodd"
+										d="M12 3.75a.75.75 0 01.75.75v6.75h6.75a.75.75 0 010 1.5h-6.75v6.75a.75.75 0 01-1.5 0v-6.75H4.5a.75.75 0 010-1.5h6.75V4.5a.75.75 0 01.75-.75z"
+										clip-rule="evenodd"
+									/>
+								</svg>
+							{/if}
+						</button>
+					</div>
+				</div>
+
+				<div class="my-2">
+					<div class=" text-sm font-semibold mb-2">Name*</div>
+
+					<div>
+						<input
+							class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
+							placeholder="Name your modelfile"
+							bind:value={title}
+							required
+						/>
+					</div>
+				</div>
+
+				<div class="my-2">
+					<div class=" text-sm font-semibold mb-2">Description*</div>
+
+					<div>
+						<input
+							class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
+							placeholder="Add a short description about what this modelfile does"
+							bind:value={desc}
+							required
+						/>
+					</div>
+				</div>
+
+				<div class="my-2">
+					<div class="flex w-full justify-between">
+						<div class=" self-center text-sm font-semibold">Modelfile</div>
+
+						<button
+							class="p-1 px-3 text-xs flex rounded transition"
+							type="button"
+							on:click={() => {
+								raw = !raw;
+							}}
+						>
+							{#if raw}
+								<span class="ml-2 self-center"> Raw Format </span>
+							{:else}
+								<span class="ml-2 self-center"> Builder Mode </span>
+							{/if}
+						</button>
+					</div>
+
+					<!-- <div class=" text-sm font-semibold mb-2"></div> -->
+
+					{#if raw}
+						<div class="mt-2">
+							<div class=" text-xs font-semibold mb-2">Content*</div>
+
+							<div>
+								<textarea
+									class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
+									placeholder={`FROM llama2\nPARAMETER temperature 1\nSYSTEM """\nYou are Mario from Super Mario Bros, acting as an assistant.\n"""`}
+									rows="6"
+									bind:value={content}
+									required
+								/>
+							</div>
+
+							<div class="text-xs text-gray-400 dark:text-gray-500">
+								Not sure what to write? Switch to <button
+									class="text-gray-500 dark:text-gray-300 font-medium cursor-pointer"
+									type="button"
+									on:click={() => {
+										raw = !raw;
+									}}>Builder Mode</button
+								>
+								or
+								<a
+									class=" text-gray-500 dark:text-gray-300 font-medium"
+									href="https://ollamahub.com"
+									target="_blank"
+								>
+									Click here to check other modelfiles.
+								</a>
+							</div>
+						</div>
+					{:else}
+						<div class="my-2">
+							<div class=" text-xs font-semibold mb-2">From (Base Model)*</div>
+
+							<div>
+								<input
+									class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
+									placeholder="Write a modelfile base model name (e.g. llama2, mistral)"
+									bind:value={model}
+									required
+								/>
+							</div>
+						</div>
+
+						<div class="my-2">
+							<div class=" text-xs font-semibold mb-2">System Prompt</div>
+
+							<div>
+								<textarea
+									class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg -mb-1"
+									placeholder={`Write your modelfile system prompt content here\ne.g.) You are Mario from Super Mario Bros, acting as an assistant.`}
+									rows="4"
+									bind:value={system}
+								/>
+							</div>
+						</div>
+
+						<div class="flex w-full justify-between">
+							<div class=" self-center text-sm font-semibold">Modelfile Advanced Settings</div>
+
+							<button
+								class="p-1 px-3 text-xs flex rounded transition"
+								type="button"
+								on:click={() => {
+									advanced = !advanced;
+								}}
+							>
+								{#if advanced}
+									<span class="ml-2 self-center"> Custom </span>
+								{:else}
+									<span class="ml-2 self-center"> Default </span>
+								{/if}
+							</button>
+						</div>
+
+						{#if advanced}
+							<div class="my-2">
+								<div class=" text-xs font-semibold mb-2">Template</div>
+
+								<div>
+									<textarea
+										class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg -mb-1"
+										placeholder="Write your modelfile template content here"
+										rows="4"
+										bind:value={template}
+									/>
+								</div>
+							</div>
+
+							<div class="my-2">
+								<div class=" text-xs font-semibold mb-2">Parameters</div>
+
+								<div>
+									<Advanced bind:options />
+								</div>
+							</div>
+						{/if}
+					{/if}
+				</div>
+
+				<div class="my-2">
+					<div class="flex w-full justify-between mb-2">
+						<div class=" self-center text-sm font-semibold">Prompt suggestions</div>
+
+						<button
+							class="p-1 px-3 text-xs flex rounded transition"
+							type="button"
+							on:click={() => {
+								suggestions = [...suggestions, { content: '' }];
+							}}
+						>
+							<svg
+								xmlns="http://www.w3.org/2000/svg"
+								viewBox="0 0 20 20"
+								fill="currentColor"
+								class="w-4 h-4"
+							>
+								<path
+									d="M10.75 4.75a.75.75 0 00-1.5 0v4.5h-4.5a.75.75 0 000 1.5h4.5v4.5a.75.75 0 001.5 0v-4.5h4.5a.75.75 0 000-1.5h-4.5v-4.5z"
+								/>
+							</svg>
+						</button>
+					</div>
+					<div class="flex flex-col space-y-1">
+						{#each suggestions as prompt, promptIdx}
+							<div class=" flex border dark:border-gray-600 rounded-lg">
+								<input
+									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?)"
+									bind:value={prompt.content}
+									required
+								/>
+
+								<button
+									class="px-2"
+									type="button"
+									on:click={() => {
+										suggestions.splice(promptIdx, 1);
+										suggestions = suggestions;
+									}}
+								>
+									<svg
+										xmlns="http://www.w3.org/2000/svg"
+										viewBox="0 0 20 20"
+										fill="currentColor"
+										class="w-4 h-4"
+									>
+										<path
+											d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
+										/>
+									</svg>
+								</button>
+							</div>
+						{/each}
+					</div>
+				</div>
+
+				<div class="my-2">
+					<div class=" text-sm font-semibold mb-2">Categories</div>
+
+					<div class="grid grid-cols-4">
+						{#each Object.keys(categories) as category}
+							<div class="flex space-x-2 text-sm">
+								<input type="checkbox" bind:checked={categories[category]} />
+
+								<div>{category}</div>
+							</div>
+						{/each}
+					</div>
+				</div>
+
+				<div class="my-2 flex justify-end">
+					<button
+						class=" text-sm px-3 py-2 transition rounded-xl {loading
+							? ' cursor-not-allowed bg-gray-100 dark:bg-gray-800'
+							: ' bg-gray-50 hover:bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-800'} flex"
+						type="submit"
+						disabled={loading}
+					>
+						<div class=" self-center font-medium">Save & Create</div>
+
+						{#if loading}
+							<div class="ml-1.5 self-center">
+								<svg
+									class=" w-4 h-4"
+									viewBox="0 0 24 24"
+									fill="currentColor"
+									xmlns="http://www.w3.org/2000/svg"
+									><style>
+										.spinner_ajPY {
+											transform-origin: center;
+											animation: spinner_AtaB 0.75s infinite linear;
+										}
+										@keyframes spinner_AtaB {
+											100% {
+												transform: rotate(360deg);
+											}
+										}
+									</style><path
+										d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
+										opacity=".25"
+									/><path
+										d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
+										class="spinner_ajPY"
+									/></svg
+								>
+							</div>
+						{/if}
+					</button>
+				</div>
+			</form>
+		</div>
+	</div>
+</div>