/* Copyright (C) 2023-2026 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { SlidersHorizontalIcon } from 'lucide-react' import { useTranslation } from 'react-i18next' import { PromptInputButton } from '@/components/ai-elements/prompt-input' import { Input } from '@/components/design-system/input' import { StatusBadge } from '@/components/status-badge' import { Popover, PopoverContent, PopoverTrigger, } from '@/components/ui/popover' import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger, } from '@/components/ui/sheet' import { Slider } from '@/components/ui/slider' import { Switch } from '@/components/ui/switch' import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/tooltip' import { useIsMobile } from '@/hooks/use-mobile' import { cn } from '@/lib/utils' import { getParameterControlValueText, normalizeParameterNumberValue, PLAYGROUND_PARAMETER_CONTROLS, PLAYGROUND_PARAMETER_PANEL_SCROLL_CLASS, type PlaygroundParameterKey, } from '../../lib/parameters/playground-parameters' import type { ParameterEnabled, PlaygroundConfig } from '../../types' type PlaygroundParameterPanelProps = { config: PlaygroundConfig disabled?: boolean onConfigChange: ( key: K, value: PlaygroundConfig[K] ) => void onParameterEnabledChange: ( key: PlaygroundParameterKey, value: boolean ) => void parameterEnabled: ParameterEnabled } type PlaygroundParameterContentProps = PlaygroundParameterPanelProps & { compact?: boolean } function PlaygroundParameterContent({ compact = false, config, disabled, onConfigChange, onParameterEnabledChange, parameterEnabled, }: PlaygroundParameterContentProps) { const { t } = useTranslation() const updateParameterConfig = ( key: PlaygroundParameterKey, value: number | null ) => { if (key === 'seed') { onConfigChange('seed', value) return } onConfigChange(key, value ?? 0) } return (
{PLAYGROUND_PARAMETER_CONTROLS.map((control) => { const enabled = parameterEnabled[control.key] const value = config[control.key] const controlId = `playground-${control.key}` return (
{t(getParameterControlValueText(control.key, value))}

{t(control.descriptionKey)}

onParameterEnabledChange(control.key, checked) } size='sm' />
{control.valueType === 'slider' ? ( { const firstValue = Array.isArray(nextValue) ? nextValue[0] : nextValue updateParameterConfig( control.key, normalizeParameterNumberValue(control.key, firstValue) ) }} step={control.step} value={[Number(value)]} /> ) : ( { updateParameterConfig( control.key, normalizeParameterNumberValue( control.key, event.target.value ) ) }} step={control.step} type='number' value={value ?? ''} /> )}
) })}
) } export function PlaygroundParameterPanel(props: PlaygroundParameterPanelProps) { const { t } = useTranslation() const isMobile = useIsMobile() const activeCount = PLAYGROUND_PARAMETER_CONTROLS.filter( (control) => props.parameterEnabled[control.key] ).length const trigger = ( {activeCount} ) if (isMobile) { return ( } />

{t('Parameters')}

{t('Parameter settings')}
) } return ( } />

{t('Parameters')}

{t('Parameter settings')}
{t('Only enabled parameters are sent with the request.')}
) }