diff --git a/src/routes/settings/components/Select.svelte b/src/routes/settings/components/Select.svelte new file mode 100644 index 0000000..5e22754 --- /dev/null +++ b/src/routes/settings/components/Select.svelte @@ -0,0 +1,36 @@ + + + dispatch('change', ev?.value)} +> + + {label ?? placeholder} + + + {#each items as it} + {it.label ?? it.value} + {/each} + + diff --git a/src/routes/settings/page.svelte b/src/routes/settings/page.svelte index 91a7972..53304e1 100644 --- a/src/routes/settings/page.svelte +++ b/src/routes/settings/page.svelte @@ -4,6 +4,9 @@ import { Input } from '$lib/components/ui/input' import { Separator } from '$lib/components/ui/separator' import { settingSchemaStore } from '$lib/stores/settingSchema' + import { Textarea } from '$lib/components/ui/textarea' + import SelectUI from './components/Select.svelte' + import { pluginStore } from '$lib/plugins/store' function onChange(name: string, value: any) { ;($settingsStore as any)[name] = value @@ -45,43 +48,42 @@
{#if it.schema.enum} - { - value?.value && onChange(it.name, value.value) - }} - > - - {it.schema.enumDescriptions?.[ - it.schema.enum.indexOf($settingsStore[it.name]) - ] ?? - $settingsStore[it.name] ?? - it.schema.enumDescriptions?.[ - it.schema.enum.indexOf(it.schema.default) - ] ?? - it.schema.default ?? - 'Please select'} - - - {#each it.schema.enum as value, index} - {it.schema.enumDescriptions?.[index] ?? value} - {/each} - - - {:else if it.schema.type === 'string'} - onChangeInput(e, it.name)} + value={$settingsStore[it.name]} + on:change={(ev) => onChange(it.name, ev.detail)} + items={it.schema.enum.map((value, index) => ({ + value, + label: it.schema.enumDescriptions?.[index] ?? value, + }))} + placeholder="Please select" /> + {:else if it.schema.type === 'string'} + {#if it.schema.format === 'markdown'} + + {:else if it.schema.format === 'model'} + onChange(it.name, ev.detail)} + placeholder="Please select" + items={$pluginStore.models + .filter((it) => it.type === 'llm') + .map((it) => ({ + value: it.id, + label: it.name, + }))} + /> + {:else} + onChangeInput(e, it.name)} + /> + {/if} {/if}
{/each}