mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 19:11:13 +00:00
feat(core): Implement wrapping of regular nodes as AI Tools (#10641)
Co-authored-by: JP van Oosten <jp@n8n.io>
This commit is contained in:
@@ -159,6 +159,7 @@ import { InstanceSettings } from './InstanceSettings';
|
||||
import { ScheduledTaskManager } from './ScheduledTaskManager';
|
||||
import { SSHClientsManager } from './SSHClientsManager';
|
||||
import { binaryToBuffer } from './BinaryData/utils';
|
||||
import { getNodeAsTool } from './CreateNodeAsTool';
|
||||
|
||||
axios.defaults.timeout = 300000;
|
||||
// Prevent axios from adding x-form-www-urlencoded headers by default
|
||||
@@ -2780,12 +2781,6 @@ async function getInputConnectionData(
|
||||
connectedNode.typeVersion,
|
||||
);
|
||||
|
||||
if (!nodeType.supplyData) {
|
||||
throw new ApplicationError('Node does not have a `supplyData` method defined', {
|
||||
extra: { nodeName: connectedNode.name },
|
||||
});
|
||||
}
|
||||
|
||||
const context = Object.assign({}, this);
|
||||
|
||||
context.getNodeParameter = (
|
||||
@@ -2853,6 +2848,18 @@ async function getInputConnectionData(
|
||||
}
|
||||
};
|
||||
|
||||
if (!nodeType.supplyData) {
|
||||
if (nodeType.description.outputs.includes(NodeConnectionType.AiTool)) {
|
||||
nodeType.supplyData = async function (this: IExecuteFunctions) {
|
||||
return getNodeAsTool(this, nodeType, this.getNode().parameters);
|
||||
};
|
||||
} else {
|
||||
throw new ApplicationError('Node does not have a `supplyData` method defined', {
|
||||
extra: { nodeName: connectedNode.name },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await nodeType.supplyData.call(context, itemIndex);
|
||||
if (response.closeFunction) {
|
||||
|
||||
Reference in New Issue
Block a user