diff --git a/.env b/.env index c965efba7cc..63370165f6c 100644 --- a/.env +++ b/.env @@ -128,4 +128,6 @@ LLM_SUMMERIZATION=true # PUBLIC_APP_DATA_SHARING=1 # PUBLIC_APP_DISCLAIMER=1 -ENABLE_ASSISTANTS=false #set to true to enable assistants feature \ No newline at end of file +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" diff --git a/src/lib/components/AssistantSettings.svelte b/src/lib/components/AssistantSettings.svelte index b8ec68f6b0e..a2dd7bb9804 100644 --- a/src/lib/components/AssistantSettings.svelte +++ b/src/lib/components/AssistantSettings.svelte @@ -4,10 +4,12 @@ import type { Assistant } from "$lib/types/Assistant"; import { onMount } from "svelte"; - import { enhance } from "$app/forms"; + import { applyAction, enhance } from "$app/forms"; import { base } from "$app/paths"; import CarbonPen from "~icons/carbon/pen"; import { useSettingsStore } from "$lib/stores/settings"; + import { page } from "$app/stores"; + import IconLoading from "./icons/IconLoading.svelte"; type ActionData = { error: boolean; @@ -49,6 +51,10 @@ function getError(field: string, returnForm: ActionData) { return returnForm?.errors.find((error) => error.field === field)?.message ?? ""; } + + let loading = false; + + let generateAvatar = false;
{ + loading = true; const avatar = formData.get("avatar"); if (avatar && typeof avatar !== "string" && avatar.size > 0 && compress) { @@ -67,6 +74,11 @@ formData.set("avatar", resizedImage); }); } + + return async ({ result }) => { + loading = false; + await applyAction(result); + }; }} > {#if assistant} @@ -90,6 +102,7 @@ accept="image/*" name="avatar" class="invisible z-10 block h-0 w-0" + disabled={generateAvatar} on:change={onFilesChange} /> {#if (files && files[0]) || assistant?.avatar} @@ -122,9 +135,24 @@ Reset {:else} - Click to upload + Click to upload {/if}

{getError("avatar", form)}

+ {#if !files?.[0] && $page.data.avatarGeneration && !assistant?.avatar} + + {/if}