import { IconSettings } from '@tabler/icons-react' import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger, } from '@/components/ui/sheet' import { DynamicControllerSetting } from '@/containers/dynamicControllerSetting' import { useModelProvider } from '@/hooks/useModelProvider' import { updateModel } from '@/services/models' import { ModelSettingParams } from '@janhq/core' // import { // HoverCard, // HoverCardContent, // HoverCardTrigger, // } from '@/components/ui/hover-card' type ModelSettingProps = { provider: ProviderObject model: Model } export function ModelSetting({ model, provider }: ModelSettingProps) { const { updateProvider } = useModelProvider() const handleSettingChange = ( key: string, value: string | boolean | number ) => { if (!provider) return // Create a copy of the model with updated settings const updatedModel = { ...model, settings: { ...model.settings, [key]: { ...(model.settings?.[key] != null ? model.settings?.[key] : {}), controller_props: { // @ts-ignore ...(model.settings?.[key]?.controller_props ?? {}), value: value, }, }, }, } // Find the model index in the provider's models array const modelIndex = provider.models.findIndex((m) => m.id === model.id) if (modelIndex !== -1) { // Create a copy of the provider's models array const updatedModels = [...provider.models] // Update the specific model in the array updatedModels[modelIndex] = updatedModel as Model // Update the provider with the new models array updateProvider(provider.provider, { models: updatedModels, }) updateModel({ id: model.id, settings: Object.entries(updatedModel.settings).map(([key, value]) => ({ // @ts-ignore [key]: value.controller_props?.value, })) as ModelSettingParams, }) } } return (
Model Setting {model.id} Configure model settings to optimize performance and behavior.
{Object.entries(model.settings || {}).map(([key, value]) => { const config = value as ProviderSetting return (

{config.title}

{config.description}

handleSettingChange(key, newValue)} /> {/*
handleSettingChange(key, newValue) } />
{config.description}
*/}
) })}
) }