From 4f8cdabef03938d628873e558e0752f8f8580366 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Mon, 16 Dec 2024 16:29:15 +0800 Subject: [PATCH] dark mode of model provider --- web/app/components/base/grid-mask/index.tsx | 8 ++-- .../model-provider-page/model-modal/Form.tsx | 11 +++-- .../model-provider-page/model-modal/Input.tsx | 8 ++-- .../model-provider-page/model-modal/index.tsx | 21 ++++----- .../provider-added-card/add-model-button.tsx | 6 +-- .../provider-added-card/credential-panel.tsx | 4 +- .../provider-added-card/index.tsx | 6 +-- .../provider-added-card/model-list-item.tsx | 16 ++++--- .../model-load-balancing-configs.tsx | 24 +++++----- .../model-load-balancing-modal.tsx | 12 ++--- .../provider-added-card/priority-selector.tsx | 19 ++++---- .../provider-added-card/priority-use-tip.tsx | 4 +- .../provider-added-card/quota-panel.tsx | 8 ++-- .../provider-added-card/tab.tsx | 45 ------------------- 14 files changed, 74 insertions(+), 118 deletions(-) delete mode 100644 web/app/components/header/account-setting/model-provider-page/provider-added-card/tab.tsx diff --git a/web/app/components/base/grid-mask/index.tsx b/web/app/components/base/grid-mask/index.tsx index 876eb7f1de..0bf6625a83 100644 --- a/web/app/components/base/grid-mask/index.tsx +++ b/web/app/components/base/grid-mask/index.tsx @@ -36,8 +36,8 @@ const GridMask: FC = ({ const drawRecord = useCallback(() => { const canvas = canvasRef.current! const ctx = ctxRef.current! - const rowNumber = parseInt(`${canvas.width / 24}`) - const colNumber = parseInt(`${canvas.height / 24}`) + const rowNumber = Number.parseInt(`${canvas.width / 24}`) + const colNumber = Number.parseInt(`${canvas.height / 24}`) ctx.clearRect(0, 0, canvas.width, canvas.height) ctx.beginPath() @@ -82,9 +82,9 @@ const GridMask: FC = ({ }, []) return ( -
+
-
+
{children}
) diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx index abad9479ee..d6614a8692 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx @@ -20,6 +20,7 @@ import Radio from '@/app/components/base/radio' import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal' import ToolSelector from '@/app/components/plugins/plugin-detail-panel/tool-selector' import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector' +import RadioE from '@/app/components/base/radio/ui' type FormProps = { className?: string @@ -177,17 +178,15 @@ const Form: FC = ({ }).map(option => (
handleFormChange(variable, option.value)} key={`${variable}-${option.value}`} > -
+ +
{option.label[language] || option.label.en_US}
)) diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx index 041b44a507..f94b708bf3 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx @@ -41,11 +41,11 @@ const Input: FC = ({ = ({
-
+
-
{renderTitlePrefix()}
+
{renderTitlePrefix()}
@@ -297,7 +297,7 @@ const ModelModal: FC = ({ isEditMode={isEditMode} /> -
+
= ({ configurationMethod: configurateMethod, }} /> -
+
{ (provider.help && (provider.help.title || provider.help.url)) ? ( @@ -326,8 +326,9 @@ const ModelModal: FC = ({ { isEditMode && (
-
+
{ (validatedStatusState.status === ValidatedStatus.Error && validatedStatusState.message) ? ( -
+
{validatedStatusState.message}
) : ( -
- +
+ {t('common.modelProvider.encrypted.front')} diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.tsx index cc8fa67efc..410ab1c090 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/add-model-button.tsx @@ -1,6 +1,7 @@ import type { FC } from 'react' import { useTranslation } from 'react-i18next' import { PlusCircle } from '@/app/components/base/icons/src/vender/solid/general' +import cn from '@/utils/classnames' type AddModelButtonProps = { className?: string @@ -14,10 +15,7 @@ const AddModelButton: FC = ({ return ( diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx index e7f865f198..f43b5359ab 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/credential-panel.tsx @@ -66,8 +66,8 @@ const CredentialPanel: FC = ({ <> { provider.provider_credential_schema && ( -
-
+
+
API-KEY
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx index 4b7f128bca..a3dddf9435 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx @@ -122,7 +122,7 @@ const ProviderAddedCard: FC = ({
{ collapsed && ( -
+
{(showQuota || !notConfigured) && ( <>
@@ -134,7 +134,7 @@ const ProviderAddedCard: FC = ({ {!loading && }
{ @@ -154,7 +154,7 @@ const ProviderAddedCard: FC = ({ {!showQuota && notConfigured && (
- {t('common.modelProvider.configureTip')} + {t('common.modelProvider.configureTip')}
)} { diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx index 3fc73a62b2..6c4a3f575e 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-list-item.tsx @@ -49,7 +49,7 @@ const ModelListItem = ({ model, provider, isConfigurable, onConfig, onModifyLoad key={model.model} className={classNames( 'group flex items-center pl-2 pr-2.5 h-8 rounded-lg', - isConfigurable && 'hover:bg-gray-50', + isConfigurable && 'hover:bg-components-panel-on-panel-item-bg-hover', model.deprecated && 'opacity-60', )} > @@ -59,14 +59,14 @@ const ModelListItem = ({ model, provider, isConfigurable, onConfig, onModifyLoad modelName={model.model} /> {modelLoadBalancingEnabled && !model.deprecated && model.load_balancing_enabled && ( - + {t('common.modelProvider.loadBalancingHeadline')} @@ -77,20 +77,22 @@ const ModelListItem = ({ model, provider, isConfigurable, onConfig, onModifyLoad model.fetch_from === ConfigurationMethodEnum.customizableModel ? (isCurrentWorkspaceManager && ( )) : (isCurrentWorkspaceManager && (modelLoadBalancingEnabled || plan.type === Plan.sandbox) && !model.deprecated && [ModelStatusEnum.active, ModelStatusEnum.disabled].includes(model.status)) ? ( ) diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx index 94184076fd..2d5cf26257 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-configs.tsx @@ -145,19 +145,19 @@ const ModelLoadBalancingConfigs = ({ <>
toggleModalBalancing(true) : undefined} >
-
+
-
+
{t('common.modelProvider.loadBalancing')}
-
{t('common.modelProvider.loadBalancingDescription')}
+
{t('common.modelProvider.loadBalancingDescription')}
{ withSwitch && ( @@ -184,7 +184,7 @@ const ModelLoadBalancingConfigs = ({ {draftConfig.configs.map((config, index) => { const isProviderManaged = config.name === '__inherit__' return ( -
+
{(config.in_cooldown && Boolean(config.ttl)) @@ -201,7 +201,7 @@ const ModelLoadBalancingConfigs = ({ {isProviderManaged ? t('common.modelProvider.defaultConfig') : config.name}
{isProviderManaged && ( - {t('common.modelProvider.providerManaged')} + {t('common.modelProvider.providerManaged')} )}
@@ -209,18 +209,18 @@ const ModelLoadBalancingConfigs = ({ <>
toggleEntryModal(index, config)} > updateConfigEntry(index, () => undefined)} > - +
)} @@ -247,7 +247,7 @@ const ModelLoadBalancingConfigs = ({ )} { draftConfig.enabled && draftConfig.configs.length < 2 && ( -
+
{t('common.modelProvider.loadBalancingLeastKeyWarning')}
@@ -257,7 +257,7 @@ const ModelLoadBalancingConfigs = ({ {!modelLoadBalancingEnabled && !IS_CE_EDITION && ( -
+
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx index edbb4665e9..bdc6b13c2c 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-load-balancing-modal.tsx @@ -119,7 +119,7 @@ const ModelLoadBalancingModal = ({ provider, model, open = false, onClose, onSav modelName={model!.model} />
toggleModalBalancing(false) : undefined} >
-
+
{Boolean(model) && ( )}
-
{t('common.modelProvider.providerManaged')}
-
{t('common.modelProvider.providerManagedDescription')}
+
{t('common.modelProvider.providerManaged')}
+
{t('common.modelProvider.providerManagedDescription')}
diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/priority-selector.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/priority-selector.tsx index 7e44011ead..e93c6636b5 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/priority-selector.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/priority-selector.tsx @@ -8,6 +8,7 @@ import { } from '@remixicon/react' import { PreferredProviderTypeEnum } from '../declarations' import Button from '@/app/components/base/button' +import cn from '@/utils/classnames' type SelectorProps = { value?: string @@ -34,11 +35,11 @@ const Selector: FC = ({ { ({ open }) => ( - ) } @@ -49,18 +50,18 @@ const Selector: FC = ({ leaveFrom='opacity-100' leaveTo='opacity-0' > - +
-
{t('common.modelProvider.card.priorityUse')}
+
{t('common.modelProvider.card.priorityUse')}
{ options.map(option => (
onSelect(option.key)} >
{option.text}
- {value === option.key && } + {value === option.key && }
)) diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/priority-use-tip.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/priority-use-tip.tsx index 24e91d2214..91e45ad1a3 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/priority-use-tip.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/priority-use-tip.tsx @@ -9,8 +9,8 @@ const PriorityUseTip = () => { -
- +
+
) diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/quota-panel.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/quota-panel.tsx index 0f5c265d52..8d0ea83d65 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/quota-panel.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/quota-panel.tsx @@ -28,8 +28,8 @@ const QuotaPanel: FC = ({ const openaiOrAnthropic = MODEL_PROVIDER_QUOTA_GET_PAID.includes(provider.provider) return ( -
-
+
+
{t('common.modelProvider.quota')} = ({
{ currentQuota && ( -
- {formatNumber((currentQuota?.quota_limit || 0) - (currentQuota?.quota_used || 0))} +
+ {formatNumber((currentQuota?.quota_limit || 0) - (currentQuota?.quota_used || 0))} { currentQuota?.quota_unit === QuotaUnitEnum.tokens && 'Tokens' } diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/tab.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/tab.tsx deleted file mode 100644 index 5a533947d2..0000000000 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/tab.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import type { FC } from 'react' - -type TabProps = { - active: string - onSelect: (active: string) => void -} -const Tab: FC = ({ - active, - onSelect, -}) => { - const tabs = [ - { - key: 'all', - text: 'All', - }, - { - key: 'added', - text: 'Added', - }, - { - key: 'build-in', - text: 'Build-in', - }, - ] - return ( -
- { - tabs.map(tab => ( -
onSelect(tab.key)} - > - {tab.text} -
- )) - } -
- ) -} - -export default Tab