From a864e67a6ccf2bf2067794e65fc7444785bb1365 Mon Sep 17 00:00:00 2001 From: scarqin Date: Wed, 25 Dec 2024 14:43:29 +0800 Subject: [PATCH] feat: encapsulation select options --- .../src/components/AIProviderSelect/index.tsx | 43 +++++++++++++++++++ .../core/src/pages/keySettings/index.tsx | 30 ++++++------- 2 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 frontend/packages/core/src/components/AIProviderSelect/index.tsx diff --git a/frontend/packages/core/src/components/AIProviderSelect/index.tsx b/frontend/packages/core/src/components/AIProviderSelect/index.tsx new file mode 100644 index 00000000..2c568c4d --- /dev/null +++ b/frontend/packages/core/src/components/AIProviderSelect/index.tsx @@ -0,0 +1,43 @@ +import React from 'react'; +import { Select, Space } from 'antd'; +import { useTranslation } from 'react-i18next'; + +export interface AIProviderOption { + label: string; + value: string; +} + +interface AIProviderSelectProps { + value?: string; + onChange?: (value: string) => void; + style?: React.CSSProperties; + options?: AIProviderOption[]; +} + +const defaultOptions: AIProviderOption[] = [ + { label: 'OpenAI', value: 'openai' }, + { label: 'Anthropic', value: 'anthropic' } +]; + +const AIProviderSelect: React.FC = ({ + value, + onChange, + style = { width: 200 }, + options = defaultOptions +}) => { + const { t } = useTranslation(); + + return ( + + {t('AI 供应商')}: + - +