diff --git a/.env b/.env index 421fce63526..c14a1ae41b9 100644 --- a/.env +++ b/.env @@ -129,6 +129,4 @@ EXPOSE_API=true # PUBLIC_APP_DATA_SHARING=1 # PUBLIC_APP_DISCLAIMER=1 -ENABLE_ASSISTANTS=false #set to true to enable assistants feature -ASSISTANTS_GENERATE_AVATAR=true #requires an hf token, uses the model description and name to generate an avatar using a text to image model -TEXT_TO_IMAGE_MODEL="runwayml/stable-diffusion-v1-5" +ENABLE_ASSISTANTS=false #set to true to enable assistants feature \ No newline at end of file diff --git a/src/lib/components/AssistantSettings.svelte b/src/lib/components/AssistantSettings.svelte index 6511ee7bee0..85394e8d6cf 100644 --- a/src/lib/components/AssistantSettings.svelte +++ b/src/lib/components/AssistantSettings.svelte @@ -7,8 +7,8 @@ import { applyAction, enhance } from "$app/forms"; import { base } from "$app/paths"; import CarbonPen from "~icons/carbon/pen"; + import CarbonUpload from "~icons/carbon/upload"; import { useSettingsStore } from "$lib/stores/settings"; - import { page } from "$app/stores"; import IconLoading from "./icons/IconLoading.svelte"; type ActionData = { @@ -41,10 +41,19 @@ let inputMessage3 = assistant?.exampleInputs[2] ?? ""; let inputMessage4 = assistant?.exampleInputs[3] ?? ""; + function resetErrors() { + if (form) { + form.errors = []; + form.error = false; + } + } + function onFilesChange(e: Event) { const inputEl = e.target as HTMLInputElement; if (inputEl.files?.length) { files = inputEl.files; + resetErrors(); + deleteExistingAvatar = false; } } @@ -52,9 +61,9 @@ return returnForm?.errors.find((error) => error.field === field)?.message ?? ""; } - let loading = false; + let deleteExistingAvatar = false; - let generateAvatar = false; + let loading = false;
{ loading = true; - const avatar = formData.get("avatar"); - - if (avatar && typeof avatar !== "string" && avatar.size > 0 && compress) { - await compress(avatar, { + if (files?.[0] && files[0].size > 0 && compress) { + await compress(files[0], { maxWidth: 500, maxHeight: 500, quality: 1, @@ -75,6 +82,16 @@ }); } + if (deleteExistingAvatar === true) { + if (assistant?.avatar) { + // if there is an avatar we explicitly removei t + formData.set("avatar", "null"); + } else { + // else we just remove it from the input + formData.delete("avatar"); + } + } + return async ({ result }) => { loading = false; await applyAction(result); @@ -93,73 +110,72 @@

{/if} -
+
-