From e0fb167db37ab314e342bf27649ced04c47d0f71 Mon Sep 17 00:00:00 2001 From: CodingOnStar Date: Wed, 21 Jan 2026 15:48:46 +0800 Subject: [PATCH] feat: enhance quota panel to support additional model providers and integrate trial models feature --- .../provider-added-card/quota-panel.tsx | 54 +++++++++++-------- web/types/feature.ts | 4 ++ 2 files changed, 35 insertions(+), 23 deletions(-) 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 069e46be51..e78f6989e8 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 @@ -1,15 +1,16 @@ -import type { FC } from 'react' +import type { ComponentType, FC } from 'react' import type { ModelProvider } from '../declarations' import type { Plugin } from '@/app/components/plugins/types' import { useBoolean } from 'ahooks' import * as React from 'react' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { OpenaiSmall } from '@/app/components/base/icons/src/public/llm' +import { AnthropicShortLight, Deepseek, Gemini, Grok, OpenaiSmall, Tongyi } from '@/app/components/base/icons/src/public/llm' import Loading from '@/app/components/base/loading' import Tooltip from '@/app/components/base/tooltip' import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace' import { useAppContext } from '@/context/app-context' +import { useGlobalPublicStore } from '@/context/global-public-context' import useTimestamp from '@/hooks/use-timestamp' import { cn } from '@/utils/classnames' import { formatNumber } from '@/utils/format' @@ -17,14 +18,19 @@ import { PreferredProviderTypeEnum } from '../declarations' import { useMarketplaceAllPlugins } from '../hooks' import { modelNameMap, ModelProviderQuotaGetPaid } from '../utils' -const allProviders = [ +type ProviderConfig = { + key: ModelProviderQuotaGetPaid + Icon: ComponentType<{ className?: string }> +} + +const allProviders: ProviderConfig[] = [ { key: ModelProviderQuotaGetPaid.OPENAI, Icon: OpenaiSmall }, - // { key: ModelProviderQuotaGetPaid.ANTHROPIC, Icon: AnthropicShortLight }, - // { key: ModelProviderQuotaGetPaid.GEMINI, Icon: Gemini }, - // { key: ModelProviderQuotaGetPaid.X, Icon: Grok }, - // { key: ModelProviderQuotaGetPaid.DEEPSEEK, Icon: Deepseek }, - // { key: ModelProviderQuotaGetPaid.TONGYI, Icon: Tongyi }, -] as const + { key: ModelProviderQuotaGetPaid.ANTHROPIC, Icon: AnthropicShortLight }, + { key: ModelProviderQuotaGetPaid.GEMINI, Icon: Gemini }, + { key: ModelProviderQuotaGetPaid.X, Icon: Grok }, + { key: ModelProviderQuotaGetPaid.DEEPSEEK, Icon: Deepseek }, + { key: ModelProviderQuotaGetPaid.TONGYI, Icon: Tongyi }, +] // Map provider key to plugin ID // provider key format: langgenius/provider/model, plugin ID format: langgenius/provider @@ -47,6 +53,7 @@ const QuotaPanel: FC = ({ }) => { const { t } = useTranslation() const { currentWorkspace } = useAppContext() + const { trial_models } = useGlobalPublicStore(s => s.systemFeatures) const credits = Math.max((currentWorkspace.trial_credits - currentWorkspace.trial_credits_used) || 0, 0) const providerMap = useMemo(() => new Map( providers.map(p => [p.provider, p.preferred_provider_type]), @@ -130,21 +137,22 @@ const QuotaPanel: FC = ({ return 'modelProvider.card.modelNotSupported' } return ( - -
handleIconClick(key)} + trial_models.includes(key) && ( + - - {!usingQuota && ( -
- )} -
-
- ) +
handleIconClick(key)} + > + + {!usingQuota && ( +
+ )} +
+ + )) })}
diff --git a/web/types/feature.ts b/web/types/feature.ts index bd331d4508..eed6e3542c 100644 --- a/web/types/feature.ts +++ b/web/types/feature.ts @@ -1,3 +1,5 @@ +import type { ModelProviderQuotaGetPaid } from '@/app/components/header/account-setting/model-provider-page/utils' + export enum SSOProtocol { SAML = 'saml', OIDC = 'oidc', @@ -26,6 +28,7 @@ type License = { } export type SystemFeatures = { + trial_models: ModelProviderQuotaGetPaid[] plugin_installation_permission: { plugin_installation_scope: InstallationScope restrict_to_marketplace_only: boolean @@ -62,6 +65,7 @@ export type SystemFeatures = { } export const defaultSystemFeatures: SystemFeatures = { + trial_models: [], plugin_installation_permission: { plugin_installation_scope: InstallationScope.ALL, restrict_to_marketplace_only: false,