diff --git a/src/app/settings/llm/OpenAI/index.tsx b/src/app/settings/llm/OpenAI/index.tsx index 9987b437f0be..adb77c5f069a 100644 --- a/src/app/settings/llm/OpenAI/index.tsx +++ b/src/app/settings/llm/OpenAI/index.tsx @@ -10,6 +10,7 @@ import { useGlobalStore } from '@/store/global'; import { modelProviderSelectors } from '@/store/global/selectors'; import Checker from '../components/Checker'; +import CustomModelSelect from '../components/CustomModelList'; import ProviderConfig from '../components/ProviderConfig'; import { LLMProviderConfigKey } from '../const'; @@ -66,10 +67,9 @@ const LLM = memo(() => { }, { children: ( - ), desc: t('llm.openai.customModelName.desc'), diff --git a/src/app/settings/llm/components/CustomModelList/Option.tsx b/src/app/settings/llm/components/CustomModelList/Option.tsx new file mode 100644 index 000000000000..3962634c5d46 --- /dev/null +++ b/src/app/settings/llm/components/CustomModelList/Option.tsx @@ -0,0 +1,28 @@ +import { Typography } from 'antd'; +import isEqual from 'fast-deep-equal'; +import { memo } from 'react'; +import { Flexbox } from 'react-layout-kit'; + +import ModelIcon from '@/components/ModelIcon'; +import { ModelInfoTags } from '@/components/ModelSelect'; +import { useGlobalStore } from '@/store/global'; +import { modelProviderSelectors } from '@/store/global/slices/settings/selectors'; + +export const OptionRender = memo<{ displayName: string; id: string }>(({ displayName, id: id }) => { + const model = useGlobalStore((s) => modelProviderSelectors.modelCardById(id)(s), isEqual); + + return ( + + + + + {displayName} + + + + {id} + + + + ); +}); diff --git a/src/app/settings/llm/components/CustomModelList/index.tsx b/src/app/settings/llm/components/CustomModelList/index.tsx new file mode 100644 index 000000000000..91af4e4c5792 --- /dev/null +++ b/src/app/settings/llm/components/CustomModelList/index.tsx @@ -0,0 +1,51 @@ +import { Select } from 'antd'; +import { css, cx } from 'antd-style'; +import isEqual from 'fast-deep-equal'; +import { memo } from 'react'; + +import { useGlobalStore } from '@/store/global'; +import { modelProviderSelectors } from '@/store/global/selectors'; + +import { OptionRender } from './Option'; + +const popup = css` + &.ant-select-dropdown { + .ant-select-item-option-selected { + font-weight: normal; + } + } +`; + +interface CustomModelSelectProps { + placeholder?: string; + provider: string; +} + +const CustomModelSelect = memo(({ provider, placeholder }) => { + const providerCard = useGlobalStore( + (s) => modelProviderSelectors.modelSelectList(s).find((s) => s.id === provider), + isEqual, + ); + const defaultEnableModel = providerCard?.chatModels.filter((v) => !v.hidden).map((m) => m.id); + + return ( +