import type { FC } from 'react' import { useTranslation } from 'react-i18next' import { useContext } from 'use-context-selector' import type { FormValue, Provider, ProviderConfigItem, ProviderWithConfig, ProviderWithQuota } from '../declarations' import { ProviderEnum } from '../declarations' import Indicator from '../../../indicator' import Selector from '../selector' import FreeQuota from './FreeQuota' import I18n from '@/context/i18n' import Button from '@/app/components/base/button' import { IS_CE_EDITION } from '@/config' type SettingProps = { currentProvider?: Provider modelItem: ProviderConfigItem onOpenModal: (v?: FormValue) => void onOperate: (v: Record) => void onUpdate: () => void } const Setting: FC = ({ currentProvider, modelItem, onOpenModal, onOperate, onUpdate, }) => { const { locale } = useContext(I18n) const { t } = useTranslation() const configurable = currentProvider?.model_flexibility === 'configurable' const systemFree = currentProvider?.providers.find(p => p.provider_type === 'system' && (p as ProviderWithQuota).quota_type === 'free') as ProviderWithQuota const custom = currentProvider?.providers.find(p => p.provider_type === 'custom') as ProviderWithConfig return (
{ (modelItem.key === ProviderEnum.minimax || modelItem.key === ProviderEnum.spark) && systemFree && !systemFree?.is_valid && !IS_CE_EDITION && ( ) } { modelItem.disable && !IS_CE_EDITION && (
{modelItem.disable.tip[locale]} {modelItem.disable.link.label[locale]}
) } { configurable && ( ) } { !configurable && custom?.config && (
`${open && '!bg-gray-100 shadow-none'} flex justify-center items-center w-7 h-7 bg-white rounded-md border-[0.5px] border-gray-200 shadow-xs cursor-pointer hover:bg-gray-100`} />
) } { !configurable && !custom?.config && ( ) }
) } export default Setting