feat: add better provider support, icons, regen, and a lot more
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<script setup lang="ts">
|
||||
const triplit = useTriplitClient();
|
||||
const { providers, unsubscribe: unsubscribeModels, allModels } = await useModels();
|
||||
const { settings, unsubscribe: unsubscribeSettings } = await useUserSettings();
|
||||
|
||||
const toggle = async (key: string) => {
|
||||
console.log(key);
|
||||
|
||||
await triplit.update('settings', settings.value.id, {
|
||||
systemAssistants: {
|
||||
...settings.value.systemAssistants,
|
||||
[key]: {
|
||||
// @ts-ignore
|
||||
...settings.value.systemAssistants[key],
|
||||
// @ts-ignore
|
||||
enabled: !settings.value.systemAssistants[key].enabled
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const updateModel = async (key: string, model: ModelWithProvider | undefined | null) => {
|
||||
await triplit.update('settings', settings.value.id, {
|
||||
systemAssistants: {
|
||||
...settings.value.systemAssistants,
|
||||
[key]: {
|
||||
// @ts-ignore
|
||||
...settings.value.systemAssistants[key],
|
||||
modelId: model?.id ?? null
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getModel = (id: string | null | undefined) => {
|
||||
if (!id) return null;
|
||||
|
||||
return allModels.value.find(m => m.id === id);
|
||||
}
|
||||
|
||||
defineEmits(['navigate']);
|
||||
|
||||
onUnmounted(() => {
|
||||
unsubscribeModels?.();
|
||||
unsubscribeSettings?.();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-4 flex-grow">
|
||||
<div class="flex flex-col" v-for="(systemAssistant, key) in settings.systemAssistants">
|
||||
<label :for="`slider-${key}`" class="flex justify-between gap-4 items-center">
|
||||
<h4 class="capitalize">{{ key }}</h4>
|
||||
<Slider :id="`slider-${key}`" :checked="systemAssistant.enabled" @click="toggle(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(key, model)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user