Revert "update model provider api responses"

This reverts commit c8dc5e4849.
pull/12372/head
JzoNg 2 years ago
parent e7dcc53b55
commit 7752f374e5

@ -1,6 +1,6 @@
export type FormValue = Record<string, any> export type FormValue = Record<string, any>
export type TypeWithI18N<T = string> = { export interface TypeWithI18N<T = string> {
en_US: T en_US: T
zh_Hans: T zh_Hans: T
[key: string]: T [key: string]: T
@ -17,7 +17,7 @@ export enum FormTypeEnum {
file = 'file', file = 'file',
} }
export type FormOption = { export interface FormOption {
label: TypeWithI18N label: TypeWithI18N
value: string value: string
show_on: FormShowOnObject[] show_on: FormShowOnObject[]
@ -89,12 +89,12 @@ export enum CustomConfigurationStatusEnum {
noConfigure = 'no-configure', noConfigure = 'no-configure',
} }
export type FormShowOnObject = { export interface FormShowOnObject {
variable: string variable: string
value: string value: string
} }
export type CredentialFormSchemaBase = { export interface CredentialFormSchemaBase {
variable: string variable: string
label: TypeWithI18N label: TypeWithI18N
type: FormTypeEnum type: FormTypeEnum
@ -112,7 +112,7 @@ export type CredentialFormSchemaRadio = CredentialFormSchemaBase & { options: Fo
export type CredentialFormSchemaSecretInput = CredentialFormSchemaBase & { placeholder?: TypeWithI18N } export type CredentialFormSchemaSecretInput = CredentialFormSchemaBase & { placeholder?: TypeWithI18N }
export type CredentialFormSchema = CredentialFormSchemaTextInput | CredentialFormSchemaSelect | CredentialFormSchemaRadio | CredentialFormSchemaSecretInput export type CredentialFormSchema = CredentialFormSchemaTextInput | CredentialFormSchemaSelect | CredentialFormSchemaRadio | CredentialFormSchemaSecretInput
export type ModelItem = { export interface ModelItem {
model: string model: string
label: TypeWithI18N label: TypeWithI18N
model_type: ModelTypeEnum model_type: ModelTypeEnum
@ -141,7 +141,7 @@ export enum QuotaUnitEnum {
credits = 'credits', credits = 'credits',
} }
export type QuotaConfiguration = { export interface QuotaConfiguration {
quota_type: CurrentSystemQuotaTypeEnum quota_type: CurrentSystemQuotaTypeEnum
quota_unit: QuotaUnitEnum quota_unit: QuotaUnitEnum
quota_limit: number quota_limit: number
@ -150,8 +150,7 @@ export type QuotaConfiguration = {
is_valid: boolean is_valid: boolean
} }
export type ModelProvider = { export interface ModelProvider {
plugin_id: string
provider: string provider: string
label: TypeWithI18N label: TypeWithI18N
description?: TypeWithI18N description?: TypeWithI18N
@ -185,8 +184,7 @@ export type ModelProvider = {
} }
} }
export type Model = { export interface Model {
plugin_id: string
provider: string provider: string
icon_large: TypeWithI18N icon_large: TypeWithI18N
icon_small: TypeWithI18N icon_small: TypeWithI18N
@ -195,29 +193,27 @@ export type Model = {
status: ModelStatusEnum status: ModelStatusEnum
} }
export type DefaultModelResponse = { export interface DefaultModelResponse {
model: string model: string
model_type: ModelTypeEnum model_type: ModelTypeEnum
provider: { provider: {
plugin_id: string
provider: string provider: string
icon_large: TypeWithI18N icon_large: TypeWithI18N
icon_small: TypeWithI18N icon_small: TypeWithI18N
} }
} }
export type DefaultModel = { export interface DefaultModel {
plugin_id: string
provider: string provider: string
model: string model: string
} }
export type CustomConfigurationModelFixedFields = { export interface CustomConfigurationModelFixedFields {
__model_name: string __model_name: string
__model_type: ModelTypeEnum __model_type: ModelTypeEnum
} }
export type ModelParameterRule = { export interface ModelParameterRule {
default?: number | string | boolean | string[] default?: number | string | boolean | string[]
help?: TypeWithI18N help?: TypeWithI18N
label: TypeWithI18N label: TypeWithI18N
@ -232,7 +228,7 @@ export type ModelParameterRule = {
tagPlaceholder?: TypeWithI18N tagPlaceholder?: TypeWithI18N
} }
export type ModelLoadBalancingConfigEntry = { export interface ModelLoadBalancingConfigEntry {
/** model balancing config entry id */ /** model balancing config entry id */
id?: string id?: string
/** is config entry enabled */ /** is config entry enabled */
@ -247,7 +243,7 @@ export type ModelLoadBalancingConfigEntry = {
ttl?: number ttl?: number
} }
export type ModelLoadBalancingConfig = { export interface ModelLoadBalancingConfig {
enabled: boolean enabled: boolean
configs: ModelLoadBalancingConfigEntry[] configs: ModelLoadBalancingConfigEntry[]
} }

@ -36,12 +36,11 @@ export const useSystemDefaultModelAndModelList: UseDefaultModelAndModelList = (
modelList, modelList,
) => { ) => {
const currentDefaultModel = useMemo(() => { 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 currentModel = currentProvider?.models.find(model => model.model === defaultModel?.model)
const currentDefaultModel = currentProvider && currentModel && { const currentDefaultModel = currentProvider && currentModel && {
model: currentModel.model, model: currentModel.model,
provider: currentProvider.provider, provider: currentProvider.provider,
plugin_id: currentProvider.plugin_id,
} }
return currentDefaultModel return currentDefaultModel
@ -173,11 +172,7 @@ export const useModelListAndDefaultModelAndCurrentProviderAndModel = (type: Mode
const { modelList, defaultModel } = useModelListAndDefaultModel(type) const { modelList, defaultModel } = useModelListAndDefaultModel(type)
const { currentProvider, currentModel } = useCurrentProviderAndModel( const { currentProvider, currentModel } = useCurrentProviderAndModel(
modelList, modelList,
{ { provider: defaultModel?.provider.provider || '', model: defaultModel?.model || '' },
plugin_id: defaultModel?.provider.plugin_id || '',
provider: defaultModel?.provider.provider || '',
model: defaultModel?.model || '',
},
) )
return { return {

@ -94,7 +94,6 @@ const SystemModel: FC<SystemModelSelectorProps> = ({
model_settings: [ModelTypeEnum.textGeneration, ModelTypeEnum.textEmbedding, ModelTypeEnum.rerank, ModelTypeEnum.speech2text, ModelTypeEnum.tts].map((modelType) => { model_settings: [ModelTypeEnum.textGeneration, ModelTypeEnum.textEmbedding, ModelTypeEnum.rerank, ModelTypeEnum.speech2text, ModelTypeEnum.tts].map((modelType) => {
return { return {
model_type: modelType, model_type: modelType,
plugin_id: getCurrentDefaultModelByModelType(modelType)?.plugin_id,
provider: getCurrentDefaultModelByModelType(modelType)?.provider, provider: getCurrentDefaultModelByModelType(modelType)?.provider,
model: getCurrentDefaultModelByModelType(modelType)?.model, model: getCurrentDefaultModelByModelType(modelType)?.model,
} }

@ -38,11 +38,11 @@ import type {
import type { RETRIEVE_METHOD } from '@/types/app' import type { RETRIEVE_METHOD } from '@/types/app'
import type { SystemFeatures } from '@/types/feature' import type { SystemFeatures } from '@/types/feature'
type LoginSuccess = { interface LoginSuccess {
result: 'success' result: 'success'
data: { access_token: string;refresh_token: string } data: { access_token: string;refresh_token: string }
} }
type LoginFail = { interface LoginFail {
result: 'fail' result: 'fail'
data: string data: string
code: string code: string
@ -183,7 +183,7 @@ export const fetchModelProviders: Fetcher<{ data: ModelProvider[] }, string> = (
return get<{ data: ModelProvider[] }>(url) return get<{ data: ModelProvider[] }>(url)
} }
export type ModelProviderCredentials = { export interface ModelProviderCredentials {
credentials?: Record<string, string | undefined | boolean> credentials?: Record<string, string | undefined | boolean>
load_balancing: ModelLoadBalancingConfig load_balancing: ModelLoadBalancingConfig
} }
@ -297,7 +297,7 @@ export const moderate = (url: string, body: { app_id: string; text: string }) =>
return post(url, { body }) as Promise<ModerateResponse> return post(url, { body }) as Promise<ModerateResponse>
} }
type RetrievalMethodsRes = { interface RetrievalMethodsRes {
retrieval_method: RETRIEVE_METHOD[] retrieval_method: RETRIEVE_METHOD[]
} }
export const fetchSupportRetrievalMethods: Fetcher<RetrievalMethodsRes, string> = (url) => { export const fetchSupportRetrievalMethods: Fetcher<RetrievalMethodsRes, string> = (url) => {

Loading…
Cancel
Save