feat: Hints for tools and agent (#13386)

This commit is contained in:
Michael Kret
2025-03-12 19:08:08 +02:00
committed by GitHub
parent 1d559861f1
commit ec8a719efa
2 changed files with 75 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ import type {
NodeHint,
Workflow,
} from 'n8n-workflow';
import { NodeHelpers } from 'n8n-workflow';
import { NodeHelpers, SEND_AND_WAIT_OPERATION } from 'n8n-workflow';
import type { RouteLocation } from 'vue-router';
/*
@@ -280,6 +280,19 @@ export function getGenericHints({
}) {
const nodeHints: NodeHint[] = [];
// tools hints
if (node?.type.toLocaleLowerCase().includes('tool') && hasNodeRun) {
const stringifiedParameters = JSON.stringify(workflowNode.parameters);
if (!stringifiedParameters.includes('$fromAI')) {
nodeHints.push({
message:
'No parameters are set up to be filled by AI. Click on the ✨ button next to a parameter to allow AI to set its value.',
location: 'outputPane',
whenToDisplay: 'afterExecution',
});
}
}
// add limit reached hint
if (hasNodeRun && workflowNode.parameters.limit) {
if (nodeOutputData.length === workflowNode.parameters.limit) {
@@ -306,6 +319,17 @@ export function getGenericHints({
}
}
// add sendAndWait hint
if (hasMultipleInputItems && workflowNode.parameters.operation === SEND_AND_WAIT_OPERATION) {
const executeOnce = workflow.getNode(node.name)?.executeOnce;
if (!executeOnce) {
nodeHints.push({
message: 'This action will run only once, for the first input item',
location: 'outputPane',
});
}
}
// add expression in field name hint for Set node
if (node.type === SET_NODE_TYPE && node.parameters.mode === 'manual') {
const rawParameters = NodeHelpers.getNodeParameters(