mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
feat: agent node checklist
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import type { StrategyDetail, StrategyPluginDetail } from '@/app/components/plugins/types'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '../../constants'
|
||||
import type { NodeDefault } from '../../types'
|
||||
import type { AgentNodeType } from './types'
|
||||
@ -15,16 +16,29 @@ const nodeDefault: NodeDefault<AgentNodeType> = {
|
||||
? ALL_CHAT_AVAILABLE_BLOCKS
|
||||
: ALL_COMPLETION_AVAILABLE_BLOCKS
|
||||
},
|
||||
checkValid(payload, t, moreDataForCheckValid) {
|
||||
let isValid = true
|
||||
let errorMessages = ''
|
||||
if (payload.type) {
|
||||
isValid = true
|
||||
errorMessages = ''
|
||||
checkValid(payload, t, moreDataForCheckValid: {
|
||||
strategyProvider: StrategyPluginDetail | undefined,
|
||||
strategy: StrategyDetail | undefined
|
||||
}) {
|
||||
const { strategy } = moreDataForCheckValid
|
||||
if (!strategy) {
|
||||
return {
|
||||
isValid: false,
|
||||
errorMessage: 'Please select a strategy',
|
||||
}
|
||||
}
|
||||
for (const param of strategy.parameters) {
|
||||
if (param.required && !payload.agent_parameters?.[param.name]?.value) {
|
||||
return {
|
||||
isValid: false,
|
||||
errorMessage: `Please select ${param.name}`,
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: tool selector valid?
|
||||
return {
|
||||
isValid,
|
||||
errorMessage: errorMessages,
|
||||
isValid: true,
|
||||
errorMessage: '',
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user