mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(HTTP Request Tool Node): Use DynamicStructuredTool with models supporting it (no-changelog) (#10246)
This commit is contained in:
@@ -12,6 +12,7 @@ import { NodeConnectionType, NodeOperationError, tryToParseAlphanumericString }
|
||||
import { DynamicTool } from '@langchain/core/tools';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { N8nTool } from '../../../utils/N8nTool';
|
||||
import {
|
||||
configureHttpRequestFunction,
|
||||
configureResponseOptimizer,
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
prepareToolDescription,
|
||||
configureToolFunction,
|
||||
updateParametersAndOptions,
|
||||
makeToolInputSchema,
|
||||
} from './utils';
|
||||
|
||||
import {
|
||||
@@ -38,7 +40,7 @@ export class ToolHttpRequest implements INodeType {
|
||||
name: 'toolHttpRequest',
|
||||
icon: { light: 'file:httprequest.svg', dark: 'file:httprequest.dark.svg' },
|
||||
group: ['output'],
|
||||
version: 1,
|
||||
version: [1, 1.1],
|
||||
description: 'Makes an HTTP request and returns the response data',
|
||||
subtitle: '={{ $parameter.toolDescription }}',
|
||||
defaults: {
|
||||
@@ -394,9 +396,24 @@ export class ToolHttpRequest implements INodeType {
|
||||
optimizeResponse,
|
||||
);
|
||||
|
||||
const description = prepareToolDescription(toolDescription, toolParameters);
|
||||
let tool: DynamicTool | N8nTool;
|
||||
|
||||
const tool = new DynamicTool({ name, description, func });
|
||||
// If the node version is 1.1 or higher, we use the N8nTool wrapper:
|
||||
// it allows to use tool as a DynamicStructuredTool and have a fallback to DynamicTool
|
||||
if (this.getNode().typeVersion >= 1.1) {
|
||||
const schema = makeToolInputSchema(toolParameters);
|
||||
|
||||
tool = new N8nTool(this, {
|
||||
name,
|
||||
description: toolDescription,
|
||||
func,
|
||||
schema,
|
||||
});
|
||||
} else {
|
||||
// Keep the old behavior for nodes with version 1.0
|
||||
const description = prepareToolDescription(toolDescription, toolParameters);
|
||||
tool = new DynamicTool({ name, description, func });
|
||||
}
|
||||
|
||||
return {
|
||||
response: tool,
|
||||
|
||||
Reference in New Issue
Block a user