From 7752f374e5b3e5ac3641a859fe38749297c618e9 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Fri, 1 Nov 2024 11:59:53 +0800 Subject: [PATCH] Revert "update model provider api responses" This reverts commit c8dc5e484937136b4466bf3a37d6de58606a0234. --- .../model-provider-page/declarations.ts | 32 ++++++++----------- .../model-provider-page/hooks.ts | 9 ++---- .../system-model-selector/index.tsx | 1 - web/service/common.ts | 8 ++--- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/web/app/components/header/account-setting/model-provider-page/declarations.ts b/web/app/components/header/account-setting/model-provider-page/declarations.ts index 930ae4b852..c50a17c6b2 100644 --- a/web/app/components/header/account-setting/model-provider-page/declarations.ts +++ b/web/app/components/header/account-setting/model-provider-page/declarations.ts @@ -1,6 +1,6 @@ export type FormValue = Record -export type TypeWithI18N = { +export interface TypeWithI18N { en_US: T zh_Hans: T [key: string]: T @@ -17,7 +17,7 @@ export enum FormTypeEnum { file = 'file', } -export type FormOption = { +export interface FormOption { label: TypeWithI18N value: string show_on: FormShowOnObject[] @@ -89,12 +89,12 @@ export enum CustomConfigurationStatusEnum { noConfigure = 'no-configure', } -export type FormShowOnObject = { +export interface FormShowOnObject { variable: string value: string } -export type CredentialFormSchemaBase = { +export interface CredentialFormSchemaBase { variable: string label: TypeWithI18N type: FormTypeEnum @@ -112,7 +112,7 @@ export type CredentialFormSchemaRadio = CredentialFormSchemaBase & { options: Fo export type CredentialFormSchemaSecretInput = CredentialFormSchemaBase & { placeholder?: TypeWithI18N } export type CredentialFormSchema = CredentialFormSchemaTextInput | CredentialFormSchemaSelect | CredentialFormSchemaRadio | CredentialFormSchemaSecretInput -export type ModelItem = { +export interface ModelItem { model: string label: TypeWithI18N model_type: ModelTypeEnum @@ -141,7 +141,7 @@ export enum QuotaUnitEnum { credits = 'credits', } -export type QuotaConfiguration = { +export interface QuotaConfiguration { quota_type: CurrentSystemQuotaTypeEnum quota_unit: QuotaUnitEnum quota_limit: number @@ -150,8 +150,7 @@ export type QuotaConfiguration = { is_valid: boolean } -export type ModelProvider = { - plugin_id: string +export interface ModelProvider { provider: string label: TypeWithI18N description?: TypeWithI18N @@ -185,8 +184,7 @@ export type ModelProvider = { } } -export type Model = { - plugin_id: string +export interface Model { provider: string icon_large: TypeWithI18N icon_small: TypeWithI18N @@ -195,29 +193,27 @@ export type Model = { status: ModelStatusEnum } -export type DefaultModelResponse = { +export interface DefaultModelResponse { model: string model_type: ModelTypeEnum provider: { - plugin_id: string provider: string icon_large: TypeWithI18N icon_small: TypeWithI18N } } -export type DefaultModel = { - plugin_id: string +export interface DefaultModel { provider: string model: string } -export type CustomConfigurationModelFixedFields = { +export interface CustomConfigurationModelFixedFields { __model_name: string __model_type: ModelTypeEnum } -export type ModelParameterRule = { +export interface ModelParameterRule { default?: number | string | boolean | string[] help?: TypeWithI18N label: TypeWithI18N @@ -232,7 +228,7 @@ export type ModelParameterRule = { tagPlaceholder?: TypeWithI18N } -export type ModelLoadBalancingConfigEntry = { +export interface ModelLoadBalancingConfigEntry { /** model balancing config entry id */ id?: string /** is config entry enabled */ @@ -247,7 +243,7 @@ export type ModelLoadBalancingConfigEntry = { ttl?: number } -export type ModelLoadBalancingConfig = { +export interface ModelLoadBalancingConfig { enabled: boolean configs: ModelLoadBalancingConfigEntry[] } diff --git a/web/app/components/header/account-setting/model-provider-page/hooks.ts b/web/app/components/header/account-setting/model-provider-page/hooks.ts index 95bbd24f4a..54396cc538 100644 --- a/web/app/components/header/account-setting/model-provider-page/hooks.ts +++ b/web/app/components/header/account-setting/model-provider-page/hooks.ts @@ -36,12 +36,11 @@ export const useSystemDefaultModelAndModelList: UseDefaultModelAndModelList = ( modelList, ) => { const currentDefaultModel = useMemo(() => { - const currentProvider = modelList.find(provider => provider.provider === defaultModel?.provider.provider && provider.plugin_id === defaultModel?.provider.plugin_id) + const currentProvider = modelList.find(provider => provider.provider === defaultModel?.provider.provider) const currentModel = currentProvider?.models.find(model => model.model === defaultModel?.model) const currentDefaultModel = currentProvider && currentModel && { model: currentModel.model, provider: currentProvider.provider, - plugin_id: currentProvider.plugin_id, } return currentDefaultModel @@ -173,11 +172,7 @@ export const useModelListAndDefaultModelAndCurrentProviderAndModel = (type: Mode const { modelList, defaultModel } = useModelListAndDefaultModel(type) const { currentProvider, currentModel } = useCurrentProviderAndModel( modelList, - { - plugin_id: defaultModel?.provider.plugin_id || '', - provider: defaultModel?.provider.provider || '', - model: defaultModel?.model || '', - }, + { provider: defaultModel?.provider.provider || '', model: defaultModel?.model || '' }, ) return { diff --git a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx index 578fcbe716..2e1e6400d1 100644 --- a/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx +++ b/web/app/components/header/account-setting/model-provider-page/system-model-selector/index.tsx @@ -94,7 +94,6 @@ const SystemModel: FC = ({ model_settings: [ModelTypeEnum.textGeneration, ModelTypeEnum.textEmbedding, ModelTypeEnum.rerank, ModelTypeEnum.speech2text, ModelTypeEnum.tts].map((modelType) => { return { model_type: modelType, - plugin_id: getCurrentDefaultModelByModelType(modelType)?.plugin_id, provider: getCurrentDefaultModelByModelType(modelType)?.provider, model: getCurrentDefaultModelByModelType(modelType)?.model, } diff --git a/web/service/common.ts b/web/service/common.ts index 1fc9b60f45..d3c07f3c1d 100644 --- a/web/service/common.ts +++ b/web/service/common.ts @@ -38,11 +38,11 @@ import type { import type { RETRIEVE_METHOD } from '@/types/app' import type { SystemFeatures } from '@/types/feature' -type LoginSuccess = { +interface LoginSuccess { result: 'success' data: { access_token: string;refresh_token: string } } -type LoginFail = { +interface LoginFail { result: 'fail' data: string code: string @@ -183,7 +183,7 @@ export const fetchModelProviders: Fetcher<{ data: ModelProvider[] }, string> = ( return get<{ data: ModelProvider[] }>(url) } -export type ModelProviderCredentials = { +export interface ModelProviderCredentials { credentials?: Record load_balancing: ModelLoadBalancingConfig } @@ -297,7 +297,7 @@ export const moderate = (url: string, body: { app_id: string; text: string }) => return post(url, { body }) as Promise } -type RetrievalMethodsRes = { +interface RetrievalMethodsRes { retrieval_method: RETRIEVE_METHOD[] } export const fetchSupportRetrievalMethods: Fetcher = (url) => {