From 72fd873a76b3bbee9c08d0f9c5aa06aa3dbb66f5 Mon Sep 17 00:00:00 2001 From: arvinxx Date: Sun, 7 Apr 2024 16:19:35 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20support=20user=20config=20m?= =?UTF-8?q?odel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/settings/llm/Ollama/index.tsx | 1 - .../llm/components/CustomModelList/index.tsx | 19 +++++-- src/components/ModelSelect/index.tsx | 2 +- .../AgentSetting/AgentConfig/ModelSelect.tsx | 16 +++--- src/features/ModelSwitchPanel/index.tsx | 51 ++++++++++++++----- src/locales/default/common.ts | 11 ---- src/locales/default/components.ts | 15 ++++++ src/locales/default/index.ts | 2 + .../settings/selectors/modelConfig.test.ts | 30 +++++++++++ .../slices/settings/selectors/modelConfig.ts | 43 ++++++++++++++-- src/types/settings/modelProvider.ts | 2 +- 11 files changed, 149 insertions(+), 43 deletions(-) create mode 100644 src/locales/default/components.ts create mode 100644 src/store/global/slices/settings/selectors/modelConfig.test.ts diff --git a/src/app/settings/llm/Ollama/index.tsx b/src/app/settings/llm/Ollama/index.tsx index 0a31644870eb..4752f09e77e7 100644 --- a/src/app/settings/llm/Ollama/index.tsx +++ b/src/app/settings/llm/Ollama/index.tsx @@ -22,7 +22,6 @@ const OllamaProvider = memo(() => { }} provider={ModelProvider.Ollama} showApiKey={false} - showCustomModelName showEndpoint title={ diff --git a/src/app/settings/llm/components/CustomModelList/index.tsx b/src/app/settings/llm/components/CustomModelList/index.tsx index 60ccf1e2c6e4..f68794cd4ef1 100644 --- a/src/app/settings/llm/components/CustomModelList/index.tsx +++ b/src/app/settings/llm/components/CustomModelList/index.tsx @@ -5,7 +5,8 @@ import { memo } from 'react'; import { filterEnabledModels } from '@/config/modelProviders'; import { useGlobalStore } from '@/store/global'; -import { modelConfigSelectors } from '@/store/global/selectors'; +import { modelConfigSelectors, modelProviderSelectors } from '@/store/global/selectors'; +import { GlobalLLMProviderKey } from '@/types/settings'; import { OptionRender } from './Option'; @@ -18,22 +19,31 @@ const popup = css` `; interface CustomModelSelectProps { + onChange?: (value: string[]) => void; placeholder?: string; provider: string; + value?: string[]; } -const CustomModelSelect = memo(({ provider, placeholder }) => { +const CustomModelSelect = memo(({ provider, placeholder, onChange }) => { const providerCard = useGlobalStore( - (s) => modelConfigSelectors.modelSelectList(s).find((s) => s.id === provider), + (s) => modelProviderSelectors.providerModelList(s).find((s) => s.id === provider), isEqual, ); + const providerConfig = useGlobalStore((s) => + modelConfigSelectors.providerConfig(provider as GlobalLLMProviderKey)(s), + ); + const defaultEnableModel = providerCard ? filterEnabledModels(providerCard) : []; return ( -