6ee4087a29
- Centralize `useAgents` and `useModels` state within the Nuxt app context to prevent data leaks and improve initialization. - Migrate virtualization from `vue-virtual-scroller` to `@tanstack/vue-virtual` with new `RowVirtualizerFixed` and `RowVirtualizerDynamic` components. - Upgrade Nuxt to v4.3.1 and remove `@vue-macros/nuxt`. - Replace `big.js` with an optimized custom `lshDecimal` string manipulation logic for pricing calculations in the provider API. - Implement automatic focus redirection in `ChatInput` to capture standard keyboard input. - Refactor Sidenav and Settings components to utilize virtualization for long lists (topics, agents, models). - Enhance theme colors and mobile experience. More work to come on both of these.
56 lines
1.8 KiB
Vue
56 lines
1.8 KiB
Vue
<script setup lang="ts">
|
|
import type { ModelWithProvider } from '~/composables/useModels';
|
|
|
|
const { providers, allModels } = await useModels();
|
|
const { settings, updateSettings } = await 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="capitalize">{{ 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>
|