feat: add HumanInput block support with output variable handling and integration

This commit is contained in:
twwu 2025-12-25 15:51:19 +08:00
parent 8b65b689f7
commit b8d4f60782
5 changed files with 32 additions and 5 deletions

View File

@ -128,6 +128,7 @@ export const SUPPORT_OUTPUT_VARS_NODE = [
BlockEnum.ListFilter,
BlockEnum.Agent,
BlockEnum.DataSource,
BlockEnum.HumanInput,
]
export const AGENT_OUTPUT_STRUCT: Var[] = [

View File

@ -116,7 +116,7 @@ export const useWorkflowVariables = () => {
schemaTypeDefinitions,
preferSchemaType,
})
}, [workflowStore, getVarType, schemaTypeDefinitions, buildInTools, customTools, workflowTools, mcpTools])
}, [workflowStore, schemaTypeDefinitions, buildInTools, customTools, workflowTools, mcpTools])
return {
getNodeAvailableVars,

View File

@ -15,6 +15,7 @@ import type { QuestionClassifierNodeType } from '../../../question-classifier/ty
import type { TemplateTransformNodeType } from '../../../template-transform/types'
import type { ToolNodeType } from '../../../tool/types'
import type { DataSourceNodeType } from '@/app/components/workflow/nodes/data-source/types'
import type { HumanInputNodeType } from '@/app/components/workflow/nodes/human-input/types'
import type { CaseItem, Condition } from '@/app/components/workflow/nodes/if-else/types'
import type { Field as StructField } from '@/app/components/workflow/nodes/llm/types'
import type { StartNodeType } from '@/app/components/workflow/nodes/start/types'
@ -49,6 +50,7 @@ import {
TOOL_OUTPUT_STRUCT,
} from '@/app/components/workflow/constants'
import DataSourceNodeDefault from '@/app/components/workflow/nodes/data-source/default'
import HumanInputNodeDefault from '@/app/components/workflow/nodes/human-input/default'
import ToolNodeDefault from '@/app/components/workflow/nodes/tool/default'
import PluginTriggerNodeDefault from '@/app/components/workflow/nodes/trigger-plugin/default'
import {
@ -630,6 +632,17 @@ const formatItem = (
break
}
case BlockEnum.HumanInput: {
const outputSchema = HumanInputNodeDefault.getOutputVars?.(
data as HumanInputNodeType,
allPluginInfoList,
[],
{ schemaTypeDefinitions },
) || []
res.vars = outputSchema
break
}
case 'env': {
res.vars = data.envList.map((env: EnvironmentVariable) => {
return {

View File

@ -1,7 +1,7 @@
import type { NodeDefault } from '../../types'
import type { NodeDefault, Var } from '../../types'
import type { HumanInputNodeType } from './types'
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
import { BlockEnum } from '@/app/components/workflow/types'
import { BlockEnum, VarType } from '@/app/components/workflow/types'
// import { DeliveryMethodType, UserActionButtonType } from './types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
@ -13,11 +13,22 @@ const metaData = genNodeMetaData({
type: BlockEnum.HumanInput,
})
const buildOutputVars = (variables: string[]): Var[] => {
return variables.map((variable) => {
return {
variable,
type: VarType.string,
}
})
}
const nodeDefault: NodeDefault<HumanInputNodeType> = {
metaData,
defaultValue: {
delivery_methods: [],
user_actions: [],
form_content: '',
inputs: [],
timeout: 3,
timeout_unit: 'day',
},
@ -46,6 +57,10 @@ const nodeDefault: NodeDefault<HumanInputNodeType> = {
errorMessage: errorMessages,
}
},
getOutputVars(payload, _allPluginInfoList, _ragVars) {
const variables = payload.inputs.map(input => input.output_variable_name)
return buildOutputVars(variables)
},
}
export default nodeDefault

View File

@ -2,7 +2,6 @@ import type {
CommonNodeType,
InputVarType,
ValueSelector,
Variable,
} from '@/app/components/workflow/types'
export type HumanInputNodeType = CommonNodeType & {
@ -12,7 +11,6 @@ export type HumanInputNodeType = CommonNodeType & {
user_actions: UserAction[]
timeout: number
timeout_unit: 'hour' | 'day'
outputs: Variable[]
}
export enum DeliveryMethodType {