diff --git a/src/lib/components/chat/Controls/Valves.svelte b/src/lib/components/chat/Controls/Valves.svelte index 880b55b298..898df9f4ee 100644 --- a/src/lib/components/chat/Controls/Valves.svelte +++ b/src/lib/components/chat/Controls/Valves.svelte @@ -62,6 +62,9 @@ // Convert array to string for (const property in valvesSpec.properties) { if (valvesSpec.properties[property]?.type === 'array') { + if (valvesSpec.properties[property]?.input?.type === 'multiselect') { + continue; + } valves[property] = (valves[property] ?? []).join(','); } } @@ -75,6 +78,9 @@ // Convert string to array for (const property in valvesSpec.properties) { if (valvesSpec.properties[property]?.type === 'array') { + if (valvesSpec.properties[property]?.input?.type === 'multiselect') { + continue; + } valves[property] = (valves[property] ?? '').split(',').map((v) => v.trim()); } } diff --git a/src/lib/components/common/MultiSelect.svelte b/src/lib/components/common/MultiSelect.svelte new file mode 100644 index 0000000000..e81199d821 --- /dev/null +++ b/src/lib/components/common/MultiSelect.svelte @@ -0,0 +1,153 @@ + + + + + + +{#if open} +
+
+ {#each items as item} + + {/each} +
+
+{/if} diff --git a/src/lib/components/common/Valves.svelte b/src/lib/components/common/Valves.svelte index e174a4ef32..8cca8fd583 100644 --- a/src/lib/components/common/Valves.svelte +++ b/src/lib/components/common/Valves.svelte @@ -9,6 +9,7 @@ import Switch from './Switch.svelte'; import SensitiveInput from './SensitiveInput.svelte'; import NativeSelect from './NativeSelect.svelte'; + import MultiSelect from './MultiSelect.svelte'; import MapSelector from './Valves/MapSelector.svelte'; export let valvesSpec = null; @@ -37,7 +38,11 @@ // Initialize to custom value if ((propertySpec?.type ?? null) === 'array') { const defaultArray = propertySpec?.default ?? []; - valves[property] = Array.isArray(defaultArray) ? defaultArray.join(', ') : ''; + if (propertySpec?.input?.type === 'multiselect') { + valves[property] = Array.isArray(defaultArray) ? [...defaultArray] : []; + } else { + valves[property] = Array.isArray(defaultArray) ? defaultArray.join(', ') : ''; + } } else { valves[property] = propertySpec?.default ?? ''; } @@ -95,6 +100,16 @@ /> + {:else if valvesSpec.properties[property]?.input?.type === 'multiselect' && valvesSpec.properties[property]?.input?.options} + { + dispatch('change'); + }} + /> {:else if (valvesSpec.properties[property]?.type ?? null) !== 'string'}