parent
c82b641357
commit
22766c27c7
@ -110,7 +110,7 @@ const ModelProviderPage = ({ searchText }: Props) => {
|
|||||||
if (configurationMethod === ConfigurationMethodEnum.customizableModel && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
|
if (configurationMethod === ConfigurationMethodEnum.customizableModel && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
|
||||||
eventEmitter?.emit({
|
eventEmitter?.emit({
|
||||||
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
|
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
|
||||||
payload: provider,
|
payload: provider.provider,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
if (CustomConfigurationModelFixedFields?.__model_type)
|
if (CustomConfigurationModelFixedFields?.__model_type)
|
||||||
|
@ -57,7 +57,7 @@ const CredentialPanel: FC<CredentialPanelProps> = ({
|
|||||||
|
|
||||||
eventEmitter?.emit({
|
eventEmitter?.emit({
|
||||||
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
|
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
|
||||||
payload: provider,
|
payload: provider.provider,
|
||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,12 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({
|
|||||||
const showQuota = systemConfig.enabled && [...MODEL_PROVIDER_QUOTA_GET_PAID].includes(provider.provider) && !IS_CE_EDITION
|
const showQuota = systemConfig.enabled && [...MODEL_PROVIDER_QUOTA_GET_PAID].includes(provider.provider) && !IS_CE_EDITION
|
||||||
const showCredential = configurationMethods.includes(ConfigurationMethodEnum.predefinedModel) && isCurrentWorkspaceManager
|
const showCredential = configurationMethods.includes(ConfigurationMethodEnum.predefinedModel) && isCurrentWorkspaceManager
|
||||||
|
|
||||||
const getModelList = async (pluginID: string, providerName: string) => {
|
const getModelList = async (providerName: string) => {
|
||||||
if (loading)
|
if (loading)
|
||||||
return
|
return
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${pluginID}/${providerName}/models`)
|
const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${providerName}/models`)
|
||||||
setModelList(modelsData.data)
|
setModelList(modelsData.data)
|
||||||
setCollapsed(false)
|
setCollapsed(false)
|
||||||
setFetched(true)
|
setFetched(true)
|
||||||
@ -72,12 +72,12 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
getModelList(provider.plugin_id, provider.provider)
|
getModelList(provider.provider)
|
||||||
}
|
}
|
||||||
|
|
||||||
eventEmitter?.useSubscription((v: any) => {
|
eventEmitter?.useSubscription((v: any) => {
|
||||||
if (v?.type === UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST && v.payload.provider === provider.provider)
|
if (v?.type === UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST && v.payload === provider.provider)
|
||||||
getModelList(v.payload.plugin_id, v.payload.provider)
|
getModelList(v.payload)
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -172,7 +172,7 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({
|
|||||||
models={modelList}
|
models={modelList}
|
||||||
onCollapse={() => setCollapsed(true)}
|
onCollapse={() => setCollapsed(true)}
|
||||||
onConfig={currentCustomConfigurationModelFixedFields => onOpenModal(ConfigurationMethodEnum.customizableModel, currentCustomConfigurationModelFixedFields)}
|
onConfig={currentCustomConfigurationModelFixedFields => onOpenModal(ConfigurationMethodEnum.customizableModel, currentCustomConfigurationModelFixedFields)}
|
||||||
onChange={(provider: ModelProvider) => getModelList(provider.plugin_id, provider.provider)}
|
onChange={(provider: string) => getModelList(provider)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ type ModelListProps = {
|
|||||||
models: ModelItem[]
|
models: ModelItem[]
|
||||||
onCollapse: () => void
|
onCollapse: () => void
|
||||||
onConfig: (currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields) => void
|
onConfig: (currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields) => void
|
||||||
onChange?: (provider: ModelProvider) => void
|
onChange?: (provider: string) => void
|
||||||
}
|
}
|
||||||
const ModelList: FC<ModelListProps> = ({
|
const ModelList: FC<ModelListProps> = ({
|
||||||
provider,
|
provider,
|
||||||
|
@ -19,7 +19,7 @@ export type ModelLoadBalancingModalProps = {
|
|||||||
model: ModelItem
|
model: ModelItem
|
||||||
open?: boolean
|
open?: boolean
|
||||||
onClose?: () => void
|
onClose?: () => void
|
||||||
onSave?: (provider: ModelProvider) => void
|
onSave?: (provider: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
// model balancing config modal
|
// model balancing config modal
|
||||||
@ -94,7 +94,7 @@ const ModelLoadBalancingModal = ({ provider, model, open = false, onClose, onSav
|
|||||||
if (res.result === 'success') {
|
if (res.result === 'success') {
|
||||||
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
||||||
mutate()
|
mutate()
|
||||||
onSave?.(provider)
|
onSave?.(provider.provider)
|
||||||
onClose?.()
|
onClose?.()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ import OpeningSettingModal from '@/app/components/base/features/new-feature-pane
|
|||||||
import type { OpeningStatement } from '@/app/components/base/features/types'
|
import type { OpeningStatement } from '@/app/components/base/features/types'
|
||||||
import type { InputVar } from '@/app/components/workflow/types'
|
import type { InputVar } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
export type ModalState<T> = {
|
export interface ModalState<T> {
|
||||||
payload: T
|
payload: T
|
||||||
onCancelCallback?: () => void
|
onCancelCallback?: () => void
|
||||||
onSaveCallback?: (newPayload: T) => void
|
onSaveCallback?: (newPayload: T) => void
|
||||||
@ -43,7 +43,7 @@ export type ModalState<T> = {
|
|||||||
datasetBindings?: { id: string; name: string }[]
|
datasetBindings?: { id: string; name: string }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ModelModalType = {
|
export interface ModelModalType {
|
||||||
currentProvider: ModelProvider
|
currentProvider: ModelProvider
|
||||||
currentConfigurationMethod: ConfigurationMethodEnum
|
currentConfigurationMethod: ConfigurationMethodEnum
|
||||||
currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields
|
currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields
|
||||||
@ -52,7 +52,7 @@ export type LoadBalancingEntryModalType = ModelModalType & {
|
|||||||
entry?: ModelLoadBalancingConfigEntry
|
entry?: ModelLoadBalancingConfigEntry
|
||||||
index?: number
|
index?: number
|
||||||
}
|
}
|
||||||
export type ModalContextState = {
|
export interface ModalContextState {
|
||||||
setShowAccountSettingModal: Dispatch<SetStateAction<ModalState<string> | null>>
|
setShowAccountSettingModal: Dispatch<SetStateAction<ModalState<string> | null>>
|
||||||
setShowApiBasedExtensionModal: Dispatch<SetStateAction<ModalState<ApiBasedExtension> | null>>
|
setShowApiBasedExtensionModal: Dispatch<SetStateAction<ModalState<ApiBasedExtension> | null>>
|
||||||
setShowModerationSettingModal: Dispatch<SetStateAction<ModalState<ModerationConfig> | null>>
|
setShowModerationSettingModal: Dispatch<SetStateAction<ModalState<ModerationConfig> | null>>
|
||||||
@ -90,7 +90,7 @@ export const useModalContext = () => useContext(ModalContext)
|
|||||||
export const useModalContextSelector = <T,>(selector: (state: ModalContextState) => T): T =>
|
export const useModalContextSelector = <T,>(selector: (state: ModalContextState) => T): T =>
|
||||||
useContextSelector(ModalContext, selector)
|
useContextSelector(ModalContext, selector)
|
||||||
|
|
||||||
type ModalContextProviderProps = {
|
interface ModalContextProviderProps {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}
|
}
|
||||||
export const ModalContextProvider = ({
|
export const ModalContextProvider = ({
|
||||||
|
Loading…
Reference in New Issue
Block a user