Refactor/model credential (#24994)

This commit is contained in:
zxhlyh 2025-09-03 13:36:59 +08:00 • committed by GitHub
commit 9e125e2029
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 1226 additions and 596 deletions

View file

@ -13,6 +13,7 @@ import type {
DefaultModel,
DefaultModelResponse,
Model,
ModelModalModeEnum,
ModelProvider,
ModelTypeEnum,
} from './declarations'
@ -348,29 +349,31 @@ export const useRefreshModel = () => {
export const useModelModalHandler = () => {
const setShowModelModal = useModalContextSelector(state => state.setShowModelModal)
const { handleRefreshModel } = useRefreshModel()
return (
provider: ModelProvider,
configurationMethod: ConfigurationMethodEnum,
CustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields,
isModelCredential?: boolean,
credential?: Credential,
model?: CustomModel,
onUpdate?: () => void,
extra: {
isModelCredential?: boolean,
credential?: Credential,
model?: CustomModel,
onUpdate?: (newPayload: any, formValues?: Record<string, any>) => void,
mode?: ModelModalModeEnum,
} = {},
) => {
setShowModelModal({
payload: {
currentProvider: provider,
currentConfigurationMethod: configurationMethod,
currentCustomConfigurationModelFixedFields: CustomConfigurationModelFixedFields,
isModelCredential,
credential,
model,
isModelCredential: extra.isModelCredential,
credential: extra.credential,
model: extra.model,
mode: extra.mode,
},
onSaveCallback: () => {
handleRefreshModel(provider, configurationMethod, CustomConfigurationModelFixedFields)
onUpdate?.()
onSaveCallback: (newPayload, formValues) => {
extra.onUpdate?.(newPayload, formValues)
},
})
}