From 45ff3ae2048784705ff576024e1e1a042a7d5c69 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 2 Dec 2023 16:05:01 -0800 Subject: [PATCH] feat: modelfile builder --- .../components/chat/Settings/Advanced.svelte | 24 +- src/lib/components/layout/Sidebar.svelte | 181 +++---- src/lib/constants.ts | 4 +- src/routes/(app)/modelfiles/+page.svelte | 61 +++ .../(app)/modelfiles/create/+page.svelte | 475 ++++++++++++++++++ 5 files changed, 640 insertions(+), 105 deletions(-) create mode 100644 src/routes/(app)/modelfiles/+page.svelte create mode 100644 src/routes/(app)/modelfiles/create/+page.svelte diff --git a/src/lib/components/chat/Settings/Advanced.svelte b/src/lib/components/chat/Settings/Advanced.svelte index b65ab3be..e83c48db 100644 --- a/src/lib/components/chat/Settings/Advanced.svelte +++ b/src/lib/components/chat/Settings/Advanced.svelte @@ -22,7 +22,7 @@
Seed
Stop Sequence
@@ -127,7 +127,7 @@ @@ -170,7 +170,7 @@ @@ -213,7 +213,7 @@ @@ -256,7 +256,7 @@ @@ -299,7 +299,7 @@ @@ -342,7 +342,7 @@ @@ -385,7 +385,7 @@ @@ -428,7 +428,7 @@ @@ -471,7 +471,7 @@ diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 656d3f45..bb54dbc1 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -24,7 +24,7 @@ let showDropdown = false; - let showDeleteHistoryConfirm = false; + let showDeleteHistoryConfirm = false; onMount(async () => { if (window.innerWidth > 1280) { @@ -121,11 +121,11 @@ - +
@@ -449,91 +449,92 @@
Export
- {#if showDeleteHistoryConfirm} -
-
- - - - Are you sure? -
- -
- - -
-
- {:else} - - {/if} + {#if showDeleteHistoryConfirm} +
+
+ + + + Are you sure? +
+ +
+ + +
+
+ {:else} + + {/if} {#if $user !== undefined}
diff --git a/src/routes/(app)/modelfiles/create/+page.svelte b/src/routes/(app)/modelfiles/create/+page.svelte new file mode 100644 index 00000000..3a2e60fc --- /dev/null +++ b/src/routes/(app)/modelfiles/create/+page.svelte @@ -0,0 +1,475 @@ + + +
+
+
+ { + let reader = new FileReader(); + reader.onload = (event) => { + let originalImageUrl = `${event.target.result}`; + + const img = new Image(); + img.src = originalImageUrl; + + img.onload = function () { + const canvas = document.createElement('canvas'); + const ctx = canvas.getContext('2d'); + + // Set canvas dimensions to the original image dimensions + canvas.width = img.width; + canvas.height = img.height; + + // Draw the original image on the canvas + ctx.drawImage(img, 0, 0); + + // Get the base64 representation of the compressed image + const compressedSrc = canvas.toDataURL('image/jpeg', 0.1); + + // Display the compressed image + imageUrl = compressedSrc; + + inputFiles = null; + }; + }; + + if ( + inputFiles && + inputFiles.length > 0 && + ['image/gif', 'image/jpeg', 'image/png'].includes(inputFiles[0]['type']) + ) { + reader.readAsDataURL(inputFiles[0]); + } else { + console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`); + inputFiles = null; + } + }} + /> + +
My Modelfiles
+ + +
+ +
{ + submitHandler(); + }} + > +
+
+ +
+
+ +
+
Name*
+ +
+ +
+
+ +
+
Description*
+ +
+ +
+
+ +
+
+
Modelfile
+ + +
+ + + + {#if raw} +
+
Content*
+ +
+