Files
veridian/app/components/Settings/SystemAssistants.vue
T

60 lines
1.9 KiB
Vue

<script setup lang="ts">
import type { ModelWithProvider } from '~/composables/useModels';
const props = defineProps<{
params?: string;
}>();
const { providers, allModels } = useModels();
const { settings, updateSettings } = useUserSettings();
const toggle = async (key: string) => {
const current = (settings.value.systemAssistants as any)[key];
await updateSettings({
systemAssistants: {
[key]: {
...current,
enabled: !current.enabled
}
}
});
};
const updateModel = async (key: string, model: ModelWithProvider | undefined | null) => {
const current = (settings.value.systemAssistants as any)[key];
await updateSettings({
systemAssistants: {
[key]: {
...current,
modelId: model?.id ?? null
}
}
});
};
const getModel = (id: string | null | undefined) => {
if (!id) return null;
return allModels.value.find(m => m.id === id);
}
defineEmits(['navigate']);
</script>
<template>
<div
class="flex flex-col gap-4 py-4 flex-grow overflow-auto [scrollbar-width:thin] [scrollbar-color:#888_transparent] [scrollbar-gutter:stable]">
<div class="flex flex-col" v-for="(systemAssistant, key) in settings.systemAssistants" :key="key">
<label :for="`slider-${key}`" class="flex justify-between gap-4 items-center">
<h4 class="case-capital">{{ key }}</h4>
<Slider :id="`slider-${key}`" :checked="systemAssistant.enabled" @click="toggle(String(key))" />
</label>
<div class="flex-1 justify-between gap-4 items-center">
<ModelSelector :providers="providers" :model-value="getModel(systemAssistant.modelId)"
@update:model-value="(model) => updateModel(String(key), model)" />
</div>
</div>
</div>
</template>