mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-16 07:35:56 +08:00
refac: styling
This commit is contained in:
parent
aaaef3efd8
commit
13019acce6
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { onMount, tick, getContext } from 'svelte';
|
import { onMount, tick, getContext } from 'svelte';
|
||||||
import { modelfiles, settings, showSidebar } from '$lib/stores';
|
import { mobile, modelfiles, settings, showSidebar } from '$lib/stores';
|
||||||
import { blobToFile, calculateSHA256, findWordIndices } from '$lib/utils';
|
import { blobToFile, calculateSHA256, findWordIndices } from '$lib/utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -765,7 +765,7 @@
|
|||||||
bind:value={prompt}
|
bind:value={prompt}
|
||||||
on:keypress={(e) => {
|
on:keypress={(e) => {
|
||||||
if (
|
if (
|
||||||
window.innerWidth > 1024 ||
|
!$mobile ||
|
||||||
!(
|
!(
|
||||||
'ontouchstart' in window ||
|
'ontouchstart' in window ||
|
||||||
navigator.maxTouchPoints > 0 ||
|
navigator.maxTouchPoints > 0 ||
|
||||||
|
@ -252,6 +252,10 @@
|
|||||||
const newChatButton = document.getElementById('new-chat-button');
|
const newChatButton = document.getElementById('new-chat-button');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
newChatButton?.click();
|
newChatButton?.click();
|
||||||
|
|
||||||
|
if ($mobile) {
|
||||||
|
showSidebar.set(false);
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -380,7 +384,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if $tags.length > 0}
|
{#if $tags.length > 0}
|
||||||
<div class="px-2.5 mb-2 flex gap-0.5 flex-wrap">
|
<div class="px-2.5 mb-2 flex gap-1 flex-wrap">
|
||||||
<button
|
<button
|
||||||
class="px-2.5 text-xs font-medium bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800 transition rounded-full"
|
class="px-2.5 text-xs font-medium bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800 transition rounded-full"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
@ -462,7 +466,7 @@
|
|||||||
href="/c/{chat.id}"
|
href="/c/{chat.id}"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
selectedChatId = chat.id;
|
selectedChatId = chat.id;
|
||||||
if (window.innerWidth < 1024) {
|
if ($mobile) {
|
||||||
showSidebar.set(false);
|
showSidebar.set(false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
<div class=" text-lg font-semibold mb-3">{$i18n.t('Modelfiles')}</div>
|
<div class=" text-lg font-semibold mb-3">{$i18n.t('Modelfiles')}</div>
|
||||||
|
|
||||||
<a class=" flex space-x-4 cursor-pointer w-full mb-2 px-3 py-2" href="/modelfiles/create">
|
<a class=" flex space-x-4 cursor-pointer w-full mb-2 px-3 py-2" href="/workspace/modelfiles/create">
|
||||||
<div class=" self-center w-10">
|
<div class=" self-center w-10">
|
||||||
<div
|
<div
|
||||||
class="w-full h-10 flex justify-center rounded-full bg-transparent dark:bg-gray-700 border border-dashed border-gray-200"
|
class="w-full h-10 flex justify-center rounded-full bg-transparent dark:bg-gray-700 border border-dashed border-gray-200"
|
||||||
@ -135,7 +135,7 @@
|
|||||||
<a
|
<a
|
||||||
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
type="button"
|
type="button"
|
||||||
href={`/modelfiles/edit?tag=${encodeURIComponent(modelfile.tagName)}`}
|
href={`/workspace/modelfiles/edit?tag=${encodeURIComponent(modelfile.tagName)}`}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@ -159,7 +159,7 @@
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
// console.log(modelfile);
|
// console.log(modelfile);
|
||||||
sessionStorage.modelfile = JSON.stringify(modelfile);
|
sessionStorage.modelfile = JSON.stringify(modelfile);
|
||||||
goto('/modelfiles/create');
|
goto('/workspace/modelfiles/create');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
|
@ -74,7 +74,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<a
|
<a
|
||||||
class=" px-2 py-2 rounded-xl border border-gray-200 dark:border-gray-600 dark:border-0 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 transition font-medium text-sm flex items-center space-x-1"
|
class=" px-2 py-2 rounded-xl border border-gray-200 dark:border-gray-600 dark:border-0 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 transition font-medium text-sm flex items-center space-x-1"
|
||||||
href="/prompts/create"
|
href="/workspace/prompts/create"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@ -97,7 +97,7 @@
|
|||||||
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl"
|
class=" flex space-x-4 cursor-pointer w-full px-3 py-2 dark:hover:bg-white/5 hover:bg-black/5 rounded-xl"
|
||||||
>
|
>
|
||||||
<div class=" flex flex-1 space-x-4 cursor-pointer w-full">
|
<div class=" flex flex-1 space-x-4 cursor-pointer w-full">
|
||||||
<a href={`/prompts/edit?command=${encodeURIComponent(prompt.command)}`}>
|
<a href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}>
|
||||||
<div class=" flex-1 self-center pl-5">
|
<div class=" flex-1 self-center pl-5">
|
||||||
<div class=" font-bold">{prompt.command}</div>
|
<div class=" font-bold">{prompt.command}</div>
|
||||||
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
<div class=" text-xs overflow-hidden text-ellipsis line-clamp-1">
|
||||||
@ -110,7 +110,7 @@
|
|||||||
<a
|
<a
|
||||||
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
|
||||||
type="button"
|
type="button"
|
||||||
href={`/prompts/edit?command=${encodeURIComponent(prompt.command)}`}
|
href={`/workspace/prompts/edit?command=${encodeURIComponent(prompt.command)}`}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@ -134,7 +134,7 @@
|
|||||||
on:click={() => {
|
on:click={() => {
|
||||||
// console.log(modelfile);
|
// console.log(modelfile);
|
||||||
sessionStorage.prompt = JSON.stringify(prompt);
|
sessionStorage.prompt = JSON.stringify(prompt);
|
||||||
goto('/prompts/create');
|
goto('/workspace/prompts/create');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class=" flex flex-col w-full min-h-screen">
|
<div class=" flex flex-col w-full min-h-screen max-h-screen">
|
||||||
<div class=" px-4 pt-3 mt-0.5 mb-1">
|
<div class=" px-4 pt-3 mt-0.5 mb-1">
|
||||||
<div class=" flex items-center gap-1">
|
<div class=" flex items-center gap-1">
|
||||||
<div class="{$showSidebar ? 'md:hidden' : ''} mr-1 self-start flex flex-none items-center">
|
<div class="{$showSidebar ? 'md:hidden' : ''} mr-1 self-start flex flex-none items-center">
|
||||||
@ -39,21 +39,21 @@
|
|||||||
class="flex scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-xl bg-transparent/10 p-1"
|
class="flex scrollbar-none overflow-x-auto w-fit text-center text-sm font-medium rounded-xl bg-transparent/10 p-1"
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname === '/workspace/modelfiles'
|
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/modelfiles')
|
||||||
? 'bg-gray-50 dark:bg-gray-850'
|
? 'bg-gray-50 dark:bg-gray-850'
|
||||||
: ''} transition"
|
: ''} transition"
|
||||||
href="/workspace/modelfiles">{$i18n.t('Modelfiles')}</a
|
href="/workspace/modelfiles">{$i18n.t('Modelfiles')}</a
|
||||||
>
|
>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname === '/workspace/prompts'
|
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/prompts')
|
||||||
? 'bg-gray-50 dark:bg-gray-850'
|
? 'bg-gray-50 dark:bg-gray-850'
|
||||||
: ''} transition"
|
: ''} transition"
|
||||||
href="/workspace/prompts">{$i18n.t('Prompts')}</a
|
href="/workspace/prompts">{$i18n.t('Prompts')}</a
|
||||||
>
|
>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname === '/workspace/documents'
|
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/documents')
|
||||||
? 'bg-gray-50 dark:bg-gray-850'
|
? 'bg-gray-50 dark:bg-gray-850'
|
||||||
: ''} transition"
|
: ''} transition"
|
||||||
href="/workspace/documents"
|
href="/workspace/documents"
|
||||||
@ -62,7 +62,7 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname === '/workspace/playground'
|
class="min-w-fit rounded-lg p-1.5 px-3 {$page.url.pathname.includes('/workspace/playground')
|
||||||
? 'bg-gray-50 dark:bg-gray-850'
|
? 'bg-gray-50 dark:bg-gray-850'
|
||||||
: ''} transition"
|
: ''} transition"
|
||||||
href="/workspace/playground">{$i18n.t('Playground')}</a
|
href="/workspace/playground">{$i18n.t('Playground')}</a
|
||||||
@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
<hr class=" my-2 dark:border-gray-850" />
|
<hr class=" my-2 dark:border-gray-850" />
|
||||||
|
|
||||||
<div class=" py-1 px-5 h-full">
|
<div class=" py-1 px-5 flex-1 max-h-full overflow-y-auto">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -204,7 +204,7 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
|||||||
categories: Object.keys(categories).filter((category) => categories[category]),
|
categories: Object.keys(categories).filter((category) => categories[category]),
|
||||||
user: modelfileCreator !== null ? modelfileCreator : undefined
|
user: modelfileCreator !== null ? modelfileCreator : undefined
|
||||||
});
|
});
|
||||||
await goto('/modelfiles');
|
await goto('/workspace/modelfiles');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loading = false;
|
loading = false;
|
||||||
@ -283,83 +283,326 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
|
<div class="w-full max-h-full">
|
||||||
<div class=" flex flex-col justify-between w-full overflow-y-auto">
|
<input
|
||||||
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
|
bind:this={filesInputElement}
|
||||||
<input
|
bind:files={inputFiles}
|
||||||
bind:this={filesInputElement}
|
type="file"
|
||||||
bind:files={inputFiles}
|
hidden
|
||||||
type="file"
|
accept="image/*"
|
||||||
hidden
|
on:change={() => {
|
||||||
accept="image/*"
|
let reader = new FileReader();
|
||||||
on:change={() => {
|
reader.onload = (event) => {
|
||||||
let reader = new FileReader();
|
let originalImageUrl = `${event.target.result}`;
|
||||||
reader.onload = (event) => {
|
|
||||||
let originalImageUrl = `${event.target.result}`;
|
|
||||||
|
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.src = originalImageUrl;
|
img.src = originalImageUrl;
|
||||||
|
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
// Calculate the aspect ratio of the image
|
// Calculate the aspect ratio of the image
|
||||||
const aspectRatio = img.width / img.height;
|
const aspectRatio = img.width / img.height;
|
||||||
|
|
||||||
// Calculate the new width and height to fit within 100x100
|
// Calculate the new width and height to fit within 100x100
|
||||||
let newWidth, newHeight;
|
let newWidth, newHeight;
|
||||||
if (aspectRatio > 1) {
|
if (aspectRatio > 1) {
|
||||||
newWidth = 100 * aspectRatio;
|
newWidth = 100 * aspectRatio;
|
||||||
newHeight = 100;
|
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;
|
|
||||||
|
|
||||||
// Draw the image on the canvas
|
|
||||||
ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight);
|
|
||||||
|
|
||||||
// Get the base64 representation of the compressed image
|
|
||||||
const compressedSrc = canvas.toDataURL('image/jpeg');
|
|
||||||
|
|
||||||
// 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 {
|
} else {
|
||||||
console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`);
|
newWidth = 100;
|
||||||
inputFiles = null;
|
newHeight = 100 / aspectRatio;
|
||||||
}
|
}
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class=" text-2xl font-semibold mb-6">{$i18n.t('My Modelfiles')}</div>
|
// Set the canvas size
|
||||||
|
canvas.width = 100;
|
||||||
|
canvas.height = 100;
|
||||||
|
|
||||||
<button
|
// Calculate the position to center the image
|
||||||
class="flex space-x-1"
|
const offsetX = (100 - newWidth) / 2;
|
||||||
on:click={() => {
|
const offsetY = (100 - newHeight) / 2;
|
||||||
history.back();
|
|
||||||
}}
|
// Draw the image on the canvas
|
||||||
|
ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight);
|
||||||
|
|
||||||
|
// Get the base64 representation of the compressed image
|
||||||
|
const compressedSrc = canvas.toDataURL('image/jpeg');
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<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">
|
<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"
|
||||||
|
/>
|
||||||
|
{: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 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 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="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 class=" text-sm font-semibold mb-2"></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="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 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>
|
||||||
|
|
||||||
|
{#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
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 20 20"
|
viewBox="0 0 20 20"
|
||||||
@ -367,244 +610,26 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
|||||||
class="w-4 h-4"
|
class="w-4 h-4"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
fill-rule="evenodd"
|
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="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>
|
</svg>
|
||||||
</div>
|
</button>
|
||||||
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
|
</div>
|
||||||
</button>
|
<div class="flex flex-col space-y-1">
|
||||||
<hr class="my-3 dark:border-gray-700" />
|
{#each suggestions as prompt, promptIdx}
|
||||||
|
<div class=" flex border dark:border-gray-600 rounded-lg">
|
||||||
<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 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 class="my-2">
|
|
||||||
<div class=" text-sm font-semibold mb-2">{$i18n.t('Description')}*</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input
|
<input
|
||||||
class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
|
class="px-3 py-1.5 text-sm w-full bg-transparent outline-none border-r dark:border-gray-600"
|
||||||
placeholder={$i18n.t('Add a short description about what this modelfile does')}
|
placeholder={$i18n.t('Write a prompt suggestion (e.g. Who are you?)')}
|
||||||
bind:value={desc}
|
bind:value={prompt.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>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="p-1 px-3 text-xs flex rounded transition"
|
class="px-2"
|
||||||
type="button"
|
type="button"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
raw = !raw;
|
suggestions.splice(promptIdx, 1);
|
||||||
}}
|
suggestions = suggestions;
|
||||||
>
|
|
||||||
{#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 class=" text-sm font-semibold mb-2"></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="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 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>
|
|
||||||
|
|
||||||
{#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
|
<svg
|
||||||
@ -614,114 +639,83 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
|||||||
class="w-4 h-4"
|
class="w-4 h-4"
|
||||||
>
|
>
|
||||||
<path
|
<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>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col space-y-1">
|
{/each}
|
||||||
{#each suggestions as prompt, promptIdx}
|
</div>
|
||||||
<div class=" flex border dark:border-gray-600 rounded-lg">
|
</div>
|
||||||
<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
|
<div class="my-2">
|
||||||
class="px-2"
|
<div class=" text-sm font-semibold mb-2">{$i18n.t('Categories')}</div>
|
||||||
type="button"
|
|
||||||
on:click={() => {
|
<div class="grid grid-cols-4">
|
||||||
suggestions.splice(promptIdx, 1);
|
{#each Object.keys(categories) as category}
|
||||||
suggestions = suggestions;
|
<div class="flex space-x-2 text-sm">
|
||||||
}}
|
<input type="checkbox" bind:checked={categories[category]} />
|
||||||
>
|
<div class="capitalize">{category}</div>
|
||||||
<svg
|
</div>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
{/each}
|
||||||
viewBox="0 0 20 20"
|
</div>
|
||||||
fill="currentColor"
|
</div>
|
||||||
class="w-4 h-4"
|
|
||||||
>
|
{#if pullProgress !== null}
|
||||||
<path
|
<div class="my-2">
|
||||||
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"
|
<div class=" text-sm font-semibold mb-2">{$i18n.t('Pull Progress')}</div>
|
||||||
/>
|
<div class="w-full rounded-full dark:bg-gray-800">
|
||||||
</svg>
|
<div
|
||||||
</button>
|
class="dark:bg-gray-600 bg-gray-500 text-xs font-medium text-gray-100 text-center p-0.5 leading-none rounded-full"
|
||||||
</div>
|
style="width: {Math.max(15, pullProgress ?? 0)}%"
|
||||||
{/each}
|
>
|
||||||
|
{pullProgress ?? 0}%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
|
||||||
<div class="my-2">
|
{digest}
|
||||||
<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}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if pullProgress !== null}
|
<div class="my-2 flex justify-end">
|
||||||
<div class="my-2">
|
<button
|
||||||
<div class=" text-sm font-semibold mb-2">{$i18n.t('Pull Progress')}</div>
|
class=" text-sm px-3 py-2 transition rounded-xl {loading
|
||||||
<div class="w-full rounded-full dark:bg-gray-800">
|
? ' cursor-not-allowed bg-gray-100 dark:bg-gray-800'
|
||||||
<div
|
: ' bg-gray-50 hover:bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-800'} flex"
|
||||||
class="dark:bg-gray-600 bg-gray-500 text-xs font-medium text-gray-100 text-center p-0.5 leading-none rounded-full"
|
type="submit"
|
||||||
style="width: {Math.max(15, pullProgress ?? 0)}%"
|
disabled={loading}
|
||||||
>
|
>
|
||||||
{pullProgress ?? 0}%
|
<div class=" self-center font-medium">{$i18n.t('Save & Create')}</div>
|
||||||
</div>
|
|
||||||
</div>
|
{#if loading}
|
||||||
<div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
|
<div class="ml-1.5 self-center">
|
||||||
{digest}
|
<svg
|
||||||
</div>
|
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>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
</button>
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
categories[category.toLowerCase()] = true;
|
categories[category.toLowerCase()] = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goto('/modelfiles');
|
goto('/workspace/modelfiles');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -174,7 +174,7 @@
|
|||||||
suggestionPrompts: suggestions.filter((prompt) => prompt.content !== ''),
|
suggestionPrompts: suggestions.filter((prompt) => prompt.content !== ''),
|
||||||
categories: Object.keys(categories).filter((category) => categories[category])
|
categories: Object.keys(categories).filter((category) => categories[category])
|
||||||
});
|
});
|
||||||
await goto('/modelfiles');
|
await goto('/workspace/modelfiles');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loading = false;
|
loading = false;
|
||||||
@ -182,83 +182,212 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
|
<div class="w-full max-h-full">
|
||||||
<div class="flex flex-col justify-between w-full overflow-y-auto">
|
<input
|
||||||
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
|
bind:this={filesInputElement}
|
||||||
<input
|
bind:files={inputFiles}
|
||||||
bind:this={filesInputElement}
|
type="file"
|
||||||
bind:files={inputFiles}
|
hidden
|
||||||
type="file"
|
accept="image/*"
|
||||||
hidden
|
on:change={() => {
|
||||||
accept="image/*"
|
let reader = new FileReader();
|
||||||
on:change={() => {
|
reader.onload = (event) => {
|
||||||
let reader = new FileReader();
|
let originalImageUrl = `${event.target.result}`;
|
||||||
reader.onload = (event) => {
|
|
||||||
let originalImageUrl = `${event.target.result}`;
|
|
||||||
|
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.src = originalImageUrl;
|
img.src = originalImageUrl;
|
||||||
|
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
// Calculate the aspect ratio of the image
|
// Calculate the aspect ratio of the image
|
||||||
const aspectRatio = img.width / img.height;
|
const aspectRatio = img.width / img.height;
|
||||||
|
|
||||||
// Calculate the new width and height to fit within 100x100
|
// Calculate the new width and height to fit within 100x100
|
||||||
let newWidth, newHeight;
|
let newWidth, newHeight;
|
||||||
if (aspectRatio > 1) {
|
if (aspectRatio > 1) {
|
||||||
newWidth = 100 * aspectRatio;
|
newWidth = 100 * aspectRatio;
|
||||||
newHeight = 100;
|
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;
|
|
||||||
|
|
||||||
// Draw the image on the canvas
|
|
||||||
ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight);
|
|
||||||
|
|
||||||
// Get the base64 representation of the compressed image
|
|
||||||
const compressedSrc = canvas.toDataURL('image/jpeg');
|
|
||||||
|
|
||||||
// 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 {
|
} else {
|
||||||
console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`);
|
newWidth = 100;
|
||||||
inputFiles = null;
|
newHeight = 100 / aspectRatio;
|
||||||
}
|
}
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class=" text-2xl font-semibold mb-6">{$i18n.t('My Modelfiles')}</div>
|
// Set the canvas size
|
||||||
|
canvas.width = 100;
|
||||||
|
canvas.height = 100;
|
||||||
|
|
||||||
<button
|
// Calculate the position to center the image
|
||||||
class="flex space-x-1"
|
const offsetX = (100 - newWidth) / 2;
|
||||||
on:click={() => {
|
const offsetY = (100 - newHeight) / 2;
|
||||||
history.back();
|
|
||||||
}}
|
// Draw the image on the canvas
|
||||||
|
ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight);
|
||||||
|
|
||||||
|
// Get the base64 representation of the compressed image
|
||||||
|
const compressedSrc = canvas.toDataURL('image/jpeg');
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<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">
|
<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>
|
||||||
|
<form
|
||||||
|
class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
|
||||||
|
on:submit|preventDefault={() => {
|
||||||
|
updateHandler();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<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 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 disabled:text-gray-500 border dark:border-gray-600 outline-none rounded-lg"
|
||||||
|
placeholder={$i18n.t('Add a model tag name')}
|
||||||
|
value={tagName}
|
||||||
|
disabled
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</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="my-2">
|
||||||
|
<div class="flex w-full justify-between">
|
||||||
|
<div class=" self-center text-sm font-semibold">{$i18n.t('Modelfile')}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class=" text-sm font-semibold mb-2"></div> -->
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</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
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 20 20"
|
viewBox="0 0 20 20"
|
||||||
@ -266,132 +395,26 @@
|
|||||||
class="w-4 h-4"
|
class="w-4 h-4"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
fill-rule="evenodd"
|
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="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>
|
</svg>
|
||||||
</div>
|
</button>
|
||||||
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
|
</div>
|
||||||
</button>
|
<div class="flex flex-col space-y-1">
|
||||||
<hr class="my-3 dark:border-gray-700" />
|
{#each suggestions as prompt, promptIdx}
|
||||||
|
<div class=" flex border dark:border-gray-600 rounded-lg">
|
||||||
<form
|
|
||||||
class="flex flex-col"
|
|
||||||
on:submit|preventDefault={() => {
|
|
||||||
updateHandler();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<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 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 disabled:text-gray-500 border dark:border-gray-600 outline-none rounded-lg"
|
|
||||||
placeholder={$i18n.t('Add a model tag name')}
|
|
||||||
value={tagName}
|
|
||||||
disabled
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-2">
|
|
||||||
<div class=" text-sm font-semibold mb-2">{$i18n.t('Description')}*</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input
|
<input
|
||||||
class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-lg"
|
class="px-3 py-1.5 text-sm w-full bg-transparent outline-none border-r dark:border-gray-600"
|
||||||
placeholder={$i18n.t('Add a short description about what this modelfile does')}
|
placeholder={$i18n.t('Write a prompt suggestion (e.g. Who are you?)')}
|
||||||
bind:value={desc}
|
bind:value={prompt.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>
|
|
||||||
|
|
||||||
<!-- <div class=" text-sm font-semibold mb-2"></div> -->
|
|
||||||
|
|
||||||
<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>
|
|
||||||
</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
|
<button
|
||||||
class="p-1 px-3 text-xs flex rounded transition"
|
class="px-2"
|
||||||
type="button"
|
type="button"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
if (suggestions.length === 0 || suggestions.at(-1).content !== '') {
|
suggestions.splice(promptIdx, 1);
|
||||||
suggestions = [...suggestions, { content: '' }];
|
suggestions = suggestions;
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
@ -401,115 +424,84 @@
|
|||||||
class="w-4 h-4"
|
class="w-4 h-4"
|
||||||
>
|
>
|
||||||
<path
|
<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>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col space-y-1">
|
{/each}
|
||||||
{#each suggestions as prompt, promptIdx}
|
</div>
|
||||||
<div class=" flex border dark:border-gray-600 rounded-lg">
|
</div>
|
||||||
<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
|
<div class="my-2">
|
||||||
class="px-2"
|
<div class=" text-sm font-semibold mb-2">{$i18n.t('Categories')}</div>
|
||||||
type="button"
|
|
||||||
on:click={() => {
|
<div class="grid grid-cols-4">
|
||||||
suggestions.splice(promptIdx, 1);
|
{#each Object.keys(categories) as category}
|
||||||
suggestions = suggestions;
|
<div class="flex space-x-2 text-sm">
|
||||||
}}
|
<input type="checkbox" bind:checked={categories[category]} />
|
||||||
>
|
|
||||||
<svg
|
<div class=" capitalize">{category}</div>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
</div>
|
||||||
viewBox="0 0 20 20"
|
{/each}
|
||||||
fill="currentColor"
|
</div>
|
||||||
class="w-4 h-4"
|
</div>
|
||||||
>
|
|
||||||
<path
|
{#if pullProgress !== null}
|
||||||
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"
|
<div class="my-2">
|
||||||
/>
|
<div class=" text-sm font-semibold mb-2">{$i18n.t('Pull Progress')}</div>
|
||||||
</svg>
|
<div class="w-full rounded-full dark:bg-gray-800">
|
||||||
</button>
|
<div
|
||||||
</div>
|
class="dark:bg-gray-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full"
|
||||||
{/each}
|
style="width: {Math.max(15, pullProgress ?? 0)}%"
|
||||||
|
>
|
||||||
|
{pullProgress ?? 0}%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
|
||||||
<div class="my-2">
|
{digest}
|
||||||
<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}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if pullProgress !== null}
|
<div class="my-2 flex justify-end">
|
||||||
<div class="my-2">
|
<button
|
||||||
<div class=" text-sm font-semibold mb-2">{$i18n.t('Pull Progress')}</div>
|
class=" text-sm px-3 py-2 transition rounded-xl {loading
|
||||||
<div class="w-full rounded-full dark:bg-gray-800">
|
? ' cursor-not-allowed bg-gray-100 dark:bg-gray-800'
|
||||||
<div
|
: ' bg-gray-50 hover:bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-800'} flex"
|
||||||
class="dark:bg-gray-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full"
|
type="submit"
|
||||||
style="width: {Math.max(15, pullProgress ?? 0)}%"
|
disabled={loading}
|
||||||
>
|
>
|
||||||
{pullProgress ?? 0}%
|
<div class=" self-center font-medium">{$i18n.t('Save & Update')}</div>
|
||||||
</div>
|
|
||||||
</div>
|
{#if loading}
|
||||||
<div class="mt-1 text-xs dark:text-gray-500" style="font-size: 0.5rem;">
|
<div class="ml-1.5 self-center">
|
||||||
{digest}
|
<svg
|
||||||
</div>
|
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>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
</button>
|
||||||
<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 & Update')}</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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
if (prompt) {
|
if (prompt) {
|
||||||
await prompts.set(await getPrompts(localStorage.token));
|
await prompts.set(await getPrompts(localStorage.token));
|
||||||
await goto('/prompts');
|
await goto('/workspace/prompts');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toast.error(
|
toast.error(
|
||||||
@ -93,162 +93,153 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
|
<div class="w-full max-h-full">
|
||||||
<div class=" flex flex-col justify-between w-full overflow-y-auto">
|
<button
|
||||||
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
|
class="flex space-x-1"
|
||||||
<div class=" text-2xl font-semibold mb-6">{$i18n.t('My Prompts')}</div>
|
on:click={() => {
|
||||||
|
history.back();
|
||||||
<button
|
}}
|
||||||
class="flex space-x-1"
|
>
|
||||||
on:click={() => {
|
<div class=" self-center">
|
||||||
history.back();
|
<svg
|
||||||
}}
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
>
|
>
|
||||||
<div class=" self-center">
|
<path
|
||||||
<svg
|
fill-rule="evenodd"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
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"
|
||||||
viewBox="0 0 20 20"
|
clip-rule="evenodd"
|
||||||
fill="currentColor"
|
/>
|
||||||
class="w-4 h-4"
|
</svg>
|
||||||
>
|
|
||||||
<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"
|
|
||||||
on:submit|preventDefault={() => {
|
|
||||||
submitHandler();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="my-2">
|
|
||||||
<div class=" text-sm font-semibold mb-2">{$i18n.t('Title')}*</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 title for this prompt')}
|
|
||||||
bind:value={title}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-2">
|
|
||||||
<div class=" text-sm font-semibold mb-2">{$i18n.t('Command')}*</div>
|
|
||||||
|
|
||||||
<div class="flex items-center mb-1">
|
|
||||||
<div
|
|
||||||
class="bg-gray-200 dark:bg-gray-600 font-bold px-3 py-1 border border-r-0 dark:border-gray-600 rounded-l-lg"
|
|
||||||
>
|
|
||||||
/
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-r-lg"
|
|
||||||
placeholder={$i18n.t('short-summary')}
|
|
||||||
bind:value={command}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
|
||||||
{$i18n.t('Only')}
|
|
||||||
<span class=" text-gray-600 dark:text-gray-300 font-medium"
|
|
||||||
>{$i18n.t('alphanumeric characters and hyphens')}</span
|
|
||||||
>
|
|
||||||
{$i18n.t('are allowed - Activate this command by typing')} "<span
|
|
||||||
class=" text-gray-600 dark:text-gray-300 font-medium"
|
|
||||||
>
|
|
||||||
/{command}
|
|
||||||
</span>"
|
|
||||||
{$i18n.t('to chat input.')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-2">
|
|
||||||
<div class="flex w-full justify-between">
|
|
||||||
<div class=" self-center text-sm font-semibold">{$i18n.t('Prompt Content')}*</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-2">
|
|
||||||
<div>
|
|
||||||
<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(
|
|
||||||
'Write a summary in 50 words that summarizes [topic or keyword].'
|
|
||||||
)}
|
|
||||||
rows="6"
|
|
||||||
bind:value={content}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
|
||||||
ⓘ {$i18n.t('Format your variables using square brackets like this:')} <span
|
|
||||||
class=" text-gray-600 dark:text-gray-300 font-medium">[{$i18n.t('variable')}]</span
|
|
||||||
>.
|
|
||||||
{$i18n.t('Make sure to enclose them with')}
|
|
||||||
<span class=" text-gray-600 dark:text-gray-300 font-medium">'['</span>
|
|
||||||
{$i18n.t('and')}
|
|
||||||
<span class=" text-gray-600 dark:text-gray-300 font-medium">']'</span>.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
|
||||||
{$i18n.t('Utilize')}<span class=" text-gray-600 dark:text-gray-300 font-medium">
|
|
||||||
{` {{CLIPBOARD}}`}</span
|
|
||||||
>
|
|
||||||
{$i18n.t('variable to have them replaced with clipboard content.')}
|
|
||||||
</div>
|
|
||||||
</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">{$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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
|
||||||
|
on:submit|preventDefault={() => {
|
||||||
|
submitHandler();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="my-2">
|
||||||
|
<div class=" text-sm font-semibold mb-2">{$i18n.t('Title')}*</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 title for this prompt')}
|
||||||
|
bind:value={title}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-2">
|
||||||
|
<div class=" text-sm font-semibold mb-2">{$i18n.t('Command')}*</div>
|
||||||
|
|
||||||
|
<div class="flex items-center mb-1">
|
||||||
|
<div
|
||||||
|
class="bg-gray-200 dark:bg-gray-600 font-bold px-3 py-1 border border-r-0 dark:border-gray-600 rounded-l-lg"
|
||||||
|
>
|
||||||
|
/
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
class="px-3 py-1.5 text-sm w-full bg-transparent border dark:border-gray-600 outline-none rounded-r-lg"
|
||||||
|
placeholder={$i18n.t('short-summary')}
|
||||||
|
bind:value={command}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||||
|
{$i18n.t('Only')}
|
||||||
|
<span class=" text-gray-600 dark:text-gray-300 font-medium"
|
||||||
|
>{$i18n.t('alphanumeric characters and hyphens')}</span
|
||||||
|
>
|
||||||
|
{$i18n.t('are allowed - Activate this command by typing')} "<span
|
||||||
|
class=" text-gray-600 dark:text-gray-300 font-medium"
|
||||||
|
>
|
||||||
|
/{command}
|
||||||
|
</span>"
|
||||||
|
{$i18n.t('to chat input.')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-2">
|
||||||
|
<div class="flex w-full justify-between">
|
||||||
|
<div class=" self-center text-sm font-semibold">{$i18n.t('Prompt Content')}*</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-2">
|
||||||
|
<div>
|
||||||
|
<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('Write a summary in 50 words that summarizes [topic or keyword].')}
|
||||||
|
rows="6"
|
||||||
|
bind:value={content}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||||
|
ⓘ {$i18n.t('Format your variables using square brackets like this:')} <span
|
||||||
|
class=" text-gray-600 dark:text-gray-300 font-medium">[{$i18n.t('variable')}]</span
|
||||||
|
>.
|
||||||
|
{$i18n.t('Make sure to enclose them with')}
|
||||||
|
<span class=" text-gray-600 dark:text-gray-300 font-medium">'['</span>
|
||||||
|
{$i18n.t('and')}
|
||||||
|
<span class=" text-gray-600 dark:text-gray-300 font-medium">']'</span>.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||||
|
{$i18n.t('Utilize')}<span class=" text-gray-600 dark:text-gray-300 font-medium">
|
||||||
|
{` {{CLIPBOARD}}`}</span
|
||||||
|
>
|
||||||
|
{$i18n.t('variable to have them replaced with clipboard content.')}
|
||||||
|
</div>
|
||||||
|
</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">{$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>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
if (prompt) {
|
if (prompt) {
|
||||||
await prompts.set(await getPrompts(localStorage.token));
|
await prompts.set(await getPrompts(localStorage.token));
|
||||||
await goto('/prompts');
|
await goto('/workspace/prompts');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toast.error(
|
toast.error(
|
||||||
@ -67,171 +67,162 @@
|
|||||||
command = prompt.command.slice(1);
|
command = prompt.command.slice(1);
|
||||||
content = prompt.content;
|
content = prompt.content;
|
||||||
} else {
|
} else {
|
||||||
goto('/prompts');
|
goto('/workspace/prompts');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
goto('/prompts');
|
goto('/workspace/prompts');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
|
<div class="w-full max-h-full">
|
||||||
<div class="flex flex-col justify-between w-full overflow-y-auto">
|
<button
|
||||||
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
|
class="flex space-x-1"
|
||||||
<div class=" text-2xl font-semibold mb-6">{$i18n.t('My Prompts')}</div>
|
on:click={() => {
|
||||||
|
history.back();
|
||||||
<button
|
}}
|
||||||
class="flex space-x-1"
|
>
|
||||||
on:click={() => {
|
<div class=" self-center">
|
||||||
history.back();
|
<svg
|
||||||
}}
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
>
|
>
|
||||||
<div class=" self-center">
|
<path
|
||||||
<svg
|
fill-rule="evenodd"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
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"
|
||||||
viewBox="0 0 20 20"
|
clip-rule="evenodd"
|
||||||
fill="currentColor"
|
/>
|
||||||
class="w-4 h-4"
|
</svg>
|
||||||
>
|
|
||||||
<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"
|
|
||||||
on:submit|preventDefault={() => {
|
|
||||||
updateHandler();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="my-2">
|
|
||||||
<div class=" text-sm font-semibold mb-2">{$i18n.t('Title')}*</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 title for this prompt')}
|
|
||||||
bind:value={title}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-2">
|
|
||||||
<div class=" text-sm font-semibold mb-2">{$i18n.t('Command')}*</div>
|
|
||||||
|
|
||||||
<div class="flex items-center mb-1">
|
|
||||||
<div
|
|
||||||
class="bg-gray-200 dark:bg-gray-600 font-bold px-3 py-1 border border-r-0 dark:border-gray-600 rounded-l-lg"
|
|
||||||
>
|
|
||||||
/
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
class="px-3 py-1.5 text-sm w-full bg-transparent border disabled:text-gray-500 dark:border-gray-600 outline-none rounded-r-lg"
|
|
||||||
placeholder="short-summary"
|
|
||||||
bind:value={command}
|
|
||||||
disabled
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
|
||||||
{$i18n.t('Only')}
|
|
||||||
<span class=" text-gray-600 dark:text-gray-300 font-medium"
|
|
||||||
>{$i18n.t('alphanumeric characters and hyphens')}</span
|
|
||||||
>
|
|
||||||
{$i18n.t('are allowed - Activate this command by typing')} "<span
|
|
||||||
class=" text-gray-600 dark:text-gray-300 font-medium"
|
|
||||||
>
|
|
||||||
/{command}
|
|
||||||
</span>"
|
|
||||||
{$i18n.t('to chat input.')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="my-2">
|
|
||||||
<div class="flex w-full justify-between">
|
|
||||||
<div class=" self-center text-sm font-semibold">{$i18n.t('Prompt Content')}*</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-2">
|
|
||||||
<div>
|
|
||||||
<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(
|
|
||||||
`Write a summary in 50 words that summarizes [topic or keyword].`
|
|
||||||
)}
|
|
||||||
rows="6"
|
|
||||||
bind:value={content}
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
|
||||||
ⓘ {$i18n.t('Format your variables using square brackets like this:')} <span
|
|
||||||
class=" text-gray-600 dark:text-gray-300 font-medium">[{$i18n.t('variable')}]</span
|
|
||||||
>.
|
|
||||||
{$i18n.t('Make sure to enclose them with')}
|
|
||||||
<span class=" text-gray-600 dark:text-gray-300 font-medium">'['</span>
|
|
||||||
{$i18n.t('and')}
|
|
||||||
<span class=" text-gray-600 dark:text-gray-300 font-medium">']'</span>.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
|
||||||
{$i18n.t('Utilize')}<span class=" text-gray-600 dark:text-gray-300 font-medium">
|
|
||||||
{` {{CLIPBOARD}}`}</span
|
|
||||||
>
|
|
||||||
{$i18n.t('variable to have them replaced with clipboard content.')}
|
|
||||||
</div>
|
|
||||||
</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">{$i18n.t('Save & Update')}</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>
|
<div class=" self-center font-medium text-sm">{$i18n.t('Back')}</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="flex flex-col max-w-2xl mx-auto mt-4 mb-10"
|
||||||
|
on:submit|preventDefault={() => {
|
||||||
|
updateHandler();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div class="my-2">
|
||||||
|
<div class=" text-sm font-semibold mb-2">{$i18n.t('Title')}*</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 title for this prompt')}
|
||||||
|
bind:value={title}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-2">
|
||||||
|
<div class=" text-sm font-semibold mb-2">{$i18n.t('Command')}*</div>
|
||||||
|
|
||||||
|
<div class="flex items-center mb-1">
|
||||||
|
<div
|
||||||
|
class="bg-gray-200 dark:bg-gray-600 font-bold px-3 py-1 border border-r-0 dark:border-gray-600 rounded-l-lg"
|
||||||
|
>
|
||||||
|
/
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
class="px-3 py-1.5 text-sm w-full bg-transparent border disabled:text-gray-500 dark:border-gray-600 outline-none rounded-r-lg"
|
||||||
|
placeholder="short-summary"
|
||||||
|
bind:value={command}
|
||||||
|
disabled
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||||
|
{$i18n.t('Only')}
|
||||||
|
<span class=" text-gray-600 dark:text-gray-300 font-medium"
|
||||||
|
>{$i18n.t('alphanumeric characters and hyphens')}</span
|
||||||
|
>
|
||||||
|
{$i18n.t('are allowed - Activate this command by typing')} "<span
|
||||||
|
class=" text-gray-600 dark:text-gray-300 font-medium"
|
||||||
|
>
|
||||||
|
/{command}
|
||||||
|
</span>"
|
||||||
|
{$i18n.t('to chat input.')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="my-2">
|
||||||
|
<div class="flex w-full justify-between">
|
||||||
|
<div class=" self-center text-sm font-semibold">{$i18n.t('Prompt Content')}*</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-2">
|
||||||
|
<div>
|
||||||
|
<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(`Write a summary in 50 words that summarizes [topic or keyword].`)}
|
||||||
|
rows="6"
|
||||||
|
bind:value={content}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||||
|
ⓘ {$i18n.t('Format your variables using square brackets like this:')} <span
|
||||||
|
class=" text-gray-600 dark:text-gray-300 font-medium">[{$i18n.t('variable')}]</span
|
||||||
|
>.
|
||||||
|
{$i18n.t('Make sure to enclose them with')}
|
||||||
|
<span class=" text-gray-600 dark:text-gray-300 font-medium">'['</span>
|
||||||
|
{$i18n.t('and')}
|
||||||
|
<span class=" text-gray-600 dark:text-gray-300 font-medium">']'</span>.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||||
|
{$i18n.t('Utilize')}<span class=" text-gray-600 dark:text-gray-300 font-medium">
|
||||||
|
{` {{CLIPBOARD}}`}</span
|
||||||
|
>
|
||||||
|
{$i18n.t('variable to have them replaced with clipboard content.')}
|
||||||
|
</div>
|
||||||
|
</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">{$i18n.t('Save & Update')}</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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user