import { useId, useState } from 'react' import { useTranslation } from 'react-i18next' import { Dialog } from '@/components/dialog' import { Button } from '@/components/ui/button' import { Label } from '@/components/ui/label' import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group' import { Switch } from '@/components/ui/switch' import type { RoutingPolicy } from '../types' type Props = { policy: RoutingPolicy onSave: (policy: RoutingPolicy) => void onClose: () => void } export function AutomaticRoutingSettings(props: Props) { const { t } = useTranslation() const id = useId() const [preference, setPreference] = useState( props.policy.auto_preference ?? 'cost' ) const [allowDegraded, setAllowDegraded] = useState( props.policy.allow_degraded ?? false ) const [skipNonAstra, setSkipNonAstra] = useState( props.policy.skip_degraded_non_astra ?? false ) return ( { if (!open) props.onClose() }} title={t('Automatic group settings')} description={t( 'Automatically choose from all groups you can access that support the requested model.' )} footer={ <> } >
{ if (value === 'cost' || value === 'speed' || value === 'stable') { setPreference(value) } }} >

{t( 'Enabled by default for gpt-6-astra. Keep the last valid fingerprint and pelican conclusions until recovery or reset. Failed checks do not clear them.' )}

setAllowDegraded(!checked)} />

{t( 'Uses the group Astra fingerprint and pelican checks; other models have not been individually tested. Off by default.' )}

{t( 'Speed uses recent streaming model tests; stability uses request statistics. Price uses effective multipliers.' )}

{t('Settings take effect after saving the API key.')}

) }