@n8n/n8n-nodes-langchain 1.89.0 → 1.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/credentials/OpenRouterApi.credentials.js +1 -1
- package/dist/credentials/OpenRouterApi.credentials.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js +5 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js.map +1 -1
- package/dist/nodes/chains/TextClassifier/TextClassifier.node.js +14 -0
- package/dist/nodes/chains/TextClassifier/TextClassifier.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +5 -5
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
- package/dist/nodes/mcp/McpTrigger/McpServer.js +2 -1
- package/dist/nodes/mcp/McpTrigger/McpServer.js.map +1 -1
- package/dist/nodes/memory/MemoryBufferWindow/MemoryBufferWindow.node.js +2 -1
- package/dist/nodes/memory/MemoryBufferWindow/MemoryBufferWindow.node.js.map +1 -1
- package/dist/nodes/memory/MemoryMongoDbChat/MemoryMongoDbChat.node.js +2 -1
- package/dist/nodes/memory/MemoryMongoDbChat/MemoryMongoDbChat.node.js.map +1 -1
- package/dist/nodes/memory/MemoryMotorhead/MemoryMotorhead.node.js +2 -1
- package/dist/nodes/memory/MemoryMotorhead/MemoryMotorhead.node.js.map +1 -1
- package/dist/nodes/memory/MemoryPostgresChat/MemoryPostgresChat.node.js +2 -1
- package/dist/nodes/memory/MemoryPostgresChat/MemoryPostgresChat.node.js.map +1 -1
- package/dist/nodes/memory/MemoryRedisChat/MemoryRedisChat.node.js +2 -1
- package/dist/nodes/memory/MemoryRedisChat/MemoryRedisChat.node.js.map +1 -1
- package/dist/nodes/memory/MemoryXata/MemoryXata.node.js +2 -1
- package/dist/nodes/memory/MemoryXata/MemoryXata.node.js.map +1 -1
- package/dist/nodes/memory/MemoryZep/MemoryZep.node.js +2 -1
- package/dist/nodes/memory/MemoryZep/MemoryZep.node.js.map +1 -1
- package/dist/nodes/tools/ToolCode/ToolCode.node.js +5 -3
- package/dist/nodes/tools/ToolCode/ToolCode.node.js.map +1 -1
- package/dist/nodes/tools/ToolHttpRequest/ToolHttpRequest.node.js +2 -0
- package/dist/nodes/tools/ToolHttpRequest/ToolHttpRequest.node.js.map +1 -1
- package/dist/nodes/tools/ToolVectorStore/ToolVectorStore.node.js +11 -3
- package/dist/nodes/tools/ToolVectorStore/ToolVectorStore.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/ToolWorkflow.node.js +3 -2
- package/dist/nodes/tools/ToolWorkflow/ToolWorkflow.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.js +5 -2
- package/dist/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/methods/localResourceMapping.js +3 -1
- package/dist/nodes/tools/ToolWorkflow/v2/methods/localResourceMapping.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/versionDescription.js +7 -2
- package/dist/nodes/tools/ToolWorkflow/v2/versionDescription.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js +64 -4
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js +1 -1
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js.map +1 -1
- package/dist/types/credentials.json +1 -1
- package/dist/types/nodes.json +13 -13
- package/dist/utils/helpers.js +5 -0
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/logWrapper.js +2 -1
- package/dist/utils/logWrapper.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/memory/MemoryRedisChat/MemoryRedisChat.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport type { RedisChatMessageHistoryInput } from '@langchain/redis';\nimport { RedisChatMessageHistory } from '@langchain/redis';\nimport { BufferMemory, BufferWindowMemory } from 'langchain/memory';\nimport {\n\tNodeOperationError,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n\tNodeConnectionTypes,\n} from 'n8n-workflow';\nimport type { RedisClientOptions } from 'redis';\nimport { createClient } from 'redis';\n\nimport { getSessionId } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport {\n\tsessionIdOption,\n\tsessionKeyProperty,\n\tcontextWindowLengthProperty,\n\texpressionSessionKeyProperty,\n} from '../descriptions';\n\nexport class MemoryRedisChat implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Redis Chat Memory',\n\t\tname: 'memoryRedisChat',\n\t\ticon: 'file:redis.svg',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3, 1.4, 1.5],\n\t\tdescription: 'Stores the chat history in Redis.',\n\t\tdefaults: {\n\t\t\tname: 'Redis Chat Memory',\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'redis',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Memory'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memoryredischat/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiMemory],\n\t\toutputNames: ['Memory'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Session Key',\n\t\t\t\tname: 'sessionKey',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'chat_history',\n\t\t\t\tdescription: 'The key to use to store the memory in the workflow data',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionKey',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '={{ $json.sessionId }}',\n\t\t\t\tdescription: 'The key to use to store the memory',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...sessionIdOption,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\texpressionSessionKeyProperty(1.4),\n\t\t\tsessionKeyProperty,\n\t\t\t{\n\t\t\t\tdisplayName: 'Session Time To Live',\n\t\t\t\tname: 'sessionTTL',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 0,\n\t\t\t\tdescription:\n\t\t\t\t\t'For how long the session should be stored in seconds. If set to 0 it will not expire.',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...contextWindowLengthProperty,\n\t\t\t\tdisplayOptions: { hide: { '@version': [{ _cnd: { lt: 1.3 } }] } },\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('redis');\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tconst sessionTTL = this.getNodeParameter('sessionTTL', itemIndex, 0) as number;\n\n\t\tlet sessionId;\n\n\t\tif (nodeVersion >= 1.2) {\n\t\t\tsessionId = getSessionId(this, itemIndex);\n\t\t} else {\n\t\t\tsessionId = this.getNodeParameter('sessionKey', itemIndex) as string;\n\t\t}\n\n\t\tconst redisOptions: RedisClientOptions = {\n\t\t\tsocket: {\n\t\t\t\thost: credentials.host as string,\n\t\t\t\tport: credentials.port as number,\n\t\t\t\ttls: credentials.ssl === true,\n\t\t\t},\n\t\t\tdatabase: credentials.database as number,\n\t\t};\n\n\t\tif (credentials.user && nodeVersion >= 1.5) {\n\t\t\tredisOptions.username = credentials.user as string;\n\t\t}\n\t\tif (credentials.password) {\n\t\t\tredisOptions.password = credentials.password as string;\n\t\t}\n\n\t\tconst client = createClient({\n\t\t\t...redisOptions,\n\t\t});\n\n\t\tclient.on('error', async (error: Error) => {\n\t\t\tawait client.quit();\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Redis Error: ' + error.message);\n\t\t});\n\n\t\tconst redisChatConfig: RedisChatMessageHistoryInput = {\n\t\t\tclient,\n\t\t\tsessionId,\n\t\t};\n\n\t\tif (sessionTTL > 0) {\n\t\t\tredisChatConfig.sessionTTL = sessionTTL;\n\t\t}\n\t\tconst redisChatHistory = new RedisChatMessageHistory(redisChatConfig);\n\n\t\tconst memClass = this.getNode().typeVersion < 1.3 ? BufferMemory : BufferWindowMemory;\n\t\tconst kOptions =\n\t\t\tthis.getNode().typeVersion < 1.3\n\t\t\t\t? {}\n\t\t\t\t: { k: this.getNodeParameter('contextWindowLength', itemIndex) };\n\n\t\tconst memory = new memClass({\n\t\t\tmemoryKey: 'chat_history',\n\t\t\tchatHistory: redisChatHistory,\n\t\t\treturnMessages: true,\n\t\t\tinputKey: 'input',\n\t\t\toutputKey: 'output',\n\t\t\t...kOptions,\n\t\t});\n\n\t\tasync function closeFunction() {\n\t\t\tvoid client.disconnect();\n\t\t}\n\n\t\treturn {\n\t\t\tcloseFunction,\n\t\t\tresponse: logWrapper(memory, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAwC;AACxC,oBAAiD;AACjD,0BAOO;AAEP,IAAAA,gBAA6B;AAE7B,qBAA6B;AAC7B,wBAA2B;AAC3B,0BAA6C;AAE7C,0BAKO;AAEA,MAAM,gBAAqC;AAAA,EAA3C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,MACpC,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,QAAQ;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/memory/MemoryRedisChat/MemoryRedisChat.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport type { RedisChatMessageHistoryInput } from '@langchain/redis';\nimport { RedisChatMessageHistory } from '@langchain/redis';\nimport { BufferMemory, BufferWindowMemory } from 'langchain/memory';\nimport {\n\tNodeOperationError,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n\tNodeConnectionTypes,\n} from 'n8n-workflow';\nimport type { RedisClientOptions } from 'redis';\nimport { createClient } from 'redis';\n\nimport { getSessionId } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport {\n\tsessionIdOption,\n\tsessionKeyProperty,\n\tcontextWindowLengthProperty,\n\texpressionSessionKeyProperty,\n} from '../descriptions';\n\nexport class MemoryRedisChat implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Redis Chat Memory',\n\t\tname: 'memoryRedisChat',\n\t\ticon: 'file:redis.svg',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3, 1.4, 1.5],\n\t\tdescription: 'Stores the chat history in Redis.',\n\t\tdefaults: {\n\t\t\tname: 'Redis Chat Memory',\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'redis',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Memory'],\n\t\t\t\tMemory: ['Other memories'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memoryredischat/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiMemory],\n\t\toutputNames: ['Memory'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Session Key',\n\t\t\t\tname: 'sessionKey',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'chat_history',\n\t\t\t\tdescription: 'The key to use to store the memory in the workflow data',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionKey',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '={{ $json.sessionId }}',\n\t\t\t\tdescription: 'The key to use to store the memory',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...sessionIdOption,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\texpressionSessionKeyProperty(1.4),\n\t\t\tsessionKeyProperty,\n\t\t\t{\n\t\t\t\tdisplayName: 'Session Time To Live',\n\t\t\t\tname: 'sessionTTL',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 0,\n\t\t\t\tdescription:\n\t\t\t\t\t'For how long the session should be stored in seconds. If set to 0 it will not expire.',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...contextWindowLengthProperty,\n\t\t\t\tdisplayOptions: { hide: { '@version': [{ _cnd: { lt: 1.3 } }] } },\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('redis');\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tconst sessionTTL = this.getNodeParameter('sessionTTL', itemIndex, 0) as number;\n\n\t\tlet sessionId;\n\n\t\tif (nodeVersion >= 1.2) {\n\t\t\tsessionId = getSessionId(this, itemIndex);\n\t\t} else {\n\t\t\tsessionId = this.getNodeParameter('sessionKey', itemIndex) as string;\n\t\t}\n\n\t\tconst redisOptions: RedisClientOptions = {\n\t\t\tsocket: {\n\t\t\t\thost: credentials.host as string,\n\t\t\t\tport: credentials.port as number,\n\t\t\t\ttls: credentials.ssl === true,\n\t\t\t},\n\t\t\tdatabase: credentials.database as number,\n\t\t};\n\n\t\tif (credentials.user && nodeVersion >= 1.5) {\n\t\t\tredisOptions.username = credentials.user as string;\n\t\t}\n\t\tif (credentials.password) {\n\t\t\tredisOptions.password = credentials.password as string;\n\t\t}\n\n\t\tconst client = createClient({\n\t\t\t...redisOptions,\n\t\t});\n\n\t\tclient.on('error', async (error: Error) => {\n\t\t\tawait client.quit();\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Redis Error: ' + error.message);\n\t\t});\n\n\t\tconst redisChatConfig: RedisChatMessageHistoryInput = {\n\t\t\tclient,\n\t\t\tsessionId,\n\t\t};\n\n\t\tif (sessionTTL > 0) {\n\t\t\tredisChatConfig.sessionTTL = sessionTTL;\n\t\t}\n\t\tconst redisChatHistory = new RedisChatMessageHistory(redisChatConfig);\n\n\t\tconst memClass = this.getNode().typeVersion < 1.3 ? BufferMemory : BufferWindowMemory;\n\t\tconst kOptions =\n\t\t\tthis.getNode().typeVersion < 1.3\n\t\t\t\t? {}\n\t\t\t\t: { k: this.getNodeParameter('contextWindowLength', itemIndex) };\n\n\t\tconst memory = new memClass({\n\t\t\tmemoryKey: 'chat_history',\n\t\t\tchatHistory: redisChatHistory,\n\t\t\treturnMessages: true,\n\t\t\tinputKey: 'input',\n\t\t\toutputKey: 'output',\n\t\t\t...kOptions,\n\t\t});\n\n\t\tasync function closeFunction() {\n\t\t\tvoid client.disconnect();\n\t\t}\n\n\t\treturn {\n\t\t\tcloseFunction,\n\t\t\tresponse: logWrapper(memory, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAwC;AACxC,oBAAiD;AACjD,0BAOO;AAEP,IAAAA,gBAA6B;AAE7B,qBAA6B;AAC7B,wBAA2B;AAC3B,0BAA6C;AAE7C,0BAKO;AAEA,MAAM,gBAAqC;AAAA,EAA3C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GA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E,cAAc,MAAM,6BAAe;AACnE,UAAM,WACL,KAAK,QAAQ,EAAE,cAAc,MAC1B,CAAC,IACD,EAAE,GAAG,KAAK,iBAAiB,uBAAuB,SAAS,EAAE;AAEjE,UAAM,SAAS,IAAI,SAAS;AAAA,MAC3B,WAAW;AAAA,MACX,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,UAAU;AAAA,MACV,WAAW;AAAA,MACX,GAAG;AAAA,IACJ,CAAC;AAED,mBAAe,gBAAgB;AAC9B,WAAK,OAAO,WAAW;AAAA,IACxB;AAEA,WAAO;AAAA,MACN;AAAA,MACA,cAAU,8BAAW,QAAQ,IAAI;AAAA,IAClC;AAAA,EACD;AACD;","names":["import_redis"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/memory/MemoryXata/MemoryXata.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { XataChatMessageHistory } from '@langchain/community/stores/message/xata';\nimport { BaseClient } from '@xata.io/client';\nimport { BufferMemory, BufferWindowMemory } from 'langchain/memory';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tISupplyDataFunctions,\n\tINodeType,\n\tINodeTypeDescription,\n\tSupplyData,\n} from 'n8n-workflow';\n\nimport { getSessionId } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport {\n\tsessionIdOption,\n\tsessionKeyProperty,\n\tcontextWindowLengthProperty,\n\texpressionSessionKeyProperty,\n} from '../descriptions';\n\nexport class MemoryXata implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Xata',\n\t\tname: 'memoryXata',\n\t\ticon: 'file:xata.svg',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3, 1.4],\n\t\tdescription: 'Use Xata Memory',\n\t\tdefaults: {\n\t\t\tname: 'Xata',\n\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-non-core-color-present\n\t\t\tcolor: '#1321A7',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Memory'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memoryxata/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiMemory],\n\t\toutputNames: ['Memory'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'xataApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\trequired: true,\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '={{ $json.sessionId }}',\n\t\t\t\tdescription: 'The key to use to store the memory',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...sessionIdOption,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tsessionKeyProperty,\n\t\t\texpressionSessionKeyProperty(1.4),\n\t\t\t{\n\t\t\t\t...contextWindowLengthProperty,\n\t\t\t\tdisplayOptions: { hide: { '@version': [{ _cnd: { lt: 1.3 } }] } },\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('xataApi');\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tlet sessionId;\n\n\t\tif (nodeVersion >= 1.2) {\n\t\t\tsessionId = getSessionId(this, itemIndex);\n\t\t} else {\n\t\t\tsessionId = this.getNodeParameter('sessionId', itemIndex) as string;\n\t\t}\n\n\t\tconst xataClient = new BaseClient({\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\tbranch: (credentials.branch as string) || 'main',\n\t\t\tdatabaseURL: credentials.databaseEndpoint as string,\n\t\t});\n\n\t\tconst table = (credentials.databaseEndpoint as string).match(\n\t\t\t/https:\\/\\/[^.]+\\.[^.]+\\.xata\\.sh\\/db\\/([^\\/:]+)/,\n\t\t);\n\n\t\tif (table === null) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'It was not possible to extract the table from the Database Endpoint.',\n\t\t\t);\n\t\t}\n\n\t\tconst chatHistory = new XataChatMessageHistory({\n\t\t\ttable: table[1],\n\t\t\tsessionId,\n\t\t\tclient: xataClient,\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t});\n\n\t\tconst memClass = this.getNode().typeVersion < 1.3 ? BufferMemory : BufferWindowMemory;\n\t\tconst kOptions =\n\t\t\tthis.getNode().typeVersion < 1.3\n\t\t\t\t? {}\n\t\t\t\t: { k: this.getNodeParameter('contextWindowLength', itemIndex) };\n\n\t\tconst memory = new memClass({\n\t\t\tchatHistory,\n\t\t\tmemoryKey: 'chat_history',\n\t\t\treturnMessages: true,\n\t\t\tinputKey: 'input',\n\t\t\toutputKey: 'output',\n\t\t\t...kOptions,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(memory, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAuC;AACvC,oBAA2B;AAC3B,oBAAiD;AACjD,0BAAwD;AAQxD,qBAA6B;AAC7B,wBAA2B;AAC3B,0BAA6C;AAE7C,0BAKO;AAEA,MAAM,WAAgC;AAAA,EAAtC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,KAAK,KAAK,KAAK,GAAG;AAAA,MAC/B,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA;AAAA,QAEN,OAAO;AAAA,MACR;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,QAAQ;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/memory/MemoryXata/MemoryXata.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { XataChatMessageHistory } from '@langchain/community/stores/message/xata';\nimport { BaseClient } from '@xata.io/client';\nimport { BufferMemory, BufferWindowMemory } from 'langchain/memory';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tISupplyDataFunctions,\n\tINodeType,\n\tINodeTypeDescription,\n\tSupplyData,\n} from 'n8n-workflow';\n\nimport { getSessionId } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport {\n\tsessionIdOption,\n\tsessionKeyProperty,\n\tcontextWindowLengthProperty,\n\texpressionSessionKeyProperty,\n} from '../descriptions';\n\nexport class MemoryXata implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Xata',\n\t\tname: 'memoryXata',\n\t\ticon: 'file:xata.svg',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3, 1.4],\n\t\tdescription: 'Use Xata Memory',\n\t\tdefaults: {\n\t\t\tname: 'Xata',\n\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-non-core-color-present\n\t\t\tcolor: '#1321A7',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Memory'],\n\t\t\t\tMemory: ['Other memories'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memoryxata/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiMemory],\n\t\toutputNames: ['Memory'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'xataApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\trequired: true,\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '={{ $json.sessionId }}',\n\t\t\t\tdescription: 'The key to use to store the memory',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...sessionIdOption,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tsessionKeyProperty,\n\t\t\texpressionSessionKeyProperty(1.4),\n\t\t\t{\n\t\t\t\t...contextWindowLengthProperty,\n\t\t\t\tdisplayOptions: { hide: { '@version': [{ _cnd: { lt: 1.3 } }] } },\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('xataApi');\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tlet sessionId;\n\n\t\tif (nodeVersion >= 1.2) {\n\t\t\tsessionId = getSessionId(this, itemIndex);\n\t\t} else {\n\t\t\tsessionId = this.getNodeParameter('sessionId', itemIndex) as string;\n\t\t}\n\n\t\tconst xataClient = new BaseClient({\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\tbranch: (credentials.branch as string) || 'main',\n\t\t\tdatabaseURL: credentials.databaseEndpoint as string,\n\t\t});\n\n\t\tconst table = (credentials.databaseEndpoint as string).match(\n\t\t\t/https:\\/\\/[^.]+\\.[^.]+\\.xata\\.sh\\/db\\/([^\\/:]+)/,\n\t\t);\n\n\t\tif (table === null) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'It was not possible to extract the table from the Database Endpoint.',\n\t\t\t);\n\t\t}\n\n\t\tconst chatHistory = new XataChatMessageHistory({\n\t\t\ttable: table[1],\n\t\t\tsessionId,\n\t\t\tclient: xataClient,\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t});\n\n\t\tconst memClass = this.getNode().typeVersion < 1.3 ? BufferMemory : BufferWindowMemory;\n\t\tconst kOptions =\n\t\t\tthis.getNode().typeVersion < 1.3\n\t\t\t\t? {}\n\t\t\t\t: { k: this.getNodeParameter('contextWindowLength', itemIndex) };\n\n\t\tconst memory = new memClass({\n\t\t\tchatHistory,\n\t\t\tmemoryKey: 'chat_history',\n\t\t\treturnMessages: true,\n\t\t\tinputKey: 'input',\n\t\t\toutputKey: 'output',\n\t\t\t...kOptions,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(memory, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAuC;AACvC,oBAA2B;AAC3B,oBAAiD;AACjD,0BAAwD;AAQxD,qBAA6B;AAC7B,wBAA2B;AAC3B,0BAA6C;AAE7C,0BAKO;AAEA,MAAM,WAAgC;AAAA,EAAtC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,KAAK,KAAK,KAAK,GAAG;AAAA,MAC/B,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA;AAAA,QAEN,OAAO;AAAA,MACR;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,QAAQ;AAAA,UACb,QAAQ,CAAC,gBAAgB;AAAA,QAC1B;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ,CAAC;AAAA;AAAA,MAET,SAAS,CAAC,wCAAoB,QAAQ;AAAA,MACtC,aAAa,CAAC,QAAQ;AAAA,MACtB,aAAa;AA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MAC1C,aAAa,YAAY;AAAA,IAC1B,CAAC;AAED,UAAM,QAAS,YAAY,iBAA4B;AAAA,MACtD;AAAA,IACD;AAEA,QAAI,UAAU,MAAM;AACnB,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAEA,UAAM,cAAc,IAAI,mCAAuB;AAAA,MAC9C,OAAO,MAAM,CAAC;AAAA,MACd;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ,YAAY;AAAA,IACrB,CAAC;AAED,UAAM,WAAW,KAAK,QAAQ,EAAE,cAAc,MAAM,6BAAe;AACnE,UAAM,WACL,KAAK,QAAQ,EAAE,cAAc,MAC1B,CAAC,IACD,EAAE,GAAG,KAAK,iBAAiB,uBAAuB,SAAS,EAAE;AAEjE,UAAM,SAAS,IAAI,SAAS;AAAA,MAC3B;AAAA,MACA,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,UAAU;AAAA,MACV,WAAW;AAAA,MACX,GAAG;AAAA,IACJ,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,QAAQ,IAAI;AAAA,IAClC;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/memory/MemoryZep/MemoryZep.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport type { BaseChatMemory } from '@langchain/community/dist/memory/chat_memory';\nimport { ZepMemory } from '@langchain/community/memory/zep';\nimport { ZepCloudMemory } from '@langchain/community/memory/zep_cloud';\nimport type { InputValues, MemoryVariables } from '@langchain/core/memory';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport {\n\tNodeConnectionTypes,\n\ttype ISupplyDataFunctions,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype SupplyData,\n\tNodeOperationError,\n} from 'n8n-workflow';\n\nimport { getSessionId } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { expressionSessionKeyProperty, sessionIdOption, sessionKeyProperty } from '../descriptions';\n\n// Extend ZepCloudMemory to trim white space in messages.\nclass WhiteSpaceTrimmedZepCloudMemory extends ZepCloudMemory {\n\toverride async loadMemoryVariables(values: InputValues): Promise<MemoryVariables> {\n\t\tconst memoryVariables = await super.loadMemoryVariables(values);\n\t\tmemoryVariables.chat_history = memoryVariables.chat_history.filter((m: BaseMessage) =>\n\t\t\tm.content.toString().trim(),\n\t\t);\n\t\treturn memoryVariables;\n\t}\n}\n\nexport class MemoryZep implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Zep',\n\t\tname: 'memoryZep',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg\n\t\ticon: 'file:zep.png',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdescription: 'Use Zep Memory',\n\t\tdefaults: {\n\t\t\tname: 'Zep',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Memory'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memoryzep/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiMemory],\n\t\toutputNames: ['Memory'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'zepApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Only works with Zep Cloud and Community edition <= v0.27.2',\n\t\t\t\tname: 'supportedVersions',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\trequired: true,\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '={{ $json.sessionId }}',\n\t\t\t\tdescription: 'The key to use to store the memory',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...sessionIdOption,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\texpressionSessionKeyProperty(1.3),\n\t\t\tsessionKeyProperty,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials<{\n\t\t\tapiKey?: string;\n\t\t\tapiUrl?: string;\n\t\t\tcloud?: boolean;\n\t\t}>('zepApi');\n\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tlet sessionId;\n\n\t\tif (nodeVersion >= 1.2) {\n\t\t\tsessionId = getSessionId(this, itemIndex);\n\t\t} else {\n\t\t\tsessionId = this.getNodeParameter('sessionId', itemIndex) as string;\n\t\t}\n\n\t\tlet memory: BaseChatMemory;\n\n\t\tif (credentials.cloud) {\n\t\t\tif (!credentials.apiKey) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'API key is required to use Zep Cloud');\n\t\t\t}\n\t\t\tmemory = new WhiteSpaceTrimmedZepCloudMemory({\n\t\t\t\tsessionId,\n\t\t\t\tapiKey: credentials.apiKey,\n\t\t\t\tmemoryType: 'perpetual',\n\t\t\t\tmemoryKey: 'chat_history',\n\t\t\t\treturnMessages: true,\n\t\t\t\tinputKey: 'input',\n\t\t\t\toutputKey: 'output',\n\t\t\t\tseparateMessages: false,\n\t\t\t});\n\t\t} else {\n\t\t\tif (!credentials.apiUrl) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'API url is required to use Zep Open Source');\n\t\t\t}\n\t\t\tmemory = new ZepMemory({\n\t\t\t\tsessionId,\n\t\t\t\tbaseURL: credentials.apiUrl,\n\t\t\t\tapiKey: credentials.apiKey,\n\t\t\t\tmemoryKey: 'chat_history',\n\t\t\t\treturnMessages: true,\n\t\t\t\tinputKey: 'input',\n\t\t\t\toutputKey: 'output',\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: logWrapper(memory, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAA0B;AAC1B,uBAA+B;AAG/B,0BAOO;AAEP,qBAA6B;AAC7B,wBAA2B;AAC3B,0BAA6C;AAE7C,0BAAkF;AAGlF,MAAM,wCAAwC,gCAAe;AAAA,EAC5D,MAAe,oBAAoB,QAA+C;AACjF,UAAM,kBAAkB,MAAM,MAAM,oBAAoB,MAAM;AAC9D,oBAAgB,eAAe,gBAAgB,aAAa;AAAA,MAAO,CAAC,MACnE,EAAE,QAAQ,SAAS,EAAE,KAAK;AAAA,IAC3B;AACA,WAAO;AAAA,EACR;AACD;AAEO,MAAM,UAA+B;AAAA,EAArC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA;AAAA,MAEN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,KAAK,KAAK,GAAG;AAAA,MAC1B,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,QAAQ;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/memory/MemoryZep/MemoryZep.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport type { BaseChatMemory } from '@langchain/community/dist/memory/chat_memory';\nimport { ZepMemory } from '@langchain/community/memory/zep';\nimport { ZepCloudMemory } from '@langchain/community/memory/zep_cloud';\nimport type { InputValues, MemoryVariables } from '@langchain/core/memory';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport {\n\tNodeConnectionTypes,\n\ttype ISupplyDataFunctions,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype SupplyData,\n\tNodeOperationError,\n} from 'n8n-workflow';\n\nimport { getSessionId } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { expressionSessionKeyProperty, sessionIdOption, sessionKeyProperty } from '../descriptions';\n\n// Extend ZepCloudMemory to trim white space in messages.\nclass WhiteSpaceTrimmedZepCloudMemory extends ZepCloudMemory {\n\toverride async loadMemoryVariables(values: InputValues): Promise<MemoryVariables> {\n\t\tconst memoryVariables = await super.loadMemoryVariables(values);\n\t\tmemoryVariables.chat_history = memoryVariables.chat_history.filter((m: BaseMessage) =>\n\t\t\tm.content.toString().trim(),\n\t\t);\n\t\treturn memoryVariables;\n\t}\n}\n\nexport class MemoryZep implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Zep',\n\t\tname: 'memoryZep',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg\n\t\ticon: 'file:zep.png',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdescription: 'Use Zep Memory',\n\t\tdefaults: {\n\t\t\tname: 'Zep',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Memory'],\n\t\t\t\tMemory: ['Other memories'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memoryzep/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiMemory],\n\t\toutputNames: ['Memory'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'zepApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Only works with Zep Cloud and Community edition <= v0.27.2',\n\t\t\t\tname: 'supportedVersions',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\trequired: true,\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Session ID',\n\t\t\t\tname: 'sessionId',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '={{ $json.sessionId }}',\n\t\t\t\tdescription: 'The key to use to store the memory',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...sessionIdOption,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\texpressionSessionKeyProperty(1.3),\n\t\t\tsessionKeyProperty,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials<{\n\t\t\tapiKey?: string;\n\t\t\tapiUrl?: string;\n\t\t\tcloud?: boolean;\n\t\t}>('zepApi');\n\n\t\tconst nodeVersion = this.getNode().typeVersion;\n\n\t\tlet sessionId;\n\n\t\tif (nodeVersion >= 1.2) {\n\t\t\tsessionId = getSessionId(this, itemIndex);\n\t\t} else {\n\t\t\tsessionId = this.getNodeParameter('sessionId', itemIndex) as string;\n\t\t}\n\n\t\tlet memory: BaseChatMemory;\n\n\t\tif (credentials.cloud) {\n\t\t\tif (!credentials.apiKey) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'API key is required to use Zep Cloud');\n\t\t\t}\n\t\t\tmemory = new WhiteSpaceTrimmedZepCloudMemory({\n\t\t\t\tsessionId,\n\t\t\t\tapiKey: credentials.apiKey,\n\t\t\t\tmemoryType: 'perpetual',\n\t\t\t\tmemoryKey: 'chat_history',\n\t\t\t\treturnMessages: true,\n\t\t\t\tinputKey: 'input',\n\t\t\t\toutputKey: 'output',\n\t\t\t\tseparateMessages: false,\n\t\t\t});\n\t\t} else {\n\t\t\tif (!credentials.apiUrl) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'API url is required to use Zep Open Source');\n\t\t\t}\n\t\t\tmemory = new ZepMemory({\n\t\t\t\tsessionId,\n\t\t\t\tbaseURL: credentials.apiUrl,\n\t\t\t\tapiKey: credentials.apiKey,\n\t\t\t\tmemoryKey: 'chat_history',\n\t\t\t\treturnMessages: true,\n\t\t\t\tinputKey: 'input',\n\t\t\t\toutputKey: 'output',\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: logWrapper(memory, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAA0B;AAC1B,uBAA+B;AAG/B,0BAOO;AAEP,qBAA6B;AAC7B,wBAA2B;AAC3B,0BAA6C;AAE7C,0BAAkF;AAGlF,MAAM,wCAAwC,gCAAe;AAAA,EAC5D,MAAe,oBAAoB,QAA+C;AACjF,UAAM,kBAAkB,MAAM,MAAM,oBAAoB,MAAM;AAC9D,oBAAgB,eAAe,gBAAgB,aAAa;AAAA,MAAO,CAAC,MACnE,EAAE,QAAQ,SAAS,EAAE,KAAK;AAAA,IAC3B;AACA,WAAO;AAAA,EACR;AACD;AAEO,MAAM,UAA+B;AAAA,EAArC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA;AAAA,MAEN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,KAAK,KAAK,GAAG;AAAA,MAC1B,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,QAAQ;AAAA,UACb,QAAQ,CAAC,gBAAgB;AAAA,QAC1B;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ,CAAC;AAAA;AAAA,MAET,SAAS,CAAC,wCAAoB,QAAQ;AAAA,MACtC,aAAa,CAAC,QAAQ;AAAA,M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F;AACA,eAAS,IAAI,gCAAgC;AAAA,QAC5C;AAAA,QACA,QAAQ,YAAY;AAAA,QACpB,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,gBAAgB;AAAA,QAChB,UAAU;AAAA,QACV,WAAW;AAAA,QACX,kBAAkB;AAAA,MACnB,CAAC;AAAA,IACF,OAAO;AACN,UAAI,CAAC,YAAY,QAAQ;AACxB,cAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,4CAA4C;AAAA,MAC1F;AACA,eAAS,IAAI,qBAAU;AAAA,QACtB;AAAA,QACA,SAAS,YAAY;AAAA,QACrB,QAAQ,YAAY;AAAA,QACpB,WAAW;AAAA,QACX,gBAAgB;AAAA,QAChB,UAAU;AAAA,QACV,WAAW;AAAA,MACZ,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,MACN,cAAU,8BAAW,QAAQ,IAAI;AAAA,IAClC;AAAA,EACD;AACD;","names":[]}
|
|
@@ -27,6 +27,7 @@ var import_PythonSandbox = require("n8n-nodes-base/dist/nodes/Code/PythonSandbox
|
|
|
27
27
|
var import_Sandbox = require("n8n-nodes-base/dist/nodes/Code/Sandbox");
|
|
28
28
|
var import_n8n_workflow = require("n8n-workflow");
|
|
29
29
|
var import_descriptions = require("../../../utils/descriptions");
|
|
30
|
+
var import_helpers = require("../../../utils/helpers");
|
|
30
31
|
var import_schemaParsing = require("../../../utils/schemaParsing");
|
|
31
32
|
var import_sharedFields = require("../../../utils/sharedFields");
|
|
32
33
|
class ToolCode {
|
|
@@ -37,7 +38,7 @@ class ToolCode {
|
|
|
37
38
|
icon: "fa:code",
|
|
38
39
|
iconColor: "black",
|
|
39
40
|
group: ["transform"],
|
|
40
|
-
version: [1, 1.1],
|
|
41
|
+
version: [1, 1.1, 1.2],
|
|
41
42
|
description: "Write a tool in JS or Python",
|
|
42
43
|
defaults: {
|
|
43
44
|
name: "Code Tool"
|
|
@@ -91,7 +92,7 @@ class ToolCode {
|
|
|
91
92
|
description: "The name of the function to be called, could contain letters, numbers, and underscores only",
|
|
92
93
|
displayOptions: {
|
|
93
94
|
show: {
|
|
94
|
-
"@version": [
|
|
95
|
+
"@version": [1.1]
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
},
|
|
@@ -179,7 +180,8 @@ class ToolCode {
|
|
|
179
180
|
async supplyData(itemIndex) {
|
|
180
181
|
const node = this.getNode();
|
|
181
182
|
const workflowMode = this.getMode();
|
|
182
|
-
const
|
|
183
|
+
const { typeVersion } = node;
|
|
184
|
+
const name = typeVersion <= 1.1 ? this.getNodeParameter("name", itemIndex) : (0, import_helpers.nodeNameToToolName)(node);
|
|
183
185
|
const description = this.getNodeParameter("description", itemIndex);
|
|
184
186
|
const useSchema = this.getNodeParameter("specifyInputSchema", itemIndex);
|
|
185
187
|
const language = this.getNodeParameter("language", itemIndex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/tools/ToolCode/ToolCode.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { DynamicStructuredTool, DynamicTool } from '@langchain/core/tools';\nimport type { JSONSchema7 } from 'json-schema';\nimport { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';\nimport { PythonSandbox } from 'n8n-nodes-base/dist/nodes/Code/PythonSandbox';\nimport type { Sandbox } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tExecutionError,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { jsonParse, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\n\nimport {\n\tbuildInputSchemaField,\n\tbuildJsonSchemaExampleField,\n\tschemaTypeField,\n} from '@utils/descriptions';\nimport { convertJsonSchemaToZod, generateSchema } from '@utils/schemaParsing';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport type { DynamicZodObject } from '../../../types/zod.types';\n\nexport class ToolCode implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Code Tool',\n\t\tname: 'toolCode',\n\t\ticon: 'fa:code',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Write a tool in JS or Python',\n\t\tdefaults: {\n\t\t\tname: 'Code Tool',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolcode/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'See an example of a conversational agent with custom tool written in JavaScript <a href=\"/templates/1963\" target=\"_blank\">here</a>.',\n\t\t\t\tname: 'noticeTemplateExample',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'My_Tool',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. My_Tool',\n\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\tdescription:\n\t\t\t\t\t'The name of the function to be called, could contain letters, numbers, and underscores only',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder:\n\t\t\t\t\t'Call this tool to get a random color. The input should be a string with comma separted names of colors to exclude.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Language',\n\t\t\t\tname: 'language',\n\t\t\t\ttype: 'options',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'JavaScript',\n\t\t\t\t\t\tvalue: 'javaScript',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Python (Beta)',\n\t\t\t\t\t\tvalue: 'python',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'javaScript',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'JavaScript',\n\t\t\t\tname: 'jsCode',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tlanguage: ['javaScript'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\teditor: 'jsEditor',\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'// Example: convert the incoming query to uppercase and return it\\nreturn query.toUpperCase()',\n\t\t\t\t// TODO: Add proper text here later\n\t\t\t\thint: 'You can access the input the tool receives via the input property \"query\". The returned value should be a single string.',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-missing-final-period\n\t\t\t\tdescription: 'E.g. Converts any text to uppercase',\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Python',\n\t\t\t\tname: 'pythonCode',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tlanguage: ['python'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\teditor: 'codeNodeEditor', // TODO: create a separate `pythonEditor` component\n\t\t\t\t\teditorLanguage: 'python',\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'# Example: convert the incoming query to uppercase and return it\\nreturn query.upper()',\n\t\t\t\t// TODO: Add proper text here later\n\t\t\t\thint: 'You can access the input the tool receives via the input property \"query\". The returned value should be a single string.',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-missing-final-period\n\t\t\t\tdescription: 'E.g. Converts any text to uppercase',\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Specify Input Schema',\n\t\t\t\tname: 'specifyInputSchema',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to specify the schema for the function. This would require the LLM to provide the input in the correct format and would validate it against the schema.',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t{ ...schemaTypeField, displayOptions: { show: { specifyInputSchema: [true] } } },\n\t\t\tbuildJsonSchemaExampleField({ showExtraProps: { specifyInputSchema: [true] } }),\n\t\t\tbuildInputSchemaField({ showExtraProps: { specifyInputSchema: [true] } }),\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst workflowMode = this.getMode();\n\n\t\tconst name = this.getNodeParameter('name', itemIndex) as string;\n\t\tconst description = this.getNodeParameter('description', itemIndex) as string;\n\n\t\tconst useSchema = this.getNodeParameter('specifyInputSchema', itemIndex) as boolean;\n\n\t\tconst language = this.getNodeParameter('language', itemIndex) as string;\n\t\tlet code = '';\n\t\tif (language === 'javaScript') {\n\t\t\tcode = this.getNodeParameter('jsCode', itemIndex) as string;\n\t\t} else {\n\t\t\tcode = this.getNodeParameter('pythonCode', itemIndex) as string;\n\t\t}\n\n\t\tconst getSandbox = (query: string | IDataObject, index = 0) => {\n\t\t\tconst context = getSandboxContext.call(this, index);\n\t\t\tcontext.query = query;\n\n\t\t\tlet sandbox: Sandbox;\n\t\t\tif (language === 'javaScript') {\n\t\t\t\tsandbox = new JavaScriptSandbox(context, code, this.helpers);\n\t\t\t} else {\n\t\t\t\tsandbox = new PythonSandbox(context, code, this.helpers);\n\t\t\t}\n\n\t\t\tsandbox.on(\n\t\t\t\t'output',\n\t\t\t\tworkflowMode === 'manual'\n\t\t\t\t\t? this.sendMessageToUI.bind(this)\n\t\t\t\t\t: (...args: unknown[]) =>\n\t\t\t\t\t\t\tconsole.log(`[Workflow \"${this.getWorkflow().id}\"][Node \"${node.name}\"]`, ...args),\n\t\t\t);\n\t\t\treturn sandbox;\n\t\t};\n\n\t\tconst runFunction = async (query: string | IDataObject): Promise<string> => {\n\t\t\tconst sandbox = getSandbox(query, itemIndex);\n\t\t\treturn await sandbox.runCode<string>();\n\t\t};\n\n\t\tconst toolHandler = async (query: string | IDataObject): Promise<string> => {\n\t\t\tconst { index } = this.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);\n\n\t\t\tlet response: string = '';\n\t\t\tlet executionError: ExecutionError | undefined;\n\t\t\ttry {\n\t\t\t\tresponse = await runFunction(query);\n\t\t\t} catch (error: unknown) {\n\t\t\t\texecutionError = new NodeOperationError(this.getNode(), error as ExecutionError);\n\t\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t\t}\n\n\t\t\tif (typeof response === 'number') {\n\t\t\t\tresponse = (response as number).toString();\n\t\t\t}\n\n\t\t\tif (typeof response !== 'string') {\n\t\t\t\t// TODO: Do some more testing. Issues here should actually fail the workflow\n\t\t\t\texecutionError = new NodeOperationError(this.getNode(), 'Wrong output type returned', {\n\t\t\t\t\tdescription: `The response property should be a string, but it is an ${typeof response}`,\n\t\t\t\t});\n\t\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t\t}\n\n\t\t\tif (executionError) {\n\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, index, executionError);\n\t\t\t} else {\n\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst commonToolOptions = {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tfunc: toolHandler,\n\t\t};\n\n\t\tlet tool: DynamicTool | DynamicStructuredTool | undefined = undefined;\n\n\t\tif (useSchema) {\n\t\t\ttry {\n\t\t\t\t// We initialize these even though one of them will always be empty\n\t\t\t\t// it makes it easier to navigate the ternary operator\n\t\t\t\tconst jsonExample = this.getNodeParameter('jsonSchemaExample', itemIndex, '') as string;\n\t\t\t\tconst inputSchema = this.getNodeParameter('inputSchema', itemIndex, '') as string;\n\n\t\t\t\tconst schemaType = this.getNodeParameter('schemaType', itemIndex) as 'fromJson' | 'manual';\n\t\t\t\tconst jsonSchema =\n\t\t\t\t\tschemaType === 'fromJson'\n\t\t\t\t\t\t? generateSchema(jsonExample)\n\t\t\t\t\t\t: jsonParse<JSONSchema7>(inputSchema);\n\n\t\t\t\tconst zodSchema = convertJsonSchemaToZod<DynamicZodObject>(jsonSchema);\n\n\t\t\t\ttool = new DynamicStructuredTool({\n\t\t\t\t\tschema: zodSchema,\n\t\t\t\t\t...commonToolOptions,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t'Error during parsing of JSON Schema. \\n ' + error,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\ttool = new DynamicTool(commonToolOptions);\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: tool,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAmD;AAEnD,+BAAkC;AAClC,2BAA8B;AAE9B,qBAAkC;AASlC,0BAAmE;AAEnE,0BAIO;AACP,2BAAuD;AACvD,0BAA6C;AAItC,MAAM,SAA8B;AAAA,EAApC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,mBAAmB;AAAA,QAC5B;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ,CAAC;AAAA;AAAA,MAET,SAAS,CAAC,wCAAoB,MAAM;AAAA,MACpC,aAAa,CAAC,MAAM;AAAA,MACpB,YAAY;AAAA,YACX,kDAA6B,CAAC,wCAAoB,OAAO,CAAC;AAAA,QAC1D;AAAA,UACC,aACC;AAAA,UACD,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,QACV;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AA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M,oBAAoB;AAAA,MACzB;AAAA,MACA;AAAA,MACA,MAAM;AAAA,IACP;AAEA,QAAI,OAAwD;AAE5D,QAAI,WAAW;AACd,UAAI;AAGH,cAAM,cAAc,KAAK,iBAAiB,qBAAqB,WAAW,EAAE;AAC5E,cAAM,cAAc,KAAK,iBAAiB,eAAe,WAAW,EAAE;AAEtE,cAAM,aAAa,KAAK,iBAAiB,cAAc,SAAS;AAChE,cAAM,aACL,eAAe,iBACZ,qCAAe,WAAW,QAC1B,+BAAuB,WAAW;AAEtC,cAAM,gBAAY,6CAAyC,UAAU;AAErE,eAAO,IAAI,mCAAsB;AAAA,UAChC,QAAQ;AAAA,UACR,GAAG;AAAA,QACJ,CAAC;AAAA,MACF,SAAS,OAAO;AACf,cAAM,IAAI;AAAA,UACT,KAAK,QAAQ;AAAA,UACb,6CAA6C;AAAA,QAC9C;AAAA,MACD;AAAA,IACD,OAAO;AACN,aAAO,IAAI,yBAAY,iBAAiB;AAAA,IACzC;AAEA,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/tools/ToolCode/ToolCode.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { DynamicStructuredTool, DynamicTool } from '@langchain/core/tools';\nimport type { JSONSchema7 } from 'json-schema';\nimport { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';\nimport { PythonSandbox } from 'n8n-nodes-base/dist/nodes/Code/PythonSandbox';\nimport type { Sandbox } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tExecutionError,\n\tIDataObject,\n} from 'n8n-workflow';\nimport { jsonParse, NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\n\nimport {\n\tbuildInputSchemaField,\n\tbuildJsonSchemaExampleField,\n\tschemaTypeField,\n} from '@utils/descriptions';\nimport { nodeNameToToolName } from '@utils/helpers';\nimport { convertJsonSchemaToZod, generateSchema } from '@utils/schemaParsing';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport type { DynamicZodObject } from '../../../types/zod.types';\n\nexport class ToolCode implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Code Tool',\n\t\tname: 'toolCode',\n\t\ticon: 'fa:code',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2],\n\t\tdescription: 'Write a tool in JS or Python',\n\t\tdefaults: {\n\t\t\tname: 'Code Tool',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolcode/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'See an example of a conversational agent with custom tool written in JavaScript <a href=\"/templates/1963\" target=\"_blank\">here</a>.',\n\t\t\t\tname: 'noticeTemplateExample',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'My_Tool',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. My_Tool',\n\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\tdescription:\n\t\t\t\t\t'The name of the function to be called, could contain letters, numbers, and underscores only',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder:\n\t\t\t\t\t'Call this tool to get a random color. The input should be a string with comma separted names of colors to exclude.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t{\n\t\t\t\tdisplayName: 'Language',\n\t\t\t\tname: 'language',\n\t\t\t\ttype: 'options',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'JavaScript',\n\t\t\t\t\t\tvalue: 'javaScript',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Python (Beta)',\n\t\t\t\t\t\tvalue: 'python',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'javaScript',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'JavaScript',\n\t\t\t\tname: 'jsCode',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tlanguage: ['javaScript'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\teditor: 'jsEditor',\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'// Example: convert the incoming query to uppercase and return it\\nreturn query.toUpperCase()',\n\t\t\t\t// TODO: Add proper text here later\n\t\t\t\thint: 'You can access the input the tool receives via the input property \"query\". The returned value should be a single string.',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-missing-final-period\n\t\t\t\tdescription: 'E.g. Converts any text to uppercase',\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Python',\n\t\t\t\tname: 'pythonCode',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tlanguage: ['python'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\teditor: 'codeNodeEditor', // TODO: create a separate `pythonEditor` component\n\t\t\t\t\teditorLanguage: 'python',\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'# Example: convert the incoming query to uppercase and return it\\nreturn query.upper()',\n\t\t\t\t// TODO: Add proper text here later\n\t\t\t\thint: 'You can access the input the tool receives via the input property \"query\". The returned value should be a single string.',\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-description-missing-final-period\n\t\t\t\tdescription: 'E.g. Converts any text to uppercase',\n\t\t\t\tnoDataExpression: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Specify Input Schema',\n\t\t\t\tname: 'specifyInputSchema',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to specify the schema for the function. This would require the LLM to provide the input in the correct format and would validate it against the schema.',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdefault: false,\n\t\t\t},\n\t\t\t{ ...schemaTypeField, displayOptions: { show: { specifyInputSchema: [true] } } },\n\t\t\tbuildJsonSchemaExampleField({ showExtraProps: { specifyInputSchema: [true] } }),\n\t\t\tbuildInputSchemaField({ showExtraProps: { specifyInputSchema: [true] } }),\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst workflowMode = this.getMode();\n\n\t\tconst { typeVersion } = node;\n\t\tconst name =\n\t\t\ttypeVersion <= 1.1\n\t\t\t\t? (this.getNodeParameter('name', itemIndex) as string)\n\t\t\t\t: nodeNameToToolName(node);\n\n\t\tconst description = this.getNodeParameter('description', itemIndex) as string;\n\n\t\tconst useSchema = this.getNodeParameter('specifyInputSchema', itemIndex) as boolean;\n\n\t\tconst language = this.getNodeParameter('language', itemIndex) as string;\n\t\tlet code = '';\n\t\tif (language === 'javaScript') {\n\t\t\tcode = this.getNodeParameter('jsCode', itemIndex) as string;\n\t\t} else {\n\t\t\tcode = this.getNodeParameter('pythonCode', itemIndex) as string;\n\t\t}\n\n\t\tconst getSandbox = (query: string | IDataObject, index = 0) => {\n\t\t\tconst context = getSandboxContext.call(this, index);\n\t\t\tcontext.query = query;\n\n\t\t\tlet sandbox: Sandbox;\n\t\t\tif (language === 'javaScript') {\n\t\t\t\tsandbox = new JavaScriptSandbox(context, code, this.helpers);\n\t\t\t} else {\n\t\t\t\tsandbox = new PythonSandbox(context, code, this.helpers);\n\t\t\t}\n\n\t\t\tsandbox.on(\n\t\t\t\t'output',\n\t\t\t\tworkflowMode === 'manual'\n\t\t\t\t\t? this.sendMessageToUI.bind(this)\n\t\t\t\t\t: (...args: unknown[]) =>\n\t\t\t\t\t\t\tconsole.log(`[Workflow \"${this.getWorkflow().id}\"][Node \"${node.name}\"]`, ...args),\n\t\t\t);\n\t\t\treturn sandbox;\n\t\t};\n\n\t\tconst runFunction = async (query: string | IDataObject): Promise<string> => {\n\t\t\tconst sandbox = getSandbox(query, itemIndex);\n\t\t\treturn await sandbox.runCode<string>();\n\t\t};\n\n\t\tconst toolHandler = async (query: string | IDataObject): Promise<string> => {\n\t\t\tconst { index } = this.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]]);\n\n\t\t\tlet response: string = '';\n\t\t\tlet executionError: ExecutionError | undefined;\n\t\t\ttry {\n\t\t\t\tresponse = await runFunction(query);\n\t\t\t} catch (error: unknown) {\n\t\t\t\texecutionError = new NodeOperationError(this.getNode(), error as ExecutionError);\n\t\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t\t}\n\n\t\t\tif (typeof response === 'number') {\n\t\t\t\tresponse = (response as number).toString();\n\t\t\t}\n\n\t\t\tif (typeof response !== 'string') {\n\t\t\t\t// TODO: Do some more testing. Issues here should actually fail the workflow\n\t\t\t\texecutionError = new NodeOperationError(this.getNode(), 'Wrong output type returned', {\n\t\t\t\t\tdescription: `The response property should be a string, but it is an ${typeof response}`,\n\t\t\t\t});\n\t\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t\t}\n\n\t\t\tif (executionError) {\n\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, index, executionError);\n\t\t\t} else {\n\t\t\t\tvoid this.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst commonToolOptions = {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tfunc: toolHandler,\n\t\t};\n\n\t\tlet tool: DynamicTool | DynamicStructuredTool | undefined = undefined;\n\n\t\tif (useSchema) {\n\t\t\ttry {\n\t\t\t\t// We initialize these even though one of them will always be empty\n\t\t\t\t// it makes it easier to navigate the ternary operator\n\t\t\t\tconst jsonExample = this.getNodeParameter('jsonSchemaExample', itemIndex, '') as string;\n\t\t\t\tconst inputSchema = this.getNodeParameter('inputSchema', itemIndex, '') as string;\n\n\t\t\t\tconst schemaType = this.getNodeParameter('schemaType', itemIndex) as 'fromJson' | 'manual';\n\t\t\t\tconst jsonSchema =\n\t\t\t\t\tschemaType === 'fromJson'\n\t\t\t\t\t\t? generateSchema(jsonExample)\n\t\t\t\t\t\t: jsonParse<JSONSchema7>(inputSchema);\n\n\t\t\t\tconst zodSchema = convertJsonSchemaToZod<DynamicZodObject>(jsonSchema);\n\n\t\t\t\ttool = new DynamicStructuredTool({\n\t\t\t\t\tschema: zodSchema,\n\t\t\t\t\t...commonToolOptions,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t'Error during parsing of JSON Schema. \\n ' + error,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\ttool = new DynamicTool(commonToolOptions);\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: tool,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAmD;AAEnD,+BAAkC;AAClC,2BAA8B;AAE9B,qBAAkC;AASlC,0BAAmE;AAEnE,0BAIO;AACP,qBAAmC;AACnC,2BAAuD;AACvD,0BAA6C;AAItC,MAAM,SAA8B;AAAA,EAApC;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,KAAK,GAAG;AAAA,MACrB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,mBAAmB;AAAA,QAC5B;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,MAEA,QAAQ,CAAC;AAAA;AAAA,MAET,SAAS,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,CAAC;AACD,mBAAW,wBAAwB,eAAe,OAAO;AAAA,MAC1D;AAEA,UAAI,gBAAgB;AACnB,aAAK,KAAK,cAAc,wCAAoB,QAAQ,OAAO,cAAc;AAAA,MAC1E,OAAO;AACN,aAAK,KAAK,cAAc,wCAAoB,QAAQ,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AAAA,MACtF;AAEA,aAAO;AAAA,IACR;AAEA,UAAM,oBAAoB;AAAA,MACzB;AAAA,MACA;AAAA,MACA,MAAM;AAAA,IACP;AAEA,QAAI,OAAwD;AAE5D,QAAI,WAAW;AACd,UAAI;AAGH,cAAM,cAAc,KAAK,iBAAiB,qBAAqB,WAAW,EAAE;AAC5E,cAAM,cAAc,KAAK,iBAAiB,eAAe,WAAW,EAAE;AAEtE,cAAM,aAAa,KAAK,iBAAiB,cAAc,SAAS;AAChE,cAAM,aACL,eAAe,iBACZ,qCAAe,WAAW,QAC1B,+BAAuB,WAAW;AAEtC,cAAM,gBAAY,6CAAyC,UAAU;AAErE,eAAO,IAAI,mCAAsB;AAAA,UAChC,QAAQ;AAAA,UACR,GAAG;AAAA,QACJ,CAAC;AAAA,MACF,SAAS,OAAO;AACf,cAAM,IAAI;AAAA,UACT,KAAK,QAAQ;AAAA,UACb,6CAA6C;AAAA,QAC9C;AAAA,MACD;AAAA,IACD,OAAO;AACN,aAAO,IAAI,yBAAY,iBAAiB;AAAA,IACzC;AAEA,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
|
|
@@ -55,6 +55,8 @@ class ToolHttpRequest {
|
|
|
55
55
|
]
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
|
+
// Replaced by a `usableAsTool` version of the standalone HttpRequest node
|
|
59
|
+
hidden: true,
|
|
58
60
|
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
|
|
59
61
|
inputs: [],
|
|
60
62
|
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/tools/ToolHttpRequest/ToolHttpRequest.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { DynamicTool } from '@langchain/core/tools';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tIHttpRequestMethods,\n\tIHttpRequestOptions,\n} from 'n8n-workflow';\nimport {\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttryToParseAlphanumericString,\n} from 'n8n-workflow';\n\nimport { N8nTool } from '@utils/N8nTool';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport {\n\tauthenticationProperties,\n\tjsonInput,\n\toptimizeResponseProperties,\n\tparametersCollection,\n\tplaceholderDefinitionsCollection,\n\tspecifyBySelector,\n} from './descriptions';\nimport type { PlaceholderDefinition, ToolParameter } from './interfaces';\nimport {\n\tconfigureHttpRequestFunction,\n\tconfigureResponseOptimizer,\n\textractParametersFromText,\n\tprepareToolDescription,\n\tconfigureToolFunction,\n\tupdateParametersAndOptions,\n\tmakeToolInputSchema,\n} from './utils';\n\nexport class ToolHttpRequest implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'HTTP Request Tool',\n\t\tname: 'toolHttpRequest',\n\t\ticon: { light: 'file:httprequest.svg', dark: 'file:httprequest.dark.svg' },\n\t\tgroup: ['output'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Makes an HTTP request and returns the response data',\n\t\tsubtitle: '={{ $parameter.toolDescription }}',\n\t\tdefaults: {\n\t\t\tname: 'HTTP Request',\n\t\t},\n\t\tcredentials: [],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolhttprequest/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'toolDescription',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription:\n\t\t\t\t\t'Explain to LLM what this tool does, better description would allow LLM to produce expected result',\n\t\t\t\tplaceholder: 'e.g. Get the current weather in the requested city',\n\t\t\t\tdefault: '',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Method',\n\t\t\t\tname: 'method',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'DELETE',\n\t\t\t\t\t\tvalue: 'DELETE',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'GET',\n\t\t\t\t\t\tvalue: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'PATCH',\n\t\t\t\t\t\tvalue: 'PATCH',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'POST',\n\t\t\t\t\t\tvalue: 'POST',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'PUT',\n\t\t\t\t\t\tvalue: 'PUT',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'GET',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'Tip: You can use a {placeholder} for any part of the request to be filled by the model. Provide more context about them in the placeholders section',\n\t\t\t\tname: 'placeholderNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'URL',\n\t\t\t\tname: 'url',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\tplaceholder: 'e.g. http://www.example.com/{path}',\n\t\t\t},\n\t\t\t...authenticationProperties,\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Query Parameters',\n\t\t\t\tname: 'sendQuery',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has query params or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Query Parameters',\n\t\t\t\tname: 'specifyQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Query Parameters',\n\t\t\t\tname: 'parametersQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t\tspecifyQuery: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t\tspecifyQuery: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Headers',\n\t\t\t\tname: 'sendHeaders',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has headers or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Headers',\n\t\t\t\tname: 'specifyHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Header Parameters',\n\t\t\t\tname: 'parametersHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t\tspecifyHeaders: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t\tspecifyHeaders: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Body',\n\t\t\t\tname: 'sendBody',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has body or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Body',\n\t\t\t\tname: 'specifyBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Body Parameters',\n\t\t\t\tname: 'parametersBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t\tspecifyBody: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t\tspecifyBody: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\tplaceholderDefinitionsCollection,\n\t\t\t...optimizeResponseProperties,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst name = this.getNode().name.replace(/ /g, '_');\n\t\ttry {\n\t\t\ttryToParseAlphanumericString(name);\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'The name of this tool is not a valid alphanumeric string',\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Only alphanumeric characters and underscores are allowed in the tool's name, and the name cannot start with a number\",\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst toolDescription = this.getNodeParameter('toolDescription', itemIndex) as string;\n\t\tconst sendQuery = this.getNodeParameter('sendQuery', itemIndex, false) as boolean;\n\t\tconst sendHeaders = this.getNodeParameter('sendHeaders', itemIndex, false) as boolean;\n\t\tconst sendBody = this.getNodeParameter('sendBody', itemIndex, false) as boolean;\n\n\t\tconst requestOptions: IHttpRequestOptions = {\n\t\t\tmethod: this.getNodeParameter('method', itemIndex, 'GET') as IHttpRequestMethods,\n\t\t\turl: this.getNodeParameter('url', itemIndex) as string,\n\t\t\tqs: {},\n\t\t\theaders: {\n\t\t\t\t// FIXME: This is a workaround to prevent the node from sending a default User-Agent (`n8n`) when the header is not set.\n\t\t\t\t// Needs to be replaced with a proper fix after NODE-1777 is resolved\n\t\t\t\t'User-Agent': undefined,\n\t\t\t},\n\t\t\tbody: {},\n\t\t\t// We will need a full response object later to extract the headers and check the response's content type.\n\t\t\treturnFullResponse: true,\n\t\t};\n\n\t\tconst authentication = this.getNodeParameter('authentication', itemIndex, 'none') as\n\t\t\t| 'predefinedCredentialType'\n\t\t\t| 'genericCredentialType'\n\t\t\t| 'none';\n\n\t\tif (authentication !== 'none') {\n\t\t\tconst domain = new URL(requestOptions.url).hostname;\n\t\t\tif (domain.includes('{') && domain.includes('}')) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\"Can't use a placeholder for the domain when using authentication\",\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'This is for security reasons, to prevent the model accidentally sending your credentials to an unauthorized domain',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst httpRequest = await configureHttpRequestFunction(this, authentication, itemIndex);\n\t\tconst optimizeResponse = configureResponseOptimizer(this, itemIndex);\n\n\t\tconst rawRequestOptions: { [key: string]: string } = {\n\t\t\tqs: '',\n\t\t\theaders: '',\n\t\t\tbody: '',\n\t\t};\n\n\t\tconst placeholdersDefinitions = (\n\t\t\tthis.getNodeParameter(\n\t\t\t\t'placeholderDefinitions.values',\n\t\t\t\titemIndex,\n\t\t\t\t[],\n\t\t\t) as PlaceholderDefinition[]\n\t\t).map((p) => {\n\t\t\tif (p.name.startsWith('{') && p.name.endsWith('}')) {\n\t\t\t\tp.name = p.name.slice(1, -1);\n\t\t\t}\n\t\t\treturn p;\n\t\t});\n\n\t\tconst toolParameters: ToolParameter[] = [];\n\n\t\ttoolParameters.push(\n\t\t\t...extractParametersFromText(placeholdersDefinitions, requestOptions.url, 'path'),\n\t\t);\n\n\t\tif (sendQuery) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'qs',\n\t\t\t\tinputTypePropertyName: 'specifyQuery',\n\t\t\t\tjsonPropertyName: 'jsonQuery',\n\t\t\t\tparametersPropertyName: 'parametersQuery.values',\n\t\t\t});\n\t\t}\n\n\t\tif (sendHeaders) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'headers',\n\t\t\t\tinputTypePropertyName: 'specifyHeaders',\n\t\t\t\tjsonPropertyName: 'jsonHeaders',\n\t\t\t\tparametersPropertyName: 'parametersHeaders.values',\n\t\t\t});\n\t\t}\n\n\t\tif (sendBody) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'body',\n\t\t\t\tinputTypePropertyName: 'specifyBody',\n\t\t\t\tjsonPropertyName: 'jsonBody',\n\t\t\t\tparametersPropertyName: 'parametersBody.values',\n\t\t\t});\n\t\t}\n\n\t\tfor (const placeholder of placeholdersDefinitions) {\n\t\t\tif (!toolParameters.find((parameter) => parameter.name === placeholder.name)) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t`Misconfigured placeholder '${placeholder.name}'`,\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"This placeholder is defined in the 'Placeholder Definitions' but isn't used anywhere. Either remove the definition, or add the placeholder to a part of the request.\",\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst func = configureToolFunction(\n\t\t\tthis,\n\t\t\titemIndex,\n\t\t\ttoolParameters,\n\t\t\trequestOptions,\n\t\t\trawRequestOptions,\n\t\t\thttpRequest,\n\t\t\toptimizeResponse,\n\t\t);\n\n\t\tlet tool: DynamicTool | N8nTool;\n\n\t\t// If the node version is 1.1 or higher, we use the N8nTool wrapper:\n\t\t// it allows to use tool as a DynamicStructuredTool and have a fallback to DynamicTool\n\t\tif (this.getNode().typeVersion >= 1.1) {\n\t\t\tconst schema = makeToolInputSchema(toolParameters);\n\n\t\t\ttool = new N8nTool(this, {\n\t\t\t\tname,\n\t\t\t\tdescription: toolDescription,\n\t\t\t\tfunc,\n\t\t\t\tschema,\n\t\t\t});\n\t\t} else {\n\t\t\t// Keep the old behavior for nodes with version 1.0\n\t\t\tconst description = prepareToolDescription(toolDescription, toolParameters);\n\t\t\ttool = new DynamicTool({ name, description, func });\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: tool,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA4B;AAS5B,0BAIO;AAEP,qBAAwB;AACxB,0BAA6C;AAE7C,0BAOO;AAEP,mBAQO;AAEA,MAAM,gBAAqC;AAAA,EAA3C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM,EAAE,OAAO,wBAAwB,MAAM,4BAA4B;AAAA,MACzE,OAAO,CAAC,QAAQ;AAAA,MAChB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,aAAa,CAAC;AAAA,MACd,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,I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}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/tools/ToolHttpRequest/ToolHttpRequest.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { DynamicTool } from '@langchain/core/tools';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tIHttpRequestMethods,\n\tIHttpRequestOptions,\n} from 'n8n-workflow';\nimport {\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\ttryToParseAlphanumericString,\n} from 'n8n-workflow';\n\nimport { N8nTool } from '@utils/N8nTool';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport {\n\tauthenticationProperties,\n\tjsonInput,\n\toptimizeResponseProperties,\n\tparametersCollection,\n\tplaceholderDefinitionsCollection,\n\tspecifyBySelector,\n} from './descriptions';\nimport type { PlaceholderDefinition, ToolParameter } from './interfaces';\nimport {\n\tconfigureHttpRequestFunction,\n\tconfigureResponseOptimizer,\n\textractParametersFromText,\n\tprepareToolDescription,\n\tconfigureToolFunction,\n\tupdateParametersAndOptions,\n\tmakeToolInputSchema,\n} from './utils';\n\nexport class ToolHttpRequest implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'HTTP Request Tool',\n\t\tname: 'toolHttpRequest',\n\t\ticon: { light: 'file:httprequest.svg', dark: 'file:httprequest.dark.svg' },\n\t\tgroup: ['output'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Makes an HTTP request and returns the response data',\n\t\tsubtitle: '={{ $parameter.toolDescription }}',\n\t\tdefaults: {\n\t\t\tname: 'HTTP Request',\n\t\t},\n\t\tcredentials: [],\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolhttprequest/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// Replaced by a `usableAsTool` version of the standalone HttpRequest node\n\t\thidden: true,\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Description',\n\t\t\t\tname: 'toolDescription',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription:\n\t\t\t\t\t'Explain to LLM what this tool does, better description would allow LLM to produce expected result',\n\t\t\t\tplaceholder: 'e.g. Get the current weather in the requested city',\n\t\t\t\tdefault: '',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Method',\n\t\t\t\tname: 'method',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'DELETE',\n\t\t\t\t\t\tvalue: 'DELETE',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'GET',\n\t\t\t\t\t\tvalue: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'PATCH',\n\t\t\t\t\t\tvalue: 'PATCH',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'POST',\n\t\t\t\t\t\tvalue: 'POST',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'PUT',\n\t\t\t\t\t\tvalue: 'PUT',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'GET',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'Tip: You can use a {placeholder} for any part of the request to be filled by the model. Provide more context about them in the placeholders section',\n\t\t\t\tname: 'placeholderNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'URL',\n\t\t\t\tname: 'url',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\trequired: true,\n\t\t\t\tplaceholder: 'e.g. http://www.example.com/{path}',\n\t\t\t},\n\t\t\t...authenticationProperties,\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Query Parameters',\n\t\t\t\tname: 'sendQuery',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has query params or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Query Parameters',\n\t\t\t\tname: 'specifyQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Query Parameters',\n\t\t\t\tname: 'parametersQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t\tspecifyQuery: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonQuery',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendQuery: [true],\n\t\t\t\t\t\tspecifyQuery: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Headers',\n\t\t\t\tname: 'sendHeaders',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has headers or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Headers',\n\t\t\t\tname: 'specifyHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Header Parameters',\n\t\t\t\tname: 'parametersHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t\tspecifyHeaders: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonHeaders',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendHeaders: [true],\n\t\t\t\t\t\tspecifyHeaders: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Send Body',\n\t\t\t\tname: 'sendBody',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdescription: 'Whether the request has body or not',\n\t\t\t},\n\t\t\t{\n\t\t\t\t...specifyBySelector,\n\t\t\t\tdisplayName: 'Specify Body',\n\t\t\t\tname: 'specifyBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...parametersCollection,\n\t\t\t\tdisplayName: 'Body Parameters',\n\t\t\t\tname: 'parametersBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t\tspecifyBody: ['keypair'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...jsonInput,\n\t\t\t\tname: 'jsonBody',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tsendBody: [true],\n\t\t\t\t\t\tspecifyBody: ['json'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t//----------------------------------------------------------------\n\t\t\tplaceholderDefinitionsCollection,\n\t\t\t...optimizeResponseProperties,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst name = this.getNode().name.replace(/ /g, '_');\n\t\ttry {\n\t\t\ttryToParseAlphanumericString(name);\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'The name of this tool is not a valid alphanumeric string',\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Only alphanumeric characters and underscores are allowed in the tool's name, and the name cannot start with a number\",\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst toolDescription = this.getNodeParameter('toolDescription', itemIndex) as string;\n\t\tconst sendQuery = this.getNodeParameter('sendQuery', itemIndex, false) as boolean;\n\t\tconst sendHeaders = this.getNodeParameter('sendHeaders', itemIndex, false) as boolean;\n\t\tconst sendBody = this.getNodeParameter('sendBody', itemIndex, false) as boolean;\n\n\t\tconst requestOptions: IHttpRequestOptions = {\n\t\t\tmethod: this.getNodeParameter('method', itemIndex, 'GET') as IHttpRequestMethods,\n\t\t\turl: this.getNodeParameter('url', itemIndex) as string,\n\t\t\tqs: {},\n\t\t\theaders: {\n\t\t\t\t// FIXME: This is a workaround to prevent the node from sending a default User-Agent (`n8n`) when the header is not set.\n\t\t\t\t// Needs to be replaced with a proper fix after NODE-1777 is resolved\n\t\t\t\t'User-Agent': undefined,\n\t\t\t},\n\t\t\tbody: {},\n\t\t\t// We will need a full response object later to extract the headers and check the response's content type.\n\t\t\treturnFullResponse: true,\n\t\t};\n\n\t\tconst authentication = this.getNodeParameter('authentication', itemIndex, 'none') as\n\t\t\t| 'predefinedCredentialType'\n\t\t\t| 'genericCredentialType'\n\t\t\t| 'none';\n\n\t\tif (authentication !== 'none') {\n\t\t\tconst domain = new URL(requestOptions.url).hostname;\n\t\t\tif (domain.includes('{') && domain.includes('}')) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\"Can't use a placeholder for the domain when using authentication\",\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'This is for security reasons, to prevent the model accidentally sending your credentials to an unauthorized domain',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst httpRequest = await configureHttpRequestFunction(this, authentication, itemIndex);\n\t\tconst optimizeResponse = configureResponseOptimizer(this, itemIndex);\n\n\t\tconst rawRequestOptions: { [key: string]: string } = {\n\t\t\tqs: '',\n\t\t\theaders: '',\n\t\t\tbody: '',\n\t\t};\n\n\t\tconst placeholdersDefinitions = (\n\t\t\tthis.getNodeParameter(\n\t\t\t\t'placeholderDefinitions.values',\n\t\t\t\titemIndex,\n\t\t\t\t[],\n\t\t\t) as PlaceholderDefinition[]\n\t\t).map((p) => {\n\t\t\tif (p.name.startsWith('{') && p.name.endsWith('}')) {\n\t\t\t\tp.name = p.name.slice(1, -1);\n\t\t\t}\n\t\t\treturn p;\n\t\t});\n\n\t\tconst toolParameters: ToolParameter[] = [];\n\n\t\ttoolParameters.push(\n\t\t\t...extractParametersFromText(placeholdersDefinitions, requestOptions.url, 'path'),\n\t\t);\n\n\t\tif (sendQuery) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'qs',\n\t\t\t\tinputTypePropertyName: 'specifyQuery',\n\t\t\t\tjsonPropertyName: 'jsonQuery',\n\t\t\t\tparametersPropertyName: 'parametersQuery.values',\n\t\t\t});\n\t\t}\n\n\t\tif (sendHeaders) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'headers',\n\t\t\t\tinputTypePropertyName: 'specifyHeaders',\n\t\t\t\tjsonPropertyName: 'jsonHeaders',\n\t\t\t\tparametersPropertyName: 'parametersHeaders.values',\n\t\t\t});\n\t\t}\n\n\t\tif (sendBody) {\n\t\t\tupdateParametersAndOptions({\n\t\t\t\tctx: this,\n\t\t\t\titemIndex,\n\t\t\t\ttoolParameters,\n\t\t\t\tplaceholdersDefinitions,\n\t\t\t\trequestOptions,\n\t\t\t\trawRequestOptions,\n\t\t\t\trequestOptionsProperty: 'body',\n\t\t\t\tinputTypePropertyName: 'specifyBody',\n\t\t\t\tjsonPropertyName: 'jsonBody',\n\t\t\t\tparametersPropertyName: 'parametersBody.values',\n\t\t\t});\n\t\t}\n\n\t\tfor (const placeholder of placeholdersDefinitions) {\n\t\t\tif (!toolParameters.find((parameter) => parameter.name === placeholder.name)) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t`Misconfigured placeholder '${placeholder.name}'`,\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"This placeholder is defined in the 'Placeholder Definitions' but isn't used anywhere. Either remove the definition, or add the placeholder to a part of the request.\",\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst func = configureToolFunction(\n\t\t\tthis,\n\t\t\titemIndex,\n\t\t\ttoolParameters,\n\t\t\trequestOptions,\n\t\t\trawRequestOptions,\n\t\t\thttpRequest,\n\t\t\toptimizeResponse,\n\t\t);\n\n\t\tlet tool: DynamicTool | N8nTool;\n\n\t\t// If the node version is 1.1 or higher, we use the N8nTool wrapper:\n\t\t// it allows to use tool as a DynamicStructuredTool and have a fallback to DynamicTool\n\t\tif (this.getNode().typeVersion >= 1.1) {\n\t\t\tconst schema = makeToolInputSchema(toolParameters);\n\n\t\t\ttool = new N8nTool(this, {\n\t\t\t\tname,\n\t\t\t\tdescription: toolDescription,\n\t\t\t\tfunc,\n\t\t\t\tschema,\n\t\t\t});\n\t\t} else {\n\t\t\t// Keep the old behavior for nodes with version 1.0\n\t\t\tconst description = prepareToolDescription(toolDescription, toolParameters);\n\t\t\ttool = new DynamicTool({ name, description, func });\n\t\t}\n\n\t\treturn {\n\t\t\tresponse: tool,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA4B;AAS5B,0BAIO;AAEP,qBAAwB;AACxB,0BAA6C;AAE7C,0BAOO;AAEP,mBAQO;AAEA,MAAM,gBAAqC;AAAA,EAA3C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM,EAAE,OAAO,wBAAwB,MAAM,4BAA4B;AAAA,MACzE,OAAO,CAAC,QAAQ;AAAA,MAChB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,aAAa,CAAC;AAAA,MACd,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe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AAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
|
|
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(ToolVectorStore_node_exports);
|
|
|
24
24
|
var import_chains = require("langchain/chains");
|
|
25
25
|
var import_tools = require("langchain/tools");
|
|
26
26
|
var import_n8n_workflow = require("n8n-workflow");
|
|
27
|
+
var import_helpers = require("../../../utils/helpers");
|
|
27
28
|
var import_logWrapper = require("../../../utils/logWrapper");
|
|
28
29
|
var import_sharedFields = require("../../../utils/sharedFields");
|
|
29
30
|
class ToolVectorStore {
|
|
@@ -34,7 +35,7 @@ class ToolVectorStore {
|
|
|
34
35
|
icon: "fa:database",
|
|
35
36
|
iconColor: "black",
|
|
36
37
|
group: ["transform"],
|
|
37
|
-
version: [1],
|
|
38
|
+
version: [1, 1.1],
|
|
38
39
|
description: "Answer questions with a vector store",
|
|
39
40
|
defaults: {
|
|
40
41
|
name: "Answer questions with a vector store"
|
|
@@ -80,7 +81,12 @@ class ToolVectorStore {
|
|
|
80
81
|
default: "",
|
|
81
82
|
placeholder: "e.g. users_info",
|
|
82
83
|
validateType: "string-alphanumeric",
|
|
83
|
-
description: "Name of the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question."
|
|
84
|
+
description: "Name of the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.",
|
|
85
|
+
displayOptions: {
|
|
86
|
+
show: {
|
|
87
|
+
"@version": [1]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
84
90
|
},
|
|
85
91
|
{
|
|
86
92
|
displayName: "Description of Data",
|
|
@@ -104,7 +110,9 @@ class ToolVectorStore {
|
|
|
104
110
|
};
|
|
105
111
|
}
|
|
106
112
|
async supplyData(itemIndex) {
|
|
107
|
-
const
|
|
113
|
+
const node = this.getNode();
|
|
114
|
+
const { typeVersion } = node;
|
|
115
|
+
const name = typeVersion <= 1 ? this.getNodeParameter("name", itemIndex) : (0, import_helpers.nodeNameToToolName)(node);
|
|
108
116
|
const toolDescription = this.getNodeParameter("description", itemIndex);
|
|
109
117
|
const topK = this.getNodeParameter("topK", itemIndex, 4);
|
|
110
118
|
const vectorStore = await this.getInputConnectionData(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/tools/ToolVectorStore/ToolVectorStore.node.ts"],"sourcesContent":["import type { BaseLanguageModel } from '@langchain/core/language_models/base';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { VectorDBQAChain } from 'langchain/chains';\nimport { VectorStoreQATool } from 'langchain/tools';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes } from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolVectorStore implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Vector Store Question Answer Tool',\n\t\tname: 'toolVectorStore',\n\t\ticon: 'fa:database',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: [1],\n\t\tdescription: 'Answer questions with a vector store',\n\t\tdefaults: {\n\t\t\tname: 'Answer questions with a vector store',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolvectorstore/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Vector Store',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiVectorStore,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiLanguageModel,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Data Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. users_info',\n\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\tdescription:\n\t\t\t\t\t'Name of the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description of Data',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: \"[Describe your data here, e.g. a user's name, email, etc.]\",\n\t\t\t\tdescription:\n\t\t\t\t\t'Describe the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Limit',\n\t\t\t\tname: 'topK',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 4,\n\t\t\t\tdescription: 'The maximum number of results to return',\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/tools/ToolVectorStore/ToolVectorStore.node.ts"],"sourcesContent":["import type { BaseLanguageModel } from '@langchain/core/language_models/base';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { VectorDBQAChain } from 'langchain/chains';\nimport { VectorStoreQATool } from 'langchain/tools';\nimport type {\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes } from 'n8n-workflow';\n\nimport { nodeNameToToolName } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class ToolVectorStore implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Vector Store Question Answer Tool',\n\t\tname: 'toolVectorStore',\n\t\ticon: 'fa:database',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Answer questions with a vector store',\n\t\tdefaults: {\n\t\t\tname: 'Answer questions with a vector store',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Tools'],\n\t\t\t\tTools: ['Other Tools'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolvectorstore/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Vector Store',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiVectorStore,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiLanguageModel,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiTool],\n\t\toutputNames: ['Tool'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Data Name',\n\t\t\t\tname: 'name',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. users_info',\n\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\tdescription:\n\t\t\t\t\t'Name of the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Description of Data',\n\t\t\t\tname: 'description',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: \"[Describe your data here, e.g. a user's name, email, etc.]\",\n\t\t\t\tdescription:\n\t\t\t\t\t'Describe the data in vector store. This will be used to fill this tool description: Useful for when you need to answer questions about [name]. Whenever you need information about [data description], you should ALWAYS use this. Input should be a fully formed question.',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Limit',\n\t\t\t\tname: 'topK',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 4,\n\t\t\t\tdescription: 'The maximum number of results to return',\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst { typeVersion } = node;\n\t\tconst name =\n\t\t\ttypeVersion <= 1\n\t\t\t\t? (this.getNodeParameter('name', itemIndex) as string)\n\t\t\t\t: nodeNameToToolName(node);\n\t\tconst toolDescription = this.getNodeParameter('description', itemIndex) as string;\n\t\tconst topK = this.getNodeParameter('topK', itemIndex, 4) as number;\n\n\t\tconst vectorStore = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiVectorStore,\n\t\t\titemIndex,\n\t\t)) as VectorStore;\n\n\t\tconst llm = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiLanguageModel,\n\t\t\t0,\n\t\t)) as BaseLanguageModel;\n\n\t\tconst description = VectorStoreQATool.getDescription(name, toolDescription);\n\t\tconst vectorStoreTool = new VectorStoreQATool(name, description, {\n\t\t\tllm,\n\t\t\tvectorStore,\n\t\t});\n\n\t\tvectorStoreTool.chain = VectorDBQAChain.fromLLM(llm, vectorStore, {\n\t\t\tk: topK,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(vectorStoreTool, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAgC;AAChC,mBAAkC;AAOlC,0BAAoC;AAEpC,qBAAmC;AACnC,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,gBAAqC;AAAA,EAA3C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,W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AAM,OAAO,KAAK,iBAAiB,QAAQ,WAAW,CAAC;AAEvD,UAAM,cAAe,MAAM,KAAK;AAAA,MAC/B,wCAAoB;AAAA,MACpB;AAAA,IACD;AAEA,UAAM,MAAO,MAAM,KAAK;AAAA,MACvB,wCAAoB;AAAA,MACpB;AAAA,IACD;AAEA,UAAM,cAAc,+BAAkB,eAAe,MAAM,eAAe;AAC1E,UAAM,kBAAkB,IAAI,+BAAkB,MAAM,aAAa;AAAA,MAChE;AAAA,MACA;AAAA,IACD,CAAC;AAED,oBAAgB,QAAQ,8BAAgB,QAAQ,KAAK,aAAa;AAAA,MACjE,GAAG;AAAA,IACJ,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,iBAAiB,IAAI;AAAA,IAC3C;AAAA,EACD;AACD;","names":[]}
|
|
@@ -47,7 +47,7 @@ class ToolWorkflow extends import_n8n_workflow.VersionedNodeType {
|
|
|
47
47
|
]
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
-
defaultVersion: 2.
|
|
50
|
+
defaultVersion: 2.2
|
|
51
51
|
};
|
|
52
52
|
const nodeVersions = {
|
|
53
53
|
1: new import_ToolWorkflowV1.ToolWorkflowV1(baseDescription),
|
|
@@ -55,7 +55,8 @@ class ToolWorkflow extends import_n8n_workflow.VersionedNodeType {
|
|
|
55
55
|
1.2: new import_ToolWorkflowV1.ToolWorkflowV1(baseDescription),
|
|
56
56
|
1.3: new import_ToolWorkflowV1.ToolWorkflowV1(baseDescription),
|
|
57
57
|
2: new import_ToolWorkflowV2.ToolWorkflowV2(baseDescription),
|
|
58
|
-
2.1: new import_ToolWorkflowV2.ToolWorkflowV2(baseDescription)
|
|
58
|
+
2.1: new import_ToolWorkflowV2.ToolWorkflowV2(baseDescription),
|
|
59
|
+
2.2: new import_ToolWorkflowV2.ToolWorkflowV2(baseDescription)
|
|
59
60
|
};
|
|
60
61
|
super(nodeVersions, baseDescription);
|
|
61
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/tools/ToolWorkflow/ToolWorkflow.node.ts"],"sourcesContent":["import type { IVersionedNodeType, INodeTypeBaseDescription } from 'n8n-workflow';\nimport { VersionedNodeType } from 'n8n-workflow';\n\nimport { ToolWorkflowV1 } from './v1/ToolWorkflowV1.node';\nimport { ToolWorkflowV2 } from './v2/ToolWorkflowV2.node';\n\nexport class ToolWorkflow extends VersionedNodeType {\n\tconstructor() {\n\t\tconst baseDescription: INodeTypeBaseDescription = {\n\t\t\tdisplayName: 'Call n8n Sub-Workflow Tool',\n\t\t\tname: 'toolWorkflow',\n\t\t\ticon: 'fa:network-wired',\n\t\t\ticonColor: 'black',\n\t\t\tgroup: ['transform'],\n\t\t\tdescription:\n\t\t\t\t'Uses another n8n workflow as a tool. Allows packaging any n8n node(s) as a tool.',\n\t\t\tcodex: {\n\t\t\t\tcategories: ['AI'],\n\t\t\t\tsubcategories: {\n\t\t\t\t\tAI: ['Tools'],\n\t\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t\t},\n\t\t\t\tresources: {\n\t\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolworkflow/',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdefaultVersion: 2.
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/tools/ToolWorkflow/ToolWorkflow.node.ts"],"sourcesContent":["import type { IVersionedNodeType, INodeTypeBaseDescription } from 'n8n-workflow';\nimport { VersionedNodeType } from 'n8n-workflow';\n\nimport { ToolWorkflowV1 } from './v1/ToolWorkflowV1.node';\nimport { ToolWorkflowV2 } from './v2/ToolWorkflowV2.node';\n\nexport class ToolWorkflow extends VersionedNodeType {\n\tconstructor() {\n\t\tconst baseDescription: INodeTypeBaseDescription = {\n\t\t\tdisplayName: 'Call n8n Sub-Workflow Tool',\n\t\t\tname: 'toolWorkflow',\n\t\t\ticon: 'fa:network-wired',\n\t\t\ticonColor: 'black',\n\t\t\tgroup: ['transform'],\n\t\t\tdescription:\n\t\t\t\t'Uses another n8n workflow as a tool. Allows packaging any n8n node(s) as a tool.',\n\t\t\tcodex: {\n\t\t\t\tcategories: ['AI'],\n\t\t\t\tsubcategories: {\n\t\t\t\t\tAI: ['Tools'],\n\t\t\t\t\tTools: ['Recommended Tools'],\n\t\t\t\t},\n\t\t\t\tresources: {\n\t\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolworkflow/',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdefaultVersion: 2.2,\n\t\t};\n\n\t\tconst nodeVersions: IVersionedNodeType['nodeVersions'] = {\n\t\t\t1: new ToolWorkflowV1(baseDescription),\n\t\t\t1.1: new ToolWorkflowV1(baseDescription),\n\t\t\t1.2: new ToolWorkflowV1(baseDescription),\n\t\t\t1.3: new ToolWorkflowV1(baseDescription),\n\t\t\t2: new ToolWorkflowV2(baseDescription),\n\t\t\t2.1: new ToolWorkflowV2(baseDescription),\n\t\t\t2.2: new ToolWorkflowV2(baseDescription),\n\t\t};\n\t\tsuper(nodeVersions, baseDescription);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAkC;AAElC,4BAA+B;AAC/B,4BAA+B;AAExB,MAAM,qBAAqB,sCAAkB;AAAA,EACnD,cAAc;AACb,UAAM,kBAA4C;AAAA,MACjD,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB,aACC;AAAA,MACD,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,OAAO;AAAA,UACZ,OAAO,CAAC,mBAAmB;AAAA,QAC5B;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,gBAAgB;AAAA,IACjB;AAEA,UAAM,eAAmD;AAAA,MACxD,GAAG,IAAI,qCAAe,eAAe;AAAA,MACrC,KAAK,IAAI,qCAAe,eAAe;AAAA,MACvC,KAAK,IAAI,qCAAe,eAAe;AAAA,MACvC,KAAK,IAAI,qCAAe,eAAe;AAAA,MACvC,GAAG,IAAI,qCAAe,eAAe;AAAA,MACrC,KAAK,IAAI,qCAAe,eAAe;AAAA,MACvC,KAAK,IAAI,qCAAe,eAAe;AAAA,IACxC;AACA,UAAM,cAAc,eAAe;AAAA,EACpC;AACD;","names":[]}
|
|
@@ -21,6 +21,7 @@ __export(ToolWorkflowV2_node_exports, {
|
|
|
21
21
|
ToolWorkflowV2: () => ToolWorkflowV2
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(ToolWorkflowV2_node_exports);
|
|
24
|
+
var import_helpers = require("../../../../utils/helpers");
|
|
24
25
|
var import_methods = require("./methods");
|
|
25
26
|
var import_WorkflowToolService = require("./utils/WorkflowToolService");
|
|
26
27
|
var import_versionDescription = require("./versionDescription");
|
|
@@ -35,9 +36,11 @@ class ToolWorkflowV2 {
|
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
async supplyData(itemIndex) {
|
|
38
|
-
const
|
|
39
|
+
const node = this.getNode();
|
|
40
|
+
const { typeVersion } = node;
|
|
41
|
+
const returnAllItems = typeVersion > 2;
|
|
39
42
|
const workflowToolService = new import_WorkflowToolService.WorkflowToolService(this, { returnAllItems });
|
|
40
|
-
const name = this.getNodeParameter("name", itemIndex);
|
|
43
|
+
const name = typeVersion <= 2.1 ? this.getNodeParameter("name", itemIndex) : (0, import_helpers.nodeNameToToolName)(node);
|
|
41
44
|
const description = this.getNodeParameter("description", itemIndex);
|
|
42
45
|
const tool = await workflowToolService.createTool({
|
|
43
46
|
name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.ts"],"sourcesContent":["import type {\n\tINodeTypeBaseDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tINodeType,\n\tINodeTypeDescription,\n} from 'n8n-workflow';\n\nimport { localResourceMapping } from './methods';\nimport { WorkflowToolService } from './utils/WorkflowToolService';\nimport { versionDescription } from './versionDescription';\n\nexport class ToolWorkflowV2 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\t...baseDescription,\n\t\t\t...versionDescription,\n\t\t};\n\t}\n\n\tmethods = {\n\t\tlocalResourceMapping,\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.ts"],"sourcesContent":["import type {\n\tINodeTypeBaseDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n\tINodeType,\n\tINodeTypeDescription,\n} from 'n8n-workflow';\n\nimport { nodeNameToToolName } from '@utils/helpers';\n\nimport { localResourceMapping } from './methods';\nimport { WorkflowToolService } from './utils/WorkflowToolService';\nimport { versionDescription } from './versionDescription';\n\nexport class ToolWorkflowV2 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\t...baseDescription,\n\t\t\t...versionDescription,\n\t\t};\n\t}\n\n\tmethods = {\n\t\tlocalResourceMapping,\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst node = this.getNode();\n\t\tconst { typeVersion } = node;\n\t\tconst returnAllItems = typeVersion > 2;\n\n\t\tconst workflowToolService = new WorkflowToolService(this, { returnAllItems });\n\t\tconst name =\n\t\t\ttypeVersion <= 2.1\n\t\t\t\t? (this.getNodeParameter('name', itemIndex) as string)\n\t\t\t\t: nodeNameToToolName(node);\n\t\tconst description = this.getNodeParameter('description', itemIndex) as string;\n\n\t\tconst tool = await workflowToolService.createTool({\n\t\t\tname,\n\t\t\tdescription,\n\t\t\titemIndex,\n\t\t});\n\n\t\treturn { response: tool };\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,qBAAmC;AAEnC,qBAAqC;AACrC,iCAAoC;AACpC,gCAAmC;AAE5B,MAAM,eAAoC;AAAA,EAGhD,YAAY,iBAA2C;AAOvD,mBAAU;AAAA,MACT;AAAA,IACD;AARC,SAAK,cAAc;AAAA,MAClB,GAAG;AAAA,MACH,GAAG;AAAA,IACJ;AAAA,EACD;AAAA,EAMA,MAAM,WAAuC,WAAwC;AACpF,UAAM,OAAO,KAAK,QAAQ;AAC1B,UAAM,EAAE,YAAY,IAAI;AACxB,UAAM,iBAAiB,cAAc;AAErC,UAAM,sBAAsB,IAAI,+CAAoB,MAAM,EAAE,eAAe,CAAC;AAC5E,UAAM,OACL,eAAe,MACX,KAAK,iBAAiB,QAAQ,SAAS,QACxC,mCAAmB,IAAI;AAC3B,UAAM,cAAc,KAAK,iBAAiB,eAAe,SAAS;AAElE,UAAM,OAAO,MAAM,oBAAoB,WAAW;AAAA,MACjD;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAC;AAED,WAAO,EAAE,UAAU,KAAK;AAAA,EACzB;AACD;","names":[]}
|
|
@@ -26,7 +26,9 @@ async function loadSubWorkflowInputs() {
|
|
|
26
26
|
const { fields, subworkflowInfo, dataMode } = await import_GenericFunctions.loadWorkflowInputMappings.bind(this)();
|
|
27
27
|
let emptyFieldsNotice;
|
|
28
28
|
if (fields.length === 0) {
|
|
29
|
-
const
|
|
29
|
+
const { triggerId, workflowId } = subworkflowInfo ?? {};
|
|
30
|
+
const path = (workflowId ?? "") + (triggerId ? `/${triggerId.slice(0, 6)}` : "");
|
|
31
|
+
const subworkflowLink = workflowId ? `<a href="/workflow/${path}" target="_blank">sub-workflow\u2019s trigger</a>` : "sub-workflow\u2019s trigger";
|
|
30
32
|
switch (dataMode) {
|
|
31
33
|
case "passthrough":
|
|
32
34
|
emptyFieldsNotice = `This sub-workflow is set up to receive all input data, without specific inputs the Agent will not be able to pass data to this tool. You can define specific inputs in the ${subworkflowLink}.`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/tools/ToolWorkflow/v2/methods/localResourceMapping.ts"],"sourcesContent":["import { loadWorkflowInputMappings } from 'n8n-nodes-base/dist/utils/workflowInputsResourceMapping/GenericFunctions';\nimport type { ILocalLoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';\n\nexport async function loadSubWorkflowInputs(\n\tthis: ILocalLoadOptionsFunctions,\n): Promise<ResourceMapperFields> {\n\tconst { fields, subworkflowInfo, dataMode } = await loadWorkflowInputMappings.bind(this)();\n\tlet emptyFieldsNotice: string | undefined;\n\tif (fields.length === 0) {\n\t\tconst
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/tools/ToolWorkflow/v2/methods/localResourceMapping.ts"],"sourcesContent":["import { loadWorkflowInputMappings } from 'n8n-nodes-base/dist/utils/workflowInputsResourceMapping/GenericFunctions';\nimport type { ILocalLoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';\n\nexport async function loadSubWorkflowInputs(\n\tthis: ILocalLoadOptionsFunctions,\n): Promise<ResourceMapperFields> {\n\tconst { fields, subworkflowInfo, dataMode } = await loadWorkflowInputMappings.bind(this)();\n\tlet emptyFieldsNotice: string | undefined;\n\tif (fields.length === 0) {\n\t\tconst { triggerId, workflowId } = subworkflowInfo ?? {};\n\t\tconst path = (workflowId ?? '') + (triggerId ? `/${triggerId.slice(0, 6)}` : '');\n\t\tconst subworkflowLink = workflowId\n\t\t\t? `<a href=\"/workflow/${path}\" target=\"_blank\">sub-workflow’s trigger</a>`\n\t\t\t: 'sub-workflow’s trigger';\n\n\t\tswitch (dataMode) {\n\t\t\tcase 'passthrough':\n\t\t\t\temptyFieldsNotice = `This sub-workflow is set up to receive all input data, without specific inputs the Agent will not be able to pass data to this tool. You can define specific inputs in the ${subworkflowLink}.`;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\temptyFieldsNotice = `This sub-workflow will not receive any input when called by your AI node. Define your expected input in the ${subworkflowLink}.`;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn { fields, emptyFieldsNotice };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAA0C;AAG1C,eAAsB,wBAEW;AAChC,QAAM,EAAE,QAAQ,iBAAiB,SAAS,IAAI,MAAM,kDAA0B,KAAK,IAAI,EAAE;AACzF,MAAI;AACJ,MAAI,OAAO,WAAW,GAAG;AACxB,UAAM,EAAE,WAAW,WAAW,IAAI,mBAAmB,CAAC;AACtD,UAAM,QAAQ,cAAc,OAAO,YAAY,IAAI,UAAU,MAAM,GAAG,CAAC,CAAC,KAAK;AAC7E,UAAM,kBAAkB,aACrB,sBAAsB,IAAI,sDAC1B;AAEH,YAAQ,UAAU;AAAA,MACjB,KAAK;AACJ,4BAAoB,8KAA8K,eAAe;AACjN;AAAA,MACD;AACC,4BAAoB,+GAA+G,eAAe;AAClJ;AAAA,IACF;AAAA,EACD;AACA,SAAO,EAAE,QAAQ,kBAAkB;AACpC;","names":[]}
|
|
@@ -31,7 +31,7 @@ const versionDescription = {
|
|
|
31
31
|
defaults: {
|
|
32
32
|
name: "Call n8n Workflow Tool"
|
|
33
33
|
},
|
|
34
|
-
version: [2, 2.1],
|
|
34
|
+
version: [2, 2.1, 2.2],
|
|
35
35
|
inputs: [],
|
|
36
36
|
outputs: [import_n8n_workflow.NodeConnectionTypes.AiTool],
|
|
37
37
|
outputNames: ["Tool"],
|
|
@@ -50,7 +50,12 @@ const versionDescription = {
|
|
|
50
50
|
default: "",
|
|
51
51
|
placeholder: "e.g. My_Color_Tool",
|
|
52
52
|
validateType: "string-alphanumeric",
|
|
53
|
-
description: "The name of the function to be called, could contain letters, numbers, and underscores only"
|
|
53
|
+
description: "The name of the function to be called, could contain letters, numbers, and underscores only",
|
|
54
|
+
displayOptions: {
|
|
55
|
+
show: {
|
|
56
|
+
"@version": [{ _cnd: { lte: 2.1 } }]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
54
59
|
},
|
|
55
60
|
{
|
|
56
61
|
displayName: "Description",
|