feat(settings): separate personalization & preferences

This commit is contained in:
ItzCrazyKns
2025-10-29 23:13:51 +05:30
parent f709aa8224
commit c3abba8462
5 changed files with 81 additions and 25 deletions

View File

@@ -0,0 +1,29 @@
import { UIConfigField } from '@/lib/config/types';
import SettingsField from '../SettingsField';
const Personalization = ({
fields,
values,
}: {
fields: UIConfigField[];
values: Record<string, any>;
}) => {
return (
<div className="flex-1 space-y-6 overflow-y-auto px-6 py-6">
{fields.map((field) => (
<SettingsField
key={field.key}
field={field}
value={
(field.scope === 'client'
? localStorage.getItem(field.key)
: values[field.key]) ?? field.default
}
dataAdd="personalization"
/>
))}
</div>
);
};
export default Personalization;

View File

@@ -1,7 +1,7 @@
import { UIConfigField } from '@/lib/config/types'; import { UIConfigField } from '@/lib/config/types';
import SettingsField from '../SettingsField'; import SettingsField from '../SettingsField';
const General = ({ const Preferences = ({
fields, fields,
values, values,
}: { }: {
@@ -19,11 +19,11 @@ const General = ({
? localStorage.getItem(field.key) ? localStorage.getItem(field.key)
: values[field.key]) ?? field.default : values[field.key]) ?? field.default
} }
dataAdd="general" dataAdd="preferences"
/> />
))} ))}
</div> </div>
); );
}; };
export default General; export default Preferences;

View File

@@ -4,9 +4,10 @@ import {
BrainCog, BrainCog,
ChevronLeft, ChevronLeft,
Search, Search,
Settings, Sliders,
ToggleRight,
} from 'lucide-react'; } from 'lucide-react';
import General from './Sections/General'; import Preferences from './Sections/Preferences';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { toast } from 'sonner'; import { toast } from 'sonner';
@@ -15,15 +16,24 @@ import { cn } from '@/lib/utils';
import Models from './Sections/Models/Section'; import Models from './Sections/Models/Section';
import SearchSection from './Sections/Search'; import SearchSection from './Sections/Search';
import Select from '@/components/ui/Select'; import Select from '@/components/ui/Select';
import Personalization from './Sections/Personalization';
const sections = [ const sections = [
{ {
key: 'general', key: 'preferences',
name: 'General', name: 'Preferences',
description: 'Adjust common settings.', description: 'Customize your application preferences.',
icon: Settings, icon: Sliders,
component: General, component: Preferences,
dataAdd: 'general', dataAdd: 'preferences',
},
{
key: 'personalization',
name: 'Personalization',
description: 'Customize the behavior and tone of the model.',
icon: ToggleRight,
component: Personalization,
dataAdd: 'personalization',
}, },
{ {
key: 'models', key: 'models',

View File

@@ -13,14 +13,15 @@ class ConfigManager {
currentConfig: Config = { currentConfig: Config = {
version: this.configVersion, version: this.configVersion,
setupComplete: false, setupComplete: false,
general: {}, preferences: {},
personalization: {},
modelProviders: [], modelProviders: [],
search: { search: {
searxngURL: '', searxngURL: '',
}, },
}; };
uiConfigSections: UIConfigSections = { uiConfigSections: UIConfigSections = {
general: [ preferences: [
{ {
name: 'Theme', name: 'Theme',
key: 'theme', key: 'theme',
@@ -40,16 +41,6 @@ class ConfigManager {
default: 'dark', default: 'dark',
scope: 'client', scope: 'client',
}, },
{
name: 'System Instructions',
key: 'systemInstructions',
type: 'textarea',
required: false,
description: 'Add custom behavior or tone for the model.',
placeholder:
'e.g., "Respond in a friendly and concise tone" or "Use British English and format answers as bullet points."',
scope: 'client',
},
{ {
name: 'Measurement Unit', name: 'Measurement Unit',
key: 'measureUnit', key: 'measureUnit',
@@ -69,6 +60,27 @@ class ConfigManager {
default: 'Metric', default: 'Metric',
scope: 'client', scope: 'client',
}, },
{
name: 'Auto video & image search',
key: 'autoMediaSearch',
type: 'switch',
required: false,
description: 'Automatically search for relevant images and videos.',
default: true,
scope: 'client',
},
],
personalization: [
{
name: 'System Instructions',
key: 'systemInstructions',
type: 'textarea',
required: false,
description: 'Add custom behavior or tone for the model.',
placeholder:
'e.g., "Respond in a friendly and concise tone" or "Use British English and format answers as bullet points."',
scope: 'client',
},
], ],
modelProviders: [], modelProviders: [],
search: [ search: [

View File

@@ -63,7 +63,10 @@ type ConfigModelProvider = {
type Config = { type Config = {
version: number; version: number;
setupComplete: boolean; setupComplete: boolean;
general: { preferences: {
[key: string]: any;
};
personalization: {
[key: string]: any; [key: string]: any;
}; };
modelProviders: ConfigModelProvider[]; modelProviders: ConfigModelProvider[];
@@ -86,7 +89,8 @@ type ModelProviderUISection = {
}; };
type UIConfigSections = { type UIConfigSections = {
general: UIConfigField[]; preferences: UIConfigField[];
personalization: UIConfigField[];
modelProviders: ModelProviderUISection[]; modelProviders: ModelProviderUISection[];
search: UIConfigField[]; search: UIConfigField[];
}; };
@@ -101,4 +105,5 @@ export type {
ModelProviderUISection, ModelProviderUISection,
ConfigModelProvider, ConfigModelProvider,
TextareaUIConfigField, TextareaUIConfigField,
SwitchUIConfigField,
}; };