* Determine the tool input type based on the chatflow type and flowData. * For AGENTFLOW, we look for a `startAgentflow` node and check its `startInputType` property. * If it's `formInput`, we return 'form', otherwise 'question'. * For other flow types, we default to 'question'.
(chatflow: ChatFlow)
| 44 | * For other flow types, we default to 'question'. |
| 45 | */ |
| 46 | function getToolInputType(chatflow: ChatFlow): 'question' | 'form' { |
| 47 | if (chatflow.type === 'AGENTFLOW') { |
| 48 | try { |
| 49 | const flowData: IReactFlowObject = JSON.parse(chatflow.flowData) |
| 50 | const nodes = flowData.nodes || [] |
| 51 | const startNode = nodes.find((node) => node.data.name === 'startAgentflow') |
| 52 | const startInputType = startNode?.data?.inputs?.startInputType as StartInputType | undefined |
| 53 | return startInputType === 'formInput' ? 'form' : 'question' |
| 54 | } catch (error) { |
| 55 | logger.error(`Failed to parse flowData for chatflow ${chatflow.id}: ${getErrorMessage(error)}`) |
| 56 | return 'question' |
| 57 | } |
| 58 | } |
| 59 | return 'question' |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Build the zod input schema parameters for the tool. |
no test coverage detected