feat: agent node checklist

This commit is contained in:
AkaraChen
2025-01-02 11:29:10 +08:00
parent 4663af8a60
commit 1b8ec6710a
14 changed files with 107 additions and 35 deletions

View File

@ -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: '',
}
},
}