|
@@ -204,7 +204,7 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
|
|
categories: Object.keys(categories).filter((category) => categories[category]),
|
|
|
user: modelfileCreator !== null ? modelfileCreator : undefined
|
|
|
});
|
|
|
- await goto('/modelfiles');
|
|
|
+ await goto('/workspace/modelfiles');
|
|
|
}
|
|
|
}
|
|
|
loading = false;
|
|
@@ -283,328 +283,353 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
-<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
|
|
|
- <div class=" flex flex-col justify-between w-full overflow-y-auto">
|
|
|
- <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');
|
|
|
-
|
|
|
- // Calculate the aspect ratio of the image
|
|
|
- const aspectRatio = img.width / img.height;
|
|
|
-
|
|
|
- // Calculate the new width and height to fit within 100x100
|
|
|
- let newWidth, newHeight;
|
|
|
- if (aspectRatio > 1) {
|
|
|
- newWidth = 100 * aspectRatio;
|
|
|
- newHeight = 100;
|
|
|
- } else {
|
|
|
- newWidth = 100;
|
|
|
- newHeight = 100 / aspectRatio;
|
|
|
- }
|
|
|
-
|
|
|
- // Set the canvas size
|
|
|
- canvas.width = 100;
|
|
|
- canvas.height = 100;
|
|
|
-
|
|
|
- // Calculate the position to center the image
|
|
|
- const offsetX = (100 - newWidth) / 2;
|
|
|
- const offsetY = (100 - newHeight) / 2;
|
|
|
+<div class="w-full max-h-full">
|
|
|
+ <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');
|
|
|
+
|
|
|
+ // Calculate the aspect ratio of the image
|
|
|
+ const aspectRatio = img.width / img.height;
|
|
|
+
|
|
|
+ // Calculate the new width and height to fit within 100x100
|
|
|
+ let newWidth, newHeight;
|
|
|
+ if (aspectRatio > 1) {
|
|
|
+ newWidth = 100 * aspectRatio;
|
|
|
+ newHeight = 100;
|
|
|
+ } else {
|
|
|
+ newWidth = 100;
|
|
|
+ newHeight = 100 / aspectRatio;
|
|
|
+ }
|
|
|
|
|
|
- // Draw the image on the canvas
|
|
|
- ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight);
|
|
|
+ // Set the canvas size
|
|
|
+ canvas.width = 100;
|
|
|
+ canvas.height = 100;
|
|
|
|
|
|
- // Get the base64 representation of the compressed image
|
|
|
- const compressedSrc = canvas.toDataURL('image/jpeg');
|
|
|
+ // Calculate the position to center the image
|
|
|
+ const offsetX = (100 - newWidth) / 2;
|
|
|
+ const offsetY = (100 - newHeight) / 2;
|
|
|
|
|
|
- // Display the compressed image
|
|
|
- imageUrl = compressedSrc;
|
|
|
+ // Draw the image on the canvas
|
|
|
+ ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight);
|
|
|
|
|
|
- inputFiles = null;
|
|
|
- };
|
|
|
- };
|
|
|
+ // Get the base64 representation of the compressed image
|
|
|
+ const compressedSrc = canvas.toDataURL('image/jpeg');
|
|
|
|
|
|
- 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;
|
|
|
- }
|
|
|
- }}
|
|
|
- />
|
|
|
+ // Display the compressed image
|
|
|
+ imageUrl = compressedSrc;
|
|
|
|
|
|
- <div class=" text-2xl font-semibold mb-6">{$i18n.t('My Modelfiles')}</div>
|
|
|
+ inputFiles = null;
|
|
|
+ };
|
|
|
+ };
|
|
|
|
|
|
- <button
|
|
|
- class="flex space-x-1"
|
|
|
- on:click={() => {
|
|
|
- history.back();
|
|
|
- }}
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+
|
|
|
+ <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"
|
|
|
>
|
|
|
- <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"
|
|
|
+ <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">{$i18n.t('Back')}</div>
|
|
|
+ </button>
|
|
|
+ <!-- <hr class="my-3 dark:border-gray-700" /> -->
|
|
|
+
|
|
|
+ <form
|
|
|
+ class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
|
|
|
+ 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"
|
|
|
/>
|
|
|
- </svg>
|
|
|
- </div>
|
|
|
- <div class=" self-center font-medium text-sm">{$i18n.t('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();
|
|
|
- }}
|
|
|
+ {:else}
|
|
|
+ <svg
|
|
|
+ xmlns="http://www.w3.org/2000/svg"
|
|
|
+ viewBox="0 0 24 24"
|
|
|
+ fill="currentColor"
|
|
|
+ class="w-8"
|
|
|
>
|
|
|
- {#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>
|
|
|
+ <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 flex space-x-2">
|
|
|
- <div class="flex-1">
|
|
|
- <div class=" text-sm font-semibold mb-2">{$i18n.t('Name')}*</div>
|
|
|
+ <div class="my-2 flex space-x-2">
|
|
|
+ <div class="flex-1">
|
|
|
+ <div class=" text-sm font-semibold mb-2">{$i18n.t('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={$i18n.t('Name your modelfile')}
|
|
|
+ bind:value={title}
|
|
|
+ required
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="flex-1">
|
|
|
+ <div class=" text-sm font-semibold mb-2">{$i18n.t('Model Tag 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={$i18n.t('Add a model tag name')}
|
|
|
+ bind:value={tagName}
|
|
|
+ required
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </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={$i18n.t('Name your modelfile')}
|
|
|
- bind:value={title}
|
|
|
- required
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <div class="my-2">
|
|
|
+ <div class=" text-sm font-semibold mb-2">{$i18n.t('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={$i18n.t('Add a short description about what this modelfile does')}
|
|
|
+ bind:value={desc}
|
|
|
+ required
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="flex-1">
|
|
|
- <div class=" text-sm font-semibold mb-2">{$i18n.t('Model Tag Name')}*</div>
|
|
|
+ <div class="my-2">
|
|
|
+ <div class="flex w-full justify-between">
|
|
|
+ <div class=" self-center text-sm font-semibold">{$i18n.t('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"> {$i18n.t('Raw Format')} </span>
|
|
|
+ {:else}
|
|
|
+ <span class="ml-2 self-center"> {$i18n.t('Builder Mode')} </span>
|
|
|
+ {/if}
|
|
|
+ </button>
|
|
|
+ </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={$i18n.t('Add a model tag name')}
|
|
|
- bind:value={tagName}
|
|
|
- required
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <!-- <div class=" text-sm font-semibold mb-2"></div> -->
|
|
|
|
|
|
- <div class="my-2">
|
|
|
- <div class=" text-sm font-semibold mb-2">{$i18n.t('Description')}*</div>
|
|
|
+ {#if raw}
|
|
|
+ <div class="mt-2">
|
|
|
+ <div class=" text-xs font-semibold mb-2">{$i18n.t('Content')}*</div>
|
|
|
|
|
|
<div>
|
|
|
- <input
|
|
|
+ <textarea
|
|
|
class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
|
|
|
- placeholder={$i18n.t('Add a short description about what this modelfile does')}
|
|
|
- bind:value={desc}
|
|
|
+ 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>
|
|
|
-
|
|
|
- <div class="my-2">
|
|
|
- <div class="flex w-full justify-between">
|
|
|
- <div class=" self-center text-sm font-semibold">{$i18n.t('Modelfile')}</div>
|
|
|
|
|
|
+ <div class="text-xs text-gray-400 dark:text-gray-500">
|
|
|
+ {$i18n.t('Not sure what to write? Switch to')}
|
|
|
<button
|
|
|
- class="p-1 px-3 text-xs flex rounded transition"
|
|
|
+ class="text-gray-500 dark:text-gray-300 font-medium cursor-pointer"
|
|
|
type="button"
|
|
|
on:click={() => {
|
|
|
raw = !raw;
|
|
|
- }}
|
|
|
+ }}>{$i18n.t('Builder Mode')}</button
|
|
|
>
|
|
|
- {#if raw}
|
|
|
- <span class="ml-2 self-center"> {$i18n.t('Raw Format')} </span>
|
|
|
- {:else}
|
|
|
- <span class="ml-2 self-center"> {$i18n.t('Builder Mode')} </span>
|
|
|
- {/if}
|
|
|
- </button>
|
|
|
+ or
|
|
|
+ <a
|
|
|
+ class=" text-gray-500 dark:text-gray-300 font-medium"
|
|
|
+ href="https://openwebui.com"
|
|
|
+ target="_blank"
|
|
|
+ >
|
|
|
+ {$i18n.t('Click here to check other modelfiles.')}
|
|
|
+ </a>
|
|
|
</div>
|
|
|
+ </div>
|
|
|
+ {:else}
|
|
|
+ <div class="my-2">
|
|
|
+ <div class=" text-xs font-semibold mb-2">{$i18n.t('From (Base Model)')}*</div>
|
|
|
|
|
|
- <!-- <div class=" text-sm font-semibold mb-2"></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>
|
|
|
|
|
|
- {#if raw}
|
|
|
- <div class="mt-2">
|
|
|
- <div class=" text-xs font-semibold mb-2">{$i18n.t('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">
|
|
|
- {$i18n.t('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;
|
|
|
- }}>{$i18n.t('Builder Mode')}</button
|
|
|
- >
|
|
|
- or
|
|
|
- <a
|
|
|
- class=" text-gray-500 dark:text-gray-300 font-medium"
|
|
|
- href="https://openwebui.com"
|
|
|
- target="_blank"
|
|
|
- >
|
|
|
- {$i18n.t('Click here to check other modelfiles.')}
|
|
|
- </a>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- {:else}
|
|
|
- <div class="my-2">
|
|
|
- <div class=" text-xs font-semibold mb-2">{$i18n.t('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 class="mt-1 text-xs text-gray-400 dark:text-gray-500">
|
|
|
- {$i18n.t('To access the available model names for downloading,')}
|
|
|
- <a
|
|
|
- class=" text-gray-500 dark:text-gray-300 font-medium"
|
|
|
- href="https://ollama.com/library"
|
|
|
- target="_blank">{$i18n.t('click here.')}</a
|
|
|
- >
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <div class="mt-1 text-xs text-gray-400 dark:text-gray-500">
|
|
|
+ {$i18n.t('To access the available model names for downloading,')}
|
|
|
+ <a
|
|
|
+ class=" text-gray-500 dark:text-gray-300 font-medium"
|
|
|
+ href="https://ollama.com/library"
|
|
|
+ target="_blank">{$i18n.t('click here.')}</a
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="my-1">
|
|
|
- <div class=" text-xs font-semibold mb-2">{$i18n.t('System Prompt')}</div>
|
|
|
+ <div class="my-1">
|
|
|
+ <div class=" text-xs font-semibold mb-2">{$i18n.t('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>
|
|
|
+ <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">
|
|
|
- {$i18n.t('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">{$i18n.t('Custom')}</span>
|
|
|
- {:else}
|
|
|
- <span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
|
|
- {/if}
|
|
|
- </button>
|
|
|
- </div>
|
|
|
+ <div class="flex w-full justify-between">
|
|
|
+ <div class=" self-center text-sm font-semibold">
|
|
|
+ {$i18n.t('Modelfile Advanced Settings')}
|
|
|
+ </div>
|
|
|
|
|
|
+ <button
|
|
|
+ class="p-1 px-3 text-xs flex rounded transition"
|
|
|
+ type="button"
|
|
|
+ on:click={() => {
|
|
|
+ advanced = !advanced;
|
|
|
+ }}
|
|
|
+ >
|
|
|
{#if advanced}
|
|
|
- <div class="my-2">
|
|
|
- <div class=" text-xs font-semibold mb-2">{$i18n.t('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">{$i18n.t('Parameters')}</div>
|
|
|
-
|
|
|
- <div>
|
|
|
- <AdvancedParams bind:options />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
|
|
+ {:else}
|
|
|
+ <span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
|
|
{/if}
|
|
|
- {/if}
|
|
|
+ </button>
|
|
|
</div>
|
|
|
|
|
|
- <div class="my-2">
|
|
|
- <div class="flex w-full justify-between mb-2">
|
|
|
- <div class=" self-center text-sm font-semibold">{$i18n.t('Prompt suggestions')}</div>
|
|
|
+ {#if advanced}
|
|
|
+ <div class="my-2">
|
|
|
+ <div class=" text-xs font-semibold mb-2">{$i18n.t('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">{$i18n.t('Parameters')}</div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <AdvancedParams 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">{$i18n.t('Prompt suggestions')}</div>
|
|
|
+
|
|
|
+ <button
|
|
|
+ class="p-1 px-3 text-xs flex rounded transition"
|
|
|
+ type="button"
|
|
|
+ on:click={() => {
|
|
|
+ if (suggestions.length === 0 || suggestions.at(-1).content !== '') {
|
|
|
+ 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={$i18n.t('Write a prompt suggestion (e.g. Who are you?)')}
|
|
|
+ bind:value={prompt.content}
|
|
|
+ />
|
|
|
|
|
|
<button
|
|
|
- class="p-1 px-3 text-xs flex rounded transition"
|
|
|
+ class="px-2"
|
|
|
type="button"
|
|
|
on:click={() => {
|
|
|
- if (suggestions.length === 0 || suggestions.at(-1).content !== '') {
|
|
|
- suggestions = [...suggestions, { content: '' }];
|
|
|
- }
|
|
|
+ suggestions.splice(promptIdx, 1);
|
|
|
+ suggestions = suggestions;
|
|
|
}}
|
|
|
>
|
|
|
<svg
|
|
@@ -614,114 +639,83 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
|
|
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"
|
|
|
+ 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 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={$i18n.t('Write a prompt suggestion (e.g. Who are you?)')}
|
|
|
- bind:value={prompt.content}
|
|
|
- />
|
|
|
+ {/each}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="my-2">
|
|
|
+ <div class=" text-sm font-semibold mb-2">{$i18n.t('Categories')}</div>
|
|
|
|
|
|
- <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 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 class="capitalize">{category}</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ {/each}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="my-2">
|
|
|
- <div class=" text-sm font-semibold mb-2">{$i18n.t('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 class="capitalize">{category}</div>
|
|
|
- </div>
|
|
|
- {/each}
|
|
|
+ {#if pullProgress !== null}
|
|
|
+ <div class="my-2">
|
|
|
+ <div class=" text-sm font-semibold mb-2">{$i18n.t('Pull Progress')}</div>
|
|
|
+ <div class="w-full rounded-full dark:bg-gray-800">
|
|
|
+ <div
|
|
|
+ class="dark:bg-gray-600 bg-gray-500 text-xs font-medium text-gray-100 text-center p-0.5 leading-none rounded-full"
|
|
|
+ style="width: {Math.max(15, pullProgress ?? 0)}%"
|
|
|
+ >
|
|
|
+ {pullProgress ?? 0}%
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
|
|
|
+ {digest}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ {/if}
|
|
|
|
|
|
- {#if pullProgress !== null}
|
|
|
- <div class="my-2">
|
|
|
- <div class=" text-sm font-semibold mb-2">{$i18n.t('Pull Progress')}</div>
|
|
|
- <div class="w-full rounded-full dark:bg-gray-800">
|
|
|
- <div
|
|
|
- class="dark:bg-gray-600 bg-gray-500 text-xs font-medium text-gray-100 text-center p-0.5 leading-none rounded-full"
|
|
|
- style="width: {Math.max(15, pullProgress ?? 0)}%"
|
|
|
- >
|
|
|
- {pullProgress ?? 0}%
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
|
|
|
- {digest}
|
|
|
- </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">{$i18n.t('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}
|
|
|
-
|
|
|
- <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">{$i18n.t('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>
|
|
|
+ </button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </form>
|
|
|
</div>
|