mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
parent
c82b641357
commit
22766c27c7
|
@ -110,7 +110,7 @@ const ModelProviderPage = ({ searchText }: Props) => {
|
|||
if (configurationMethod === ConfigurationMethodEnum.customizableModel && provider.custom_configuration.status === CustomConfigurationStatusEnum.active) {
|
||||
eventEmitter?.emit({
|
||||
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
|
||||
payload: provider,
|
||||
payload: provider.provider,
|
||||
} as any)
|
||||
|
||||
if (CustomConfigurationModelFixedFields?.__model_type)
|
||||
|
|
|
@ -57,7 +57,7 @@ const CredentialPanel: FC<CredentialPanelProps> = ({
|
|||
|
||||
eventEmitter?.emit({
|
||||
type: UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST,
|
||||
payload: provider,
|
||||
payload: provider.provider,
|
||||
} 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 showCredential = configurationMethods.includes(ConfigurationMethodEnum.predefinedModel) && isCurrentWorkspaceManager
|
||||
|
||||
const getModelList = async (pluginID: string, providerName: string) => {
|
||||
const getModelList = async (providerName: string) => {
|
||||
if (loading)
|
||||
return
|
||||
try {
|
||||
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)
|
||||
setCollapsed(false)
|
||||
setFetched(true)
|
||||
|
@ -72,12 +72,12 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({
|
|||
return
|
||||
}
|
||||
|
||||
getModelList(provider.plugin_id, provider.provider)
|
||||
getModelList(provider.provider)
|
||||
}
|
||||
|
||||
eventEmitter?.useSubscription((v: any) => {
|
||||
if (v?.type === UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST && v.payload.provider === provider.provider)
|
||||
getModelList(v.payload.plugin_id, v.payload.provider)
|
||||
if (v?.type === UPDATE_MODEL_PROVIDER_CUSTOM_MODEL_LIST && v.payload === provider.provider)
|
||||
getModelList(v.payload)
|
||||
})
|
||||
|
||||
return (
|
||||
|
@ -172,7 +172,7 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({
|
|||
models={modelList}
|
||||
onCollapse={() => setCollapsed(true)}
|
||||
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[]
|
||||
onCollapse: () => void
|
||||
onConfig: (currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields) => void
|
||||
onChange?: (provider: ModelProvider) => void
|
||||
onChange?: (provider: string) => void
|
||||
}
|
||||
const ModelList: FC<ModelListProps> = ({
|
||||
provider,
|
||||
|
|
|
@ -19,7 +19,7 @@ export type ModelLoadBalancingModalProps = {
|
|||
model: ModelItem
|
||||
open?: boolean
|
||||
onClose?: () => void
|
||||
onSave?: (provider: ModelProvider) => void
|
||||
onSave?: (provider: string) => void
|
||||
}
|
||||
|
||||
// model balancing config modal
|
||||
|
@ -94,7 +94,7 @@ const ModelLoadBalancingModal = ({ provider, model, open = false, onClose, onSav
|
|||
if (res.result === 'success') {
|
||||
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
|
||||
mutate()
|
||||
onSave?.(provider)
|
||||
onSave?.(provider.provider)
|
||||
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 { InputVar } from '@/app/components/workflow/types'
|
||||
|
||||
export type ModalState<T> = {
|
||||
export interface ModalState<T> {
|
||||
payload: T
|
||||
onCancelCallback?: () => void
|
||||
onSaveCallback?: (newPayload: T) => void
|
||||
|
@ -43,7 +43,7 @@ export type ModalState<T> = {
|
|||
datasetBindings?: { id: string; name: string }[]
|
||||
}
|
||||
|
||||
export type ModelModalType = {
|
||||
export interface ModelModalType {
|
||||
currentProvider: ModelProvider
|
||||
currentConfigurationMethod: ConfigurationMethodEnum
|
||||
currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields
|
||||
|
@ -52,7 +52,7 @@ export type LoadBalancingEntryModalType = ModelModalType & {
|
|||
entry?: ModelLoadBalancingConfigEntry
|
||||
index?: number
|
||||
}
|
||||
export type ModalContextState = {
|
||||
export interface ModalContextState {
|
||||
setShowAccountSettingModal: Dispatch<SetStateAction<ModalState<string> | null>>
|
||||
setShowApiBasedExtensionModal: Dispatch<SetStateAction<ModalState<ApiBasedExtension> | 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 =>
|
||||
useContextSelector(ModalContext, selector)
|
||||
|
||||
type ModalContextProviderProps = {
|
||||
interface ModalContextProviderProps {
|
||||
children: React.ReactNode
|
||||
}
|
||||
export const ModalContextProvider = ({
|
||||
|
|
Loading…
Reference in New Issue
Block a user