diff --git a/src/lib/components/chat/MessageInput/InputVariablesModal.svelte b/src/lib/components/chat/MessageInput/InputVariablesModal.svelte index 8b8e26851b..db45013ab8 100644 --- a/src/lib/components/chat/MessageInput/InputVariablesModal.svelte +++ b/src/lib/components/chat/MessageInput/InputVariablesModal.svelte @@ -20,6 +20,10 @@ let loading = true; let variableValues = {}; + let variablesKey = ''; + + const getVariableLabel = (variable) => variables[variable]?.label ?? variable; + const getVariablesKey = (value) => JSON.stringify(value ?? {}); const submitHandler = async () => { // Normalize Windows CRLF (\r\n) to LF (\n) for all string values @@ -60,8 +64,16 @@ } }; + $: if (!show) { + variablesKey = ''; + } + $: if (show) { - init(); + const key = getVariablesKey(variables); + if (key !== variablesKey) { + variablesKey = key; + init(); + } } @@ -98,10 +110,10 @@
- {variable} + {getVariableLabel(variable)} {#if variables[variable]?.required ?? false} - *{$i18n.t('required')} + * {$i18n.t('required')} {/if}
@@ -114,13 +126,11 @@ bind:value={variableValues[variable]} id="input-variable-{idx}" > - {#if variables[variable]?.placeholder} - - {/if} + {#each variables[variable]?.options ?? [] as option} - {/each}