@n8n/n8n-nodes-langchain 2.2.1 → 2.3.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/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js +4 -2
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js.map +1 -1
- package/dist/nodes/tools/ToolCode/ToolCode.node.js +23 -32
- package/dist/nodes/tools/ToolCode/ToolCode.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/constants.js +1 -11
- package/dist/nodes/trigger/ChatTrigger/constants.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.js +121 -11
- package/dist/nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.js.map +1 -1
- package/dist/types/nodes.json +2 -2
- package/dist/utils/agent-execution/buildSteps.js +2 -2
- package/dist/utils/agent-execution/buildSteps.js.map +1 -1
- package/dist/utils/agent-execution/memoryManagement.js +81 -6
- package/dist/utils/agent-execution/memoryManagement.js.map +1 -1
- package/dist/utils/output_parsers/N8nStructuredOutputParser.js +16 -1
- package/dist/utils/output_parsers/N8nStructuredOutputParser.js.map +1 -1
- package/package.json +10 -10
|
@@ -55,7 +55,8 @@ async function runAgent(ctx, executor, itemContext, model, memory, response) {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
if (memory && input && result?.output) {
|
|
58
|
-
|
|
58
|
+
const previousCount = response?.metadata?.previousRequests?.length;
|
|
59
|
+
await (0, import_agent_execution.saveToMemory)(input, result.output, memory, steps, previousCount);
|
|
59
60
|
}
|
|
60
61
|
if (options.returnIntermediateSteps && steps.length > 0) {
|
|
61
62
|
result.intermediateSteps = steps;
|
|
@@ -69,7 +70,8 @@ async function runAgent(ctx, executor, itemContext, model, memory, response) {
|
|
|
69
70
|
});
|
|
70
71
|
if ("returnValues" in modelResponse) {
|
|
71
72
|
if (memory && input && modelResponse.returnValues.output) {
|
|
72
|
-
|
|
73
|
+
const previousCount = response?.metadata?.previousRequests?.length;
|
|
74
|
+
await (0, import_agent_execution.saveToMemory)(input, modelResponse.returnValues.output, memory, steps, previousCount);
|
|
73
75
|
}
|
|
74
76
|
const result = { ...modelResponse.returnValues };
|
|
75
77
|
if (options.returnIntermediateSteps && steps.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.ts"],"sourcesContent":["import type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport type { AgentRunnableSequence } from '@langchain/classic/agents';\nimport type { BaseChatMemory } from '@langchain/classic/memory';\nimport type {\n\tIExecuteFunctions,\n\tISupplyDataFunctions,\n\tEngineResponse,\n\tEngineRequest,\n} from 'n8n-workflow';\n\nimport {\n\tloadMemory,\n\tprocessEventStream,\n\tcreateEngineRequests,\n\tsaveToMemory,\n} from '@utils/agent-execution';\n\nimport { SYSTEM_MESSAGE } from '../../prompt';\nimport type { AgentResult, RequestResponseMetadata } from '../types';\nimport { buildResponseMetadata } from './buildResponseMetadata';\nimport type { ItemContext } from './prepareItemContext';\n\ntype RunAgentResult = AgentResult | EngineRequest<RequestResponseMetadata>;\n/**\n * Runs the agent for a single item, choosing between streaming or non-streaming execution.\n * Handles both regular execution and execution after tool calls.\n *\n * @param ctx - The execution context\n * @param executor - The agent runnable sequence\n * @param itemContext - Context for the current item\n * @param model - The chat model for token counting\n * @param memory - Optional memory for conversation context\n * @param response - Optional engine response with previous tool calls\n * @returns AgentResult or engine request with tool calls\n */\nexport async function runAgent(\n\tctx: IExecuteFunctions | ISupplyDataFunctions,\n\texecutor: AgentRunnableSequence,\n\titemContext: ItemContext,\n\tmodel: BaseChatModel,\n\tmemory: BaseChatMemory | undefined,\n\tresponse?: EngineResponse<RequestResponseMetadata>,\n): Promise<RunAgentResult> {\n\tconst { itemIndex, input, steps, tools, options } = itemContext;\n\n\tconst invokeParams = {\n\t\tsteps,\n\t\tinput,\n\t\tsystem_message: options.systemMessage ?? SYSTEM_MESSAGE,\n\t\tformatting_instructions:\n\t\t\t'IMPORTANT: For your response to user, you MUST use the `format_final_json_response` tool with your complete answer formatted according to the required schema. Do not attempt to format the JSON manually - always use this tool. Your response will be rejected if it is not properly formatted through this tool. Only use this tool once you are ready to provide your final answer.',\n\t};\n\tconst executeOptions = { signal: ctx.getExecutionCancelSignal() };\n\n\t// Check if streaming is actually available\n\tconst isStreamingAvailable = 'isStreaming' in ctx ? ctx.isStreaming?.() : undefined;\n\n\tif (\n\t\t'isStreaming' in ctx &&\n\t\toptions.enableStreaming &&\n\t\tisStreamingAvailable &&\n\t\tctx.getNode().typeVersion >= 2.1\n\t) {\n\t\tconst chatHistory = await loadMemory(memory, model, options.maxTokensFromMemory);\n\t\tconst eventStream = executor.streamEvents(\n\t\t\t{\n\t\t\t\t...invokeParams,\n\t\t\t\tchat_history: chatHistory,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: 'v2',\n\t\t\t\t...executeOptions,\n\t\t\t},\n\t\t);\n\n\t\tconst result = await processEventStream(ctx, eventStream, itemIndex);\n\n\t\t// If result contains tool calls, build the request object like the normal flow\n\t\tif (result.toolCalls && result.toolCalls.length > 0) {\n\t\t\tconst actions = await createEngineRequests(result.toolCalls, itemIndex, tools);\n\n\t\t\treturn {\n\t\t\t\tactions,\n\t\t\t\tmetadata: buildResponseMetadata(response, itemIndex),\n\t\t\t};\n\t\t}\n\t\t// Save conversation to memory including any tool call context\n\t\tif (memory && input && result?.output) {\n\t\t\tawait saveToMemory(input, result.output, memory, steps);\n\t\t}\n\n\t\tif (options.returnIntermediateSteps && steps.length > 0) {\n\t\t\tresult.intermediateSteps = steps;\n\t\t}\n\n\t\treturn result;\n\t} else {\n\t\t// Handle regular execution\n\t\tconst chatHistory = await loadMemory(memory, model, options.maxTokensFromMemory);\n\n\t\tconst modelResponse = await executor.invoke({\n\t\t\t...invokeParams,\n\t\t\tchat_history: chatHistory,\n\t\t});\n\n\t\tif ('returnValues' in modelResponse) {\n\t\t\t// Save conversation to memory including any tool call context\n\t\t\tif (memory && input && modelResponse.returnValues.output) {\n\t\t\t\tawait saveToMemory(input, modelResponse.returnValues.output, memory, steps);\n\t\t\t}\n\t\t\t// Include intermediate steps if requested\n\t\t\tconst result = { ...modelResponse.returnValues };\n\t\t\tif (options.returnIntermediateSteps && steps.length > 0) {\n\t\t\t\tresult.intermediateSteps = steps;\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\n\t\t// If response contains tool calls, we need to return this in the right format\n\t\tconst actions = await createEngineRequests(modelResponse, itemIndex, tools);\n\n\t\treturn {\n\t\t\tactions,\n\t\t\tmetadata: buildResponseMetadata(response, itemIndex),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,6BAKO;AAEP,oBAA+B;AAE/B,mCAAsC;AAgBtC,eAAsB,SACrB,KACA,UACA,aACA,OACA,QACA,UAC0B;AAC1B,QAAM,EAAE,WAAW,OAAO,OAAO,OAAO,QAAQ,IAAI;AAEpD,QAAM,eAAe;AAAA,IACpB;AAAA,IACA;AAAA,IACA,gBAAgB,QAAQ,iBAAiB;AAAA,IACzC,yBACC;AAAA,EACF;AACA,QAAM,iBAAiB,EAAE,QAAQ,IAAI,yBAAyB,EAAE;AAGhE,QAAM,uBAAuB,iBAAiB,MAAM,IAAI,cAAc,IAAI;AAE1E,MACC,iBAAiB,OACjB,QAAQ,mBACR,wBACA,IAAI,QAAQ,EAAE,eAAe,KAC5B;AACD,UAAM,cAAc,UAAM,mCAAW,QAAQ,OAAO,QAAQ,mBAAmB;AAC/E,UAAM,cAAc,SAAS;AAAA,MAC5B;AAAA,QACC,GAAG;AAAA,QACH,cAAc;AAAA,MACf;AAAA,MACA;AAAA,QACC,SAAS;AAAA,QACT,GAAG;AAAA,MACJ;AAAA,IACD;AAEA,UAAM,SAAS,UAAM,2CAAmB,KAAK,aAAa,SAAS;AAGnE,QAAI,OAAO,aAAa,OAAO,UAAU,SAAS,GAAG;AACpD,YAAM,UAAU,UAAM,6CAAqB,OAAO,WAAW,WAAW,KAAK;AAE7E,aAAO;AAAA,QACN;AAAA,QACA,cAAU,oDAAsB,UAAU,SAAS;AAAA,MACpD;AAAA,IACD;AAEA,QAAI,UAAU,SAAS,QAAQ,QAAQ;AACtC,gBAAM,qCAAa,OAAO,OAAO,QAAQ,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.ts"],"sourcesContent":["import type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport type { AgentRunnableSequence } from '@langchain/classic/agents';\nimport type { BaseChatMemory } from '@langchain/classic/memory';\nimport type {\n\tIExecuteFunctions,\n\tISupplyDataFunctions,\n\tEngineResponse,\n\tEngineRequest,\n} from 'n8n-workflow';\n\nimport {\n\tloadMemory,\n\tprocessEventStream,\n\tcreateEngineRequests,\n\tsaveToMemory,\n} from '@utils/agent-execution';\n\nimport { SYSTEM_MESSAGE } from '../../prompt';\nimport type { AgentResult, RequestResponseMetadata } from '../types';\nimport { buildResponseMetadata } from './buildResponseMetadata';\nimport type { ItemContext } from './prepareItemContext';\n\ntype RunAgentResult = AgentResult | EngineRequest<RequestResponseMetadata>;\n/**\n * Runs the agent for a single item, choosing between streaming or non-streaming execution.\n * Handles both regular execution and execution after tool calls.\n *\n * @param ctx - The execution context\n * @param executor - The agent runnable sequence\n * @param itemContext - Context for the current item\n * @param model - The chat model for token counting\n * @param memory - Optional memory for conversation context\n * @param response - Optional engine response with previous tool calls\n * @returns AgentResult or engine request with tool calls\n */\nexport async function runAgent(\n\tctx: IExecuteFunctions | ISupplyDataFunctions,\n\texecutor: AgentRunnableSequence,\n\titemContext: ItemContext,\n\tmodel: BaseChatModel,\n\tmemory: BaseChatMemory | undefined,\n\tresponse?: EngineResponse<RequestResponseMetadata>,\n): Promise<RunAgentResult> {\n\tconst { itemIndex, input, steps, tools, options } = itemContext;\n\n\tconst invokeParams = {\n\t\tsteps,\n\t\tinput,\n\t\tsystem_message: options.systemMessage ?? SYSTEM_MESSAGE,\n\t\tformatting_instructions:\n\t\t\t'IMPORTANT: For your response to user, you MUST use the `format_final_json_response` tool with your complete answer formatted according to the required schema. Do not attempt to format the JSON manually - always use this tool. Your response will be rejected if it is not properly formatted through this tool. Only use this tool once you are ready to provide your final answer.',\n\t};\n\tconst executeOptions = { signal: ctx.getExecutionCancelSignal() };\n\n\t// Check if streaming is actually available\n\tconst isStreamingAvailable = 'isStreaming' in ctx ? ctx.isStreaming?.() : undefined;\n\n\tif (\n\t\t'isStreaming' in ctx &&\n\t\toptions.enableStreaming &&\n\t\tisStreamingAvailable &&\n\t\tctx.getNode().typeVersion >= 2.1\n\t) {\n\t\tconst chatHistory = await loadMemory(memory, model, options.maxTokensFromMemory);\n\t\tconst eventStream = executor.streamEvents(\n\t\t\t{\n\t\t\t\t...invokeParams,\n\t\t\t\tchat_history: chatHistory,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: 'v2',\n\t\t\t\t...executeOptions,\n\t\t\t},\n\t\t);\n\n\t\tconst result = await processEventStream(ctx, eventStream, itemIndex);\n\n\t\t// If result contains tool calls, build the request object like the normal flow\n\t\tif (result.toolCalls && result.toolCalls.length > 0) {\n\t\t\tconst actions = await createEngineRequests(result.toolCalls, itemIndex, tools);\n\n\t\t\treturn {\n\t\t\t\tactions,\n\t\t\t\tmetadata: buildResponseMetadata(response, itemIndex),\n\t\t\t};\n\t\t}\n\t\t// Save conversation to memory including any tool call context\n\t\tif (memory && input && result?.output) {\n\t\t\tconst previousCount = response?.metadata?.previousRequests?.length;\n\t\t\tawait saveToMemory(input, result.output, memory, steps, previousCount);\n\t\t}\n\n\t\tif (options.returnIntermediateSteps && steps.length > 0) {\n\t\t\tresult.intermediateSteps = steps;\n\t\t}\n\n\t\treturn result;\n\t} else {\n\t\t// Handle regular execution\n\t\tconst chatHistory = await loadMemory(memory, model, options.maxTokensFromMemory);\n\n\t\tconst modelResponse = await executor.invoke({\n\t\t\t...invokeParams,\n\t\t\tchat_history: chatHistory,\n\t\t});\n\n\t\tif ('returnValues' in modelResponse) {\n\t\t\t// Save conversation to memory including any tool call context\n\t\t\tif (memory && input && modelResponse.returnValues.output) {\n\t\t\t\tconst previousCount = response?.metadata?.previousRequests?.length;\n\t\t\t\tawait saveToMemory(input, modelResponse.returnValues.output, memory, steps, previousCount);\n\t\t\t}\n\t\t\t// Include intermediate steps if requested\n\t\t\tconst result = { ...modelResponse.returnValues };\n\t\t\tif (options.returnIntermediateSteps && steps.length > 0) {\n\t\t\t\tresult.intermediateSteps = steps;\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\n\t\t// If response contains tool calls, we need to return this in the right format\n\t\tconst actions = await createEngineRequests(modelResponse, itemIndex, tools);\n\n\t\treturn {\n\t\t\tactions,\n\t\t\tmetadata: buildResponseMetadata(response, itemIndex),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,6BAKO;AAEP,oBAA+B;AAE/B,mCAAsC;AAgBtC,eAAsB,SACrB,KACA,UACA,aACA,OACA,QACA,UAC0B;AAC1B,QAAM,EAAE,WAAW,OAAO,OAAO,OAAO,QAAQ,IAAI;AAEpD,QAAM,eAAe;AAAA,IACpB;AAAA,IACA;AAAA,IACA,gBAAgB,QAAQ,iBAAiB;AAAA,IACzC,yBACC;AAAA,EACF;AACA,QAAM,iBAAiB,EAAE,QAAQ,IAAI,yBAAyB,EAAE;AAGhE,QAAM,uBAAuB,iBAAiB,MAAM,IAAI,cAAc,IAAI;AAE1E,MACC,iBAAiB,OACjB,QAAQ,mBACR,wBACA,IAAI,QAAQ,EAAE,eAAe,KAC5B;AACD,UAAM,cAAc,UAAM,mCAAW,QAAQ,OAAO,QAAQ,mBAAmB;AAC/E,UAAM,cAAc,SAAS;AAAA,MAC5B;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D;AACD;","names":[]}
|
|
@@ -26,7 +26,6 @@ var import_config = require("@n8n/config");
|
|
|
26
26
|
var import_di = require("@n8n/di");
|
|
27
27
|
var import_JavaScriptSandbox = require("n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox");
|
|
28
28
|
var import_JsTaskRunnerSandbox = require("n8n-nodes-base/dist/nodes/Code/JsTaskRunnerSandbox");
|
|
29
|
-
var import_PythonSandbox = require("n8n-nodes-base/dist/nodes/Code/PythonSandbox");
|
|
30
29
|
var import_PythonTaskRunnerSandbox = require("n8n-nodes-base/dist/nodes/Code/PythonTaskRunnerSandbox");
|
|
31
30
|
var import_Sandbox = require("n8n-nodes-base/dist/nodes/Code/Sandbox");
|
|
32
31
|
var import_n8n_workflow = require("n8n-workflow");
|
|
@@ -48,7 +47,6 @@ function getTool(ctx, itemIndex, log = true) {
|
|
|
48
47
|
const workflowMode = ctx.getMode();
|
|
49
48
|
const runnersConfig = import_di.Container.get(import_config.TaskRunnersConfig);
|
|
50
49
|
const isJsRunnerEnabled = runnersConfig.enabled;
|
|
51
|
-
const isPyRunnerEnabled = runnersConfig.isNativePythonRunnerEnabled;
|
|
52
50
|
const { typeVersion } = node;
|
|
53
51
|
const name = typeVersion <= 1.1 ? ctx.getNodeParameter("name", itemIndex) : (0, import_n8n_workflow.nodeNameToToolName)(node);
|
|
54
52
|
const description = ctx.getNodeParameter("description", itemIndex);
|
|
@@ -60,35 +58,31 @@ function getTool(ctx, itemIndex, log = true) {
|
|
|
60
58
|
} else {
|
|
61
59
|
code = ctx.getNodeParameter("pythonCode", itemIndex);
|
|
62
60
|
}
|
|
63
|
-
const
|
|
64
|
-
const context = import_Sandbox.getSandboxContext.call(ctx, index);
|
|
65
|
-
context.query = query;
|
|
66
|
-
let sandbox;
|
|
61
|
+
const runFunction = async (query) => {
|
|
67
62
|
if (language === "javaScript") {
|
|
68
|
-
|
|
63
|
+
if (isJsRunnerEnabled) {
|
|
64
|
+
const sandbox = new import_JsTaskRunnerSandbox.JsTaskRunnerSandbox(
|
|
65
|
+
code,
|
|
66
|
+
"runOnceForAllItems",
|
|
67
|
+
workflowMode,
|
|
68
|
+
ctx,
|
|
69
|
+
void 0,
|
|
70
|
+
{
|
|
71
|
+
query
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
return await sandbox.runCodeForTool();
|
|
75
|
+
} else {
|
|
76
|
+
const context = import_Sandbox.getSandboxContext.call(ctx, itemIndex);
|
|
77
|
+
context.query = query;
|
|
78
|
+
const sandbox = new import_JavaScriptSandbox.JavaScriptSandbox(context, code, ctx.helpers);
|
|
79
|
+
sandbox.on(
|
|
80
|
+
"output",
|
|
81
|
+
workflowMode === "manual" ? ctx.sendMessageToUI.bind(ctx) : (...args) => console.log(`[Workflow "${ctx.getWorkflow().id}"][Node "${node.name}"]`, ...args)
|
|
82
|
+
);
|
|
83
|
+
return await sandbox.runCode();
|
|
84
|
+
}
|
|
69
85
|
} else {
|
|
70
|
-
sandbox = new import_PythonSandbox.PythonSandbox(context, code, ctx.helpers);
|
|
71
|
-
}
|
|
72
|
-
sandbox.on(
|
|
73
|
-
"output",
|
|
74
|
-
workflowMode === "manual" ? ctx.sendMessageToUI.bind(ctx) : (...args) => console.log(`[Workflow "${ctx.getWorkflow().id}"][Node "${node.name}"]`, ...args)
|
|
75
|
-
);
|
|
76
|
-
return sandbox;
|
|
77
|
-
};
|
|
78
|
-
const runFunction = async (query) => {
|
|
79
|
-
if (language === "javaScript" && isJsRunnerEnabled) {
|
|
80
|
-
const sandbox = new import_JsTaskRunnerSandbox.JsTaskRunnerSandbox(
|
|
81
|
-
code,
|
|
82
|
-
"runOnceForAllItems",
|
|
83
|
-
workflowMode,
|
|
84
|
-
ctx,
|
|
85
|
-
void 0,
|
|
86
|
-
{
|
|
87
|
-
query
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
return await sandbox.runCodeForTool();
|
|
91
|
-
} else if (language === "python" && isPyRunnerEnabled) {
|
|
92
86
|
const sandbox = new import_PythonTaskRunnerSandbox.PythonTaskRunnerSandbox(
|
|
93
87
|
code,
|
|
94
88
|
"runOnceForAllItems",
|
|
@@ -99,9 +93,6 @@ function getTool(ctx, itemIndex, log = true) {
|
|
|
99
93
|
}
|
|
100
94
|
);
|
|
101
95
|
return await sandbox.runCodeForTool();
|
|
102
|
-
} else {
|
|
103
|
-
const sandbox = getSandbox(query, itemIndex);
|
|
104
|
-
return await sandbox.runCode();
|
|
105
96
|
}
|
|
106
97
|
};
|
|
107
98
|
const toolHandler = async (query) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/tools/ToolCode/ToolCode.node.ts"],"sourcesContent":["import { DynamicStructuredTool, DynamicTool } from '@langchain/core/tools';\nimport { TaskRunnersConfig } from '@n8n/config';\nimport { Container } from '@n8n/di';\nimport type { JSONSchema7 } from 'json-schema';\nimport { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';\nimport { JsTaskRunnerSandbox } from 'n8n-nodes-base/dist/nodes/Code/JsTaskRunnerSandbox';\nimport { PythonSandbox } from 'n8n-nodes-base/dist/nodes/Code/PythonSandbox';\nimport { PythonTaskRunnerSandbox } from 'n8n-nodes-base/dist/nodes/Code/PythonTaskRunnerSandbox';\nimport type { Sandbox } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport type {\n\tExecutionError,\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n} from 'n8n-workflow';\nimport {\n\tjsonParse,\n\tNodeConnectionTypes,\n\tnodeNameToToolName,\n\tNodeOperationError,\n} from 'n8n-workflow';\n\nimport {\n\tbuildInputSchemaField,\n\tbuildJsonSchemaExampleField,\n\tbuildJsonSchemaExampleNotice,\n\tschemaTypeField,\n} from '@utils/descriptions';\nimport { convertJsonSchemaToZod, generateSchemaFromExample } from '@utils/schemaParsing';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport type { DynamicZodObject } from '../../../types/zod.types';\n\nconst jsonSchemaExampleField = buildJsonSchemaExampleField({\n\tshowExtraProps: { specifyInputSchema: [true] },\n});\n\nconst jsonSchemaExampleNotice = buildJsonSchemaExampleNotice({\n\tshowExtraProps: {\n\t\tspecifyInputSchema: [true],\n\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t},\n});\n\nconst jsonSchemaField = buildInputSchemaField({ showExtraProps: { specifyInputSchema: [true] } });\n\nfunction getTool(\n\tctx: ISupplyDataFunctions | IExecuteFunctions,\n\titemIndex: number,\n\tlog: boolean = true,\n) {\n\tconst node = ctx.getNode();\n\tconst workflowMode = ctx.getMode();\n\n\tconst runnersConfig = Container.get(TaskRunnersConfig);\n\tconst isJsRunnerEnabled = runnersConfig.enabled;\n\tconst isPyRunnerEnabled = runnersConfig.isNativePythonRunnerEnabled;\n\n\tconst { typeVersion } = node;\n\tconst name =\n\t\ttypeVersion <= 1.1\n\t\t\t? (ctx.getNodeParameter('name', itemIndex) as string)\n\t\t\t: nodeNameToToolName(node);\n\n\tconst description = ctx.getNodeParameter('description', itemIndex) as string;\n\n\tconst useSchema = ctx.getNodeParameter('specifyInputSchema', itemIndex) as boolean;\n\n\tconst language = ctx.getNodeParameter('language', itemIndex) as string;\n\tlet code = '';\n\tif (language === 'javaScript') {\n\t\tcode = ctx.getNodeParameter('jsCode', itemIndex) as string;\n\t} else {\n\t\tcode = ctx.getNodeParameter('pythonCode', itemIndex) as string;\n\t}\n\n\t// @deprecated - TODO: Remove this after a new python runner is implemented\n\tconst getSandbox = (query: string | IDataObject, index = 0) => {\n\t\tconst context = getSandboxContext.call(ctx, index);\n\t\tcontext.query = query;\n\n\t\tlet sandbox: Sandbox;\n\t\tif (language === 'javaScript') {\n\t\t\tsandbox = new JavaScriptSandbox(context, code, ctx.helpers);\n\t\t} else {\n\t\t\tsandbox = new PythonSandbox(context, code, ctx.helpers);\n\t\t}\n\n\t\tsandbox.on(\n\t\t\t'output',\n\t\t\tworkflowMode === 'manual'\n\t\t\t\t? ctx.sendMessageToUI.bind(ctx)\n\t\t\t\t: (...args: unknown[]) =>\n\t\t\t\t\t\tconsole.log(`[Workflow \"${ctx.getWorkflow().id}\"][Node \"${node.name}\"]`, ...args),\n\t\t);\n\t\treturn sandbox;\n\t};\n\n\tconst runFunction = async (query: string | IDataObject): Promise<unknown> => {\n\t\tif (language === 'javaScript' && isJsRunnerEnabled) {\n\t\t\tconst sandbox = new JsTaskRunnerSandbox(\n\t\t\t\tcode,\n\t\t\t\t'runOnceForAllItems',\n\t\t\t\tworkflowMode,\n\t\t\t\tctx,\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tquery,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn await sandbox.runCodeForTool();\n\t\t} else if (language === 'python' && isPyRunnerEnabled) {\n\t\t\tconst sandbox = new PythonTaskRunnerSandbox(\n\t\t\t\tcode,\n\t\t\t\t'runOnceForAllItems',\n\t\t\t\tworkflowMode,\n\t\t\t\tctx as IExecuteFunctions,\n\t\t\t\t{\n\t\t\t\t\tquery,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn await sandbox.runCodeForTool();\n\t\t} else {\n\t\t\t// use old vm2-based sandbox when runners disabled\n\t\t\tconst sandbox = getSandbox(query, itemIndex);\n\t\t\treturn await sandbox.runCode<string>();\n\t\t}\n\t};\n\n\tconst toolHandler = async (query: string | IDataObject): Promise<string> => {\n\t\tconst { index } = log\n\t\t\t? ctx.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]])\n\t\t\t: { index: 0 };\n\n\t\tlet response: any = '';\n\t\tlet executionError: ExecutionError | undefined;\n\t\ttry {\n\t\t\tresponse = await runFunction(query);\n\t\t} catch (error: unknown) {\n\t\t\texecutionError = new NodeOperationError(ctx.getNode(), error as ExecutionError);\n\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t}\n\n\t\tif (typeof response === 'number') {\n\t\t\tresponse = (response as number).toString();\n\t\t}\n\n\t\tif (typeof response !== 'string') {\n\t\t\t// TODO: Do some more testing. Issues here should actually fail the workflow\n\t\t\texecutionError = new NodeOperationError(ctx.getNode(), 'Wrong output type returned', {\n\t\t\t\tdescription: `The response property should be a string, but it is an ${typeof response}`,\n\t\t\t});\n\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t}\n\n\t\tif (executionError && log) {\n\t\t\tvoid ctx.addOutputData(NodeConnectionTypes.AiTool, index, executionError);\n\t\t} else if (log) {\n\t\t\tvoid ctx.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);\n\t\t}\n\n\t\treturn response;\n\t};\n\n\tconst commonToolOptions = {\n\t\tname,\n\t\tdescription,\n\t\tfunc: toolHandler,\n\t};\n\n\tlet tool: DynamicTool | DynamicStructuredTool | undefined = undefined;\n\n\tif (useSchema) {\n\t\ttry {\n\t\t\t// We initialize these even though one of them will always be empty\n\t\t\t// it makes it easier to navigate the ternary operator\n\t\t\tconst jsonExample = ctx.getNodeParameter('jsonSchemaExample', itemIndex, '') as string;\n\t\t\tconst inputSchema = ctx.getNodeParameter('inputSchema', itemIndex, '') as string;\n\n\t\t\tconst schemaType = ctx.getNodeParameter('schemaType', itemIndex) as 'fromJson' | 'manual';\n\n\t\t\tconst jsonSchema =\n\t\t\t\tschemaType === 'fromJson'\n\t\t\t\t\t? generateSchemaFromExample(jsonExample, ctx.getNode().typeVersion >= 1.3)\n\t\t\t\t\t: jsonParse<JSONSchema7>(inputSchema);\n\n\t\t\tconst zodSchema = convertJsonSchemaToZod<DynamicZodObject>(jsonSchema);\n\n\t\t\ttool = new DynamicStructuredTool({\n\t\t\t\tschema: zodSchema,\n\t\t\t\t...commonToolOptions,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t'Error during parsing of JSON Schema. \\n ' + error,\n\t\t\t);\n\t\t}\n\t} else {\n\t\ttool = new DynamicTool(commonToolOptions);\n\t}\n\n\treturn tool;\n}\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, 1.3],\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\n\t\tinputs: [],\n\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\tjsonSchemaExampleField,\n\t\t\tjsonSchemaExampleNotice,\n\t\t\tjsonSchemaField,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\treturn {\n\t\t\tresponse: getTool(this, itemIndex),\n\t\t};\n\t}\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst result: INodeExecutionData[] = [];\n\t\tconst input = this.getInputData();\n\t\tfor (let i = 0; i < input.length; i++) {\n\t\t\tconst item = input[i];\n\t\t\tconst tool = getTool(this, i, false);\n\t\t\tresult.push({\n\t\t\t\tjson: {\n\t\t\t\t\tresponse: await tool.invoke(item.json),\n\t\t\t\t},\n\t\t\t\tpairedItem: {\n\t\t\t\t\titem: i,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn [result];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmD;AACnD,oBAAkC;AAClC,gBAA0B;AAE1B,+BAAkC;AAClC,iCAAoC;AACpC,2BAA8B;AAC9B,qCAAwC;AAExC,qBAAkC;AAWlC,0BAKO;AAEP,0BAKO;AACP,2BAAkE;AAClE,0BAA6C;AAI7C,MAAM,6BAAyB,iDAA4B;AAAA,EAC1D,gBAAgB,EAAE,oBAAoB,CAAC,IAAI,EAAE;AAC9C,CAAC;AAED,MAAM,8BAA0B,kDAA6B;AAAA,EAC5D,gBAAgB;AAAA,IACf,oBAAoB,CAAC,IAAI;AAAA,IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;AAAA,EACpC;AACD,CAAC;AAED,MAAM,sBAAkB,2CAAsB,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC;AAEhG,SAAS,QACR,KACA,WACA,MAAe,MACd;AACD,QAAM,OAAO,IAAI,QAAQ;AACzB,QAAM,eAAe,IAAI,QAAQ;AAEjC,QAAM,gBAAgB,oBAAU,IAAI,+BAAiB;AACrD,QAAM,oBAAoB,cAAc;AACxC,QAAM,oBAAoB,cAAc;AAExC,QAAM,EAAE,YAAY,IAAI;AACxB,QAAM,OACL,eAAe,MACX,IAAI,iBAAiB,QAAQ,SAAS,QACvC,wCAAmB,IAAI;AAE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,SACC;AAAA;AAAA,UAED,MAAM;AAAA;AAAA,UAEN,aAAa;AAAA,UACb,kBAAkB;AAAA,QACnB;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,aACC;AAAA,UACD,kBAAkB;AAAA,UAClB,SAAS;AAAA,QACV;AAAA,QACA,EAAE,GAAG,qCAAiB,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE;AAAA,QAC/E;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,WAAO;AAAA,MACN,UAAU,QAAQ,MAAM,SAAS;AAAA,IAClC;AAAA,EACD;AAAA,EACA,MAAM,UAAkE;AACvE,UAAM,SAA+B,CAAC;AACtC,UAAM,QAAQ,KAAK,aAAa;AAChC,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,YAAM,OAAO,MAAM,CAAC;AACpB,YAAM,OAAO,QAAQ,MAAM,GAAG,KAAK;AACnC,aAAO,KAAK;AAAA,QACX,MAAM;AAAA,UACL,UAAU,MAAM,KAAK,OAAO,KAAK,IAAI;AAAA,QACtC;AAAA,QACA,YAAY;AAAA,UACX,MAAM;AAAA,QACP;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO,CAAC,MAAM;AAAA,EACf;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/tools/ToolCode/ToolCode.node.ts"],"sourcesContent":["import { DynamicStructuredTool, DynamicTool } from '@langchain/core/tools';\nimport { TaskRunnersConfig } from '@n8n/config';\nimport { Container } from '@n8n/di';\nimport type { JSONSchema7 } from 'json-schema';\nimport { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';\nimport { JsTaskRunnerSandbox } from 'n8n-nodes-base/dist/nodes/Code/JsTaskRunnerSandbox';\nimport { PythonTaskRunnerSandbox } from 'n8n-nodes-base/dist/nodes/Code/PythonTaskRunnerSandbox';\nimport { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport type {\n\tExecutionError,\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tISupplyDataFunctions,\n\tSupplyData,\n} from 'n8n-workflow';\nimport {\n\tjsonParse,\n\tNodeConnectionTypes,\n\tnodeNameToToolName,\n\tNodeOperationError,\n} from 'n8n-workflow';\n\nimport {\n\tbuildInputSchemaField,\n\tbuildJsonSchemaExampleField,\n\tbuildJsonSchemaExampleNotice,\n\tschemaTypeField,\n} from '@utils/descriptions';\nimport { convertJsonSchemaToZod, generateSchemaFromExample } from '@utils/schemaParsing';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport type { DynamicZodObject } from '../../../types/zod.types';\n\nconst jsonSchemaExampleField = buildJsonSchemaExampleField({\n\tshowExtraProps: { specifyInputSchema: [true] },\n});\n\nconst jsonSchemaExampleNotice = buildJsonSchemaExampleNotice({\n\tshowExtraProps: {\n\t\tspecifyInputSchema: [true],\n\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t},\n});\n\nconst jsonSchemaField = buildInputSchemaField({ showExtraProps: { specifyInputSchema: [true] } });\n\nfunction getTool(\n\tctx: ISupplyDataFunctions | IExecuteFunctions,\n\titemIndex: number,\n\tlog: boolean = true,\n) {\n\tconst node = ctx.getNode();\n\tconst workflowMode = ctx.getMode();\n\n\tconst runnersConfig = Container.get(TaskRunnersConfig);\n\tconst isJsRunnerEnabled = runnersConfig.enabled;\n\n\tconst { typeVersion } = node;\n\tconst name =\n\t\ttypeVersion <= 1.1\n\t\t\t? (ctx.getNodeParameter('name', itemIndex) as string)\n\t\t\t: nodeNameToToolName(node);\n\n\tconst description = ctx.getNodeParameter('description', itemIndex) as string;\n\n\tconst useSchema = ctx.getNodeParameter('specifyInputSchema', itemIndex) as boolean;\n\n\tconst language = ctx.getNodeParameter('language', itemIndex) as string;\n\tlet code = '';\n\tif (language === 'javaScript') {\n\t\tcode = ctx.getNodeParameter('jsCode', itemIndex) as string;\n\t} else {\n\t\tcode = ctx.getNodeParameter('pythonCode', itemIndex) as string;\n\t}\n\n\tconst runFunction = async (query: string | IDataObject): Promise<unknown> => {\n\t\tif (language === 'javaScript') {\n\t\t\tif (isJsRunnerEnabled) {\n\t\t\t\tconst sandbox = new JsTaskRunnerSandbox(\n\t\t\t\t\tcode,\n\t\t\t\t\t'runOnceForAllItems',\n\t\t\t\t\tworkflowMode,\n\t\t\t\t\tctx,\n\t\t\t\t\tundefined,\n\t\t\t\t\t{\n\t\t\t\t\t\tquery,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn await sandbox.runCodeForTool();\n\t\t\t} else {\n\t\t\t\tconst context = getSandboxContext.call(ctx, itemIndex);\n\t\t\t\tcontext.query = query;\n\t\t\t\tconst sandbox = new JavaScriptSandbox(context, code, ctx.helpers);\n\t\t\t\tsandbox.on(\n\t\t\t\t\t'output',\n\t\t\t\t\tworkflowMode === 'manual'\n\t\t\t\t\t\t? ctx.sendMessageToUI.bind(ctx)\n\t\t\t\t\t\t: (...args: unknown[]) =>\n\t\t\t\t\t\t\t\tconsole.log(`[Workflow \"${ctx.getWorkflow().id}\"][Node \"${node.name}\"]`, ...args),\n\t\t\t\t);\n\t\t\t\treturn await sandbox.runCode<string>();\n\t\t\t}\n\t\t} else {\n\t\t\tconst sandbox = new PythonTaskRunnerSandbox(\n\t\t\t\tcode,\n\t\t\t\t'runOnceForAllItems',\n\t\t\t\tworkflowMode,\n\t\t\t\tctx as IExecuteFunctions,\n\t\t\t\t{\n\t\t\t\t\tquery,\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn await sandbox.runCodeForTool();\n\t\t}\n\t};\n\n\tconst toolHandler = async (query: string | IDataObject): Promise<string> => {\n\t\tconst { index } = log\n\t\t\t? ctx.addInputData(NodeConnectionTypes.AiTool, [[{ json: { query } }]])\n\t\t\t: { index: 0 };\n\n\t\tlet response: any = '';\n\t\tlet executionError: ExecutionError | undefined;\n\t\ttry {\n\t\t\tresponse = await runFunction(query);\n\t\t} catch (error: unknown) {\n\t\t\texecutionError = new NodeOperationError(ctx.getNode(), error as ExecutionError);\n\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t}\n\n\t\tif (typeof response === 'number') {\n\t\t\tresponse = (response as number).toString();\n\t\t}\n\n\t\tif (typeof response !== 'string') {\n\t\t\t// TODO: Do some more testing. Issues here should actually fail the workflow\n\t\t\texecutionError = new NodeOperationError(ctx.getNode(), 'Wrong output type returned', {\n\t\t\t\tdescription: `The response property should be a string, but it is an ${typeof response}`,\n\t\t\t});\n\t\t\tresponse = `There was an error: \"${executionError.message}\"`;\n\t\t}\n\n\t\tif (executionError && log) {\n\t\t\tvoid ctx.addOutputData(NodeConnectionTypes.AiTool, index, executionError);\n\t\t} else if (log) {\n\t\t\tvoid ctx.addOutputData(NodeConnectionTypes.AiTool, index, [[{ json: { response } }]]);\n\t\t}\n\n\t\treturn response;\n\t};\n\n\tconst commonToolOptions = {\n\t\tname,\n\t\tdescription,\n\t\tfunc: toolHandler,\n\t};\n\n\tlet tool: DynamicTool | DynamicStructuredTool | undefined = undefined;\n\n\tif (useSchema) {\n\t\ttry {\n\t\t\t// We initialize these even though one of them will always be empty\n\t\t\t// it makes it easier to navigate the ternary operator\n\t\t\tconst jsonExample = ctx.getNodeParameter('jsonSchemaExample', itemIndex, '') as string;\n\t\t\tconst inputSchema = ctx.getNodeParameter('inputSchema', itemIndex, '') as string;\n\n\t\t\tconst schemaType = ctx.getNodeParameter('schemaType', itemIndex) as 'fromJson' | 'manual';\n\n\t\t\tconst jsonSchema =\n\t\t\t\tschemaType === 'fromJson'\n\t\t\t\t\t? generateSchemaFromExample(jsonExample, ctx.getNode().typeVersion >= 1.3)\n\t\t\t\t\t: jsonParse<JSONSchema7>(inputSchema);\n\n\t\t\tconst zodSchema = convertJsonSchemaToZod<DynamicZodObject>(jsonSchema);\n\n\t\t\ttool = new DynamicStructuredTool({\n\t\t\t\tschema: zodSchema,\n\t\t\t\t...commonToolOptions,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t'Error during parsing of JSON Schema. \\n ' + error,\n\t\t\t);\n\t\t}\n\t} else {\n\t\ttool = new DynamicTool(commonToolOptions);\n\t}\n\n\treturn tool;\n}\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, 1.3],\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\n\t\tinputs: [],\n\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\tjsonSchemaExampleField,\n\t\t\tjsonSchemaExampleNotice,\n\t\t\tjsonSchemaField,\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\treturn {\n\t\t\tresponse: getTool(this, itemIndex),\n\t\t};\n\t}\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst result: INodeExecutionData[] = [];\n\t\tconst input = this.getInputData();\n\t\tfor (let i = 0; i < input.length; i++) {\n\t\t\tconst item = input[i];\n\t\t\tconst tool = getTool(this, i, false);\n\t\t\tresult.push({\n\t\t\t\tjson: {\n\t\t\t\t\tresponse: await tool.invoke(item.json),\n\t\t\t\t},\n\t\t\t\tpairedItem: {\n\t\t\t\t\titem: i,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\treturn [result];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmD;AACnD,oBAAkC;AAClC,gBAA0B;AAE1B,+BAAkC;AAClC,iCAAoC;AACpC,qCAAwC;AACxC,qBAAkC;AAWlC,0BAKO;AAEP,0BAKO;AACP,2BAAkE;AAClE,0BAA6C;AAI7C,MAAM,6BAAyB,iDAA4B;AAAA,EAC1D,gBAAgB,EAAE,oBAAoB,CAAC,IAAI,EAAE;AAC9C,CAAC;AAED,MAAM,8BAA0B,kDAA6B;AAAA,EAC5D,gBAAgB;AAAA,IACf,oBAAoB,CAAC,IAAI;AAAA,IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;AAAA,EACpC;AACD,CAAC;AAED,MAAM,sBAAkB,2CAAsB,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC;AAEhG,SAAS,QACR,KACA,WACA,MAAe,MACd;AACD,QAAM,OAAO,IAAI,QAAQ;AACzB,QAAM,eAAe,IAAI,QAAQ;AAEjC,QAAM,gBAA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,UACb,kBAAkB;AAAA,QACnB;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,aACC;AAAA,UACD,kBAAkB;AAAA,UAClB,SAAS;AAAA,QACV;AAAA,QACA,EAAE,GAAG,qCAAiB,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE;AAAA,QAC/E;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,WAAO;AAAA,MACN,UAAU,QAAQ,MAAM,SAAS;AAAA,IAClC;AAAA,EACD;AAAA,EACA,MAAM,UAAkE;AACvE,UAAM,SAA+B,CAAC;AACtC,UAAM,QAAQ,KAAK,aAAa;AAChC,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,YAAM,OAAO,MAAM,CAAC;AACpB,YAAM,OAAO,QAAQ,MAAM,GAAG,KAAK;AACnC,aAAO,KAAK;AAAA,QACX,MAAM;AAAA,UACL,UAAU,MAAM,KAAK,OAAO,KAAK,IAAI;AAAA,QACtC;AAAA,QACA,YAAY;AAAA,UACX,MAAM;AAAA,QACP;AAAA,MACD,CAAC;AAAA,IACF;AAEA,WAAO,CAAC,MAAM;AAAA,EACf;AACD;","names":[]}
|
|
@@ -42,17 +42,7 @@ const cssVariables = `
|
|
|
42
42
|
--chat--spacing: 1rem;
|
|
43
43
|
--chat--border-radius: 0.25rem;
|
|
44
44
|
--chat--transition-duration: 0.15s;
|
|
45
|
-
--chat--font-family:
|
|
46
|
-
-apple-system,
|
|
47
|
-
BlinkMacSystemFont,
|
|
48
|
-
'Segoe UI',
|
|
49
|
-
Roboto,
|
|
50
|
-
Oxygen-Sans,
|
|
51
|
-
Ubuntu,
|
|
52
|
-
Cantarell,
|
|
53
|
-
'Helvetica Neue',
|
|
54
|
-
sans-serif
|
|
55
|
-
);
|
|
45
|
+
--chat--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
|
|
56
46
|
|
|
57
47
|
/* Window Dimensions */
|
|
58
48
|
--chat--window--width: 400px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/constants.ts"],"sourcesContent":["// CSS Variables are defined in `@n8n/chat/src/css/_tokens.scss`\nexport const cssVariables = `\n:root {\n /* Colors */\n --chat--color-primary: #e74266;\n --chat--color-primary-shade-50: #db4061;\n --chat--color-primary-shade-100: #cf3c5c;\n --chat--color-secondary: #20b69e;\n --chat--color-secondary-shade-50: #1ca08a;\n --chat--color-white: #ffffff;\n --chat--color-light: #f2f4f8;\n --chat--color-light-shade-50: #e6e9f1;\n --chat--color-light-shade-100: #c2c5cc;\n --chat--color-medium: #d2d4d9;\n --chat--color-dark: #101330;\n --chat--color-disabled: #d2d4d9;\n --chat--color-typing: #404040;\n\n /* Base Layout */\n --chat--spacing: 1rem;\n --chat--border-radius: 0.25rem;\n --chat--transition-duration: 0.15s;\n --chat--font-family:
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/constants.ts"],"sourcesContent":["// CSS Variables are defined in `@n8n/chat/src/css/_tokens.scss`\nexport const cssVariables = `\n:root {\n /* Colors */\n --chat--color-primary: #e74266;\n --chat--color-primary-shade-50: #db4061;\n --chat--color-primary-shade-100: #cf3c5c;\n --chat--color-secondary: #20b69e;\n --chat--color-secondary-shade-50: #1ca08a;\n --chat--color-white: #ffffff;\n --chat--color-light: #f2f4f8;\n --chat--color-light-shade-50: #e6e9f1;\n --chat--color-light-shade-100: #c2c5cc;\n --chat--color-medium: #d2d4d9;\n --chat--color-dark: #101330;\n --chat--color-disabled: #d2d4d9;\n --chat--color-typing: #404040;\n\n /* Base Layout */\n --chat--spacing: 1rem;\n --chat--border-radius: 0.25rem;\n --chat--transition-duration: 0.15s;\n --chat--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\n\n /* Window Dimensions */\n --chat--window--width: 400px;\n --chat--window--height: 600px;\n --chat--window--bottom: var(--chat--spacing);\n --chat--window--right: var(--chat--spacing);\n --chat--window--z-index: 9999;\n --chat--window--border: 1px solid var(--chat--color-light-shade-50);\n --chat--window--border-radius: var(--chat--border-radius);\n --chat--window--margin-bottom: var(--chat--spacing);\n\n /* Header Styles */\n --chat--header-height: auto;\n --chat--header--padding: var(--chat--spacing);\n --chat--header--background: var(--chat--color-dark);\n --chat--header--color: var(--chat--color-light);\n --chat--header--border-top: none;\n --chat--header--border-bottom: none;\n --chat--header--border-left: none;\n --chat--header--border-right: none;\n --chat--heading--font-size: 2em;\n --chat--subtitle--font-size: inherit;\n --chat--subtitle--line-height: 1.8;\n\n /* Message Styles */\n --chat--message--font-size: 1rem;\n --chat--message--padding: var(--chat--spacing);\n --chat--message--border-radius: var(--chat--border-radius);\n --chat--message-line-height: 1.5;\n --chat--message--margin-bottom: calc(var(--chat--spacing) * 1);\n --chat--message--bot--background: var(--chat--color-white);\n --chat--message--bot--color: var(--chat--color-dark);\n --chat--message--bot--border: none;\n --chat--message--user--background: var(--chat--color-secondary);\n --chat--message--user--color: var(--chat--color-white);\n --chat--message--user--border: none;\n --chat--message--pre--background: rgba(0, 0, 0, 0.05);\n --chat--messages-list--padding: var(--chat--spacing);\n\n /* Toggle Button */\n --chat--toggle--size: 64px;\n --chat--toggle--width: var(--chat--toggle--size);\n --chat--toggle--height: var(--chat--toggle--size);\n --chat--toggle--border-radius: 50%;\n --chat--toggle--background: var(--chat--color-primary);\n --chat--toggle--hover--background: var(--chat--color-primary-shade-50);\n --chat--toggle--active--background: var(--chat--color-primary-shade-100);\n --chat--toggle--color: var(--chat--color-white);\n\n /* Input Area */\n --chat--textarea--height: 50px;\n --chat--textarea--max-height: 30rem;\n --chat--input--font-size: inherit;\n --chat--input--border: 0;\n --chat--input--border-radius: 0;\n --chat--input--padding: 0.8rem;\n --chat--input--background: var(--chat--color-white);\n --chat--input--text-color: initial;\n --chat--input--line-height: 1.5;\n --chat--input--placeholder--font-size: var(--chat--input--font-size);\n --chat--input--border-active: 0;\n --chat--input--left--panel--width: 2rem;\n\n /* Button Styles */\n --chat--button--color: var(--chat--color-light);\n --chat--button--background: var(--chat--color-primary);\n --chat--button--padding: calc(var(--chat--spacing) * 1 / 2) var(--chat--spacing);\n --chat--button--border-radius: var(--chat--border-radius);\n --chat--button--hover--color: var(--chat--color-light);\n --chat--button--hover--background: var(--chat--color-primary-shade-50);\n --chat--close--button--color-hover: var(--chat--color-primary);\n\n /* Send and File Buttons */\n --chat--input--send--button--background: var(--chat--color-white);\n --chat--input--send--button--color: var(--chat--color-secondary);\n --chat--input--send--button--background-hover: var(--chat--color-primary-shade-50);\n --chat--input--send--button--color-hover: var(--chat--color-secondary-shade-50);\n --chat--input--file--button--background: var(--chat--color-white);\n --chat--input--file--button--color: var(--chat--color-secondary);\n --chat--input--file--button--background-hover: var(--chat--input--file--button--background);\n --chat--input--file--button--color-hover: var(--chat--color-secondary-shade-50);\n --chat--files-spacing: 0.25rem;\n\n /* Body and Footer */\n --chat--body--background: var(--chat--color-light);\n --chat--footer--background: var(--chat--color-light);\n --chat--footer--color: var(--chat--color-dark);\n}\n`;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
|
@@ -21,26 +21,64 @@ __export(VectorStoreWeaviate_node_exports, {
|
|
|
21
21
|
VectorStoreWeaviate: () => VectorStoreWeaviate
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(VectorStoreWeaviate_node_exports);
|
|
24
|
+
var import_documents = require("@langchain/core/documents");
|
|
24
25
|
var import_weaviate = require("@langchain/weaviate");
|
|
26
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
25
27
|
var import_Weaviate = require("./Weaviate.utils");
|
|
26
28
|
var import_createVectorStoreNode = require("../shared/createVectorStoreNode/createVectorStoreNode");
|
|
27
29
|
var import_listSearch = require("../shared/createVectorStoreNode/methods/listSearch");
|
|
28
30
|
var import_descriptions = require("../shared/descriptions");
|
|
29
31
|
class ExtendedWeaviateVectorStore extends import_weaviate.WeaviateStore {
|
|
30
32
|
static async fromExistingCollection(embeddings, args, defaultFilter) {
|
|
33
|
+
const ctor = this;
|
|
34
|
+
const baseCandidate = await ctor.fromExistingIndex(embeddings, args);
|
|
35
|
+
if (!(baseCandidate instanceof ExtendedWeaviateVectorStore)) {
|
|
36
|
+
throw new import_n8n_workflow.ApplicationError(
|
|
37
|
+
"Weaviate store factory did not return an ExtendedWeaviateVectorStore instance"
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const base = baseCandidate;
|
|
41
|
+
base.args = args;
|
|
31
42
|
if (defaultFilter) {
|
|
32
|
-
|
|
43
|
+
base.defaultFilter = defaultFilter;
|
|
33
44
|
}
|
|
34
|
-
return
|
|
45
|
+
return base;
|
|
35
46
|
}
|
|
36
47
|
async similaritySearchVectorWithScore(query, k, filter) {
|
|
37
|
-
filter = filter ??
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
filter = filter ?? this.defaultFilter;
|
|
49
|
+
const args = this.args;
|
|
50
|
+
if (args.hybridQuery) {
|
|
51
|
+
const options = {
|
|
52
|
+
limit: k ?? void 0,
|
|
53
|
+
autoLimit: args.autoCutLimit ?? void 0,
|
|
54
|
+
alpha: args.alpha ?? void 0,
|
|
55
|
+
vector: query,
|
|
56
|
+
filter: filter ? (0, import_Weaviate.parseCompositeFilter)(filter) : void 0,
|
|
57
|
+
queryProperties: args.queryProperties ? args.queryProperties.split(",").map((prop) => prop.trim()) : void 0,
|
|
58
|
+
maxVectorDistance: args.maxVectorDistance ?? void 0,
|
|
59
|
+
fusionType: args.fusionType,
|
|
60
|
+
returnMetadata: args.hybridExplainScore ? ["explainScore"] : void 0
|
|
61
|
+
};
|
|
62
|
+
const content = await super.hybridSearch(args.hybridQuery, options);
|
|
63
|
+
return content.map((doc) => {
|
|
64
|
+
const { score, ...metadata } = doc.metadata;
|
|
65
|
+
if (typeof score !== "number") {
|
|
66
|
+
throw new import_n8n_workflow.ApplicationError(`Unexpected score type: ${typeof score}`);
|
|
67
|
+
}
|
|
68
|
+
return [
|
|
69
|
+
new import_documents.Document({
|
|
70
|
+
pageContent: doc.pageContent,
|
|
71
|
+
metadata
|
|
72
|
+
}),
|
|
73
|
+
score
|
|
74
|
+
];
|
|
75
|
+
});
|
|
43
76
|
}
|
|
77
|
+
return await super.similaritySearchVectorWithScore(
|
|
78
|
+
query,
|
|
79
|
+
k,
|
|
80
|
+
filter ? (0, import_Weaviate.parseCompositeFilter)(filter) : void 0
|
|
81
|
+
);
|
|
44
82
|
}
|
|
45
83
|
}
|
|
46
84
|
const sharedFields = [import_descriptions.weaviateCollectionRLC];
|
|
@@ -148,6 +186,71 @@ const retrieveFields = [
|
|
|
148
186
|
validateType: "string",
|
|
149
187
|
description: "Select the metadata to retrieve along the content"
|
|
150
188
|
},
|
|
189
|
+
{
|
|
190
|
+
displayName: "Hybrid: Query Text",
|
|
191
|
+
name: "hybridQuery",
|
|
192
|
+
type: "string",
|
|
193
|
+
default: "",
|
|
194
|
+
validateType: "string",
|
|
195
|
+
description: "Provide a query text to combine vector search with a keyword/text search"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
displayName: "Hybrid: Explain Score",
|
|
199
|
+
name: "hybridExplainScore",
|
|
200
|
+
type: "boolean",
|
|
201
|
+
default: false,
|
|
202
|
+
validateType: "boolean",
|
|
203
|
+
description: "Whether to show the score fused between hybrid and vector search explanation"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
displayName: "Hybrid: Fusion Type",
|
|
207
|
+
name: "fusionType",
|
|
208
|
+
type: "options",
|
|
209
|
+
options: [
|
|
210
|
+
{
|
|
211
|
+
name: "Relative Score",
|
|
212
|
+
value: "RelativeScore"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "Ranked",
|
|
216
|
+
value: "Ranked"
|
|
217
|
+
}
|
|
218
|
+
],
|
|
219
|
+
default: "RelativeScore",
|
|
220
|
+
description: "Select the fusion type for combining vector and keyword search results"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
displayName: "Hybrid: Auto Cut Limit",
|
|
224
|
+
name: "autoCutLimit",
|
|
225
|
+
type: "number",
|
|
226
|
+
default: void 0,
|
|
227
|
+
validateType: "number",
|
|
228
|
+
description: "Limit result groups by detecting sudden jumps in score"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
displayName: "Hybrid: Alpha",
|
|
232
|
+
name: "alpha",
|
|
233
|
+
type: "number",
|
|
234
|
+
default: 0.5,
|
|
235
|
+
validateType: "number",
|
|
236
|
+
description: "Change the relative weights of the keyword and vector components. 1.0 = pure vector, 0.0 = pure keyword."
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
displayName: "Hybrid: Query Properties",
|
|
240
|
+
name: "queryProperties",
|
|
241
|
+
type: "string",
|
|
242
|
+
default: "",
|
|
243
|
+
validateType: "string",
|
|
244
|
+
description: 'Comma-separated list of properties to include in the query with optionally weighted values, e.g., "question^2,answer"'
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
displayName: "Hybrid: Max Vector Distance",
|
|
248
|
+
name: "maxVectorDistance",
|
|
249
|
+
type: "number",
|
|
250
|
+
default: void 0,
|
|
251
|
+
validateType: "number",
|
|
252
|
+
description: "Set the maximum allowable distance for the vector search component"
|
|
253
|
+
},
|
|
151
254
|
...shared_options
|
|
152
255
|
]
|
|
153
256
|
}
|
|
@@ -197,9 +300,16 @@ class VectorStoreWeaviate extends (0, import_createVectorStoreNode.createVectorS
|
|
|
197
300
|
const config = {
|
|
198
301
|
client,
|
|
199
302
|
indexName: collection,
|
|
200
|
-
tenant: options.tenant
|
|
303
|
+
tenant: options.tenant ?? void 0,
|
|
201
304
|
textKey: options.textKey ? options.textKey : "text",
|
|
202
|
-
metadataKeys
|
|
305
|
+
metadataKeys,
|
|
306
|
+
hybridQuery: options.hybridQuery ?? void 0,
|
|
307
|
+
autoCutLimit: options.autoCutLimit ?? void 0,
|
|
308
|
+
alpha: options.alpha ?? void 0,
|
|
309
|
+
queryProperties: options.queryProperties,
|
|
310
|
+
maxVectorDistance: options.maxVectorDistance,
|
|
311
|
+
fusionType: options.fusionType,
|
|
312
|
+
hybridExplainScore: options.hybridExplainScore ?? false
|
|
203
313
|
};
|
|
204
314
|
const validFilter = filter && Object.keys(filter).length > 0 ? filter : void 0;
|
|
205
315
|
return await ExtendedWeaviateVectorStore.fromExistingCollection(
|
|
@@ -219,7 +329,7 @@ class VectorStoreWeaviate extends (0, import_createVectorStoreNode.createVectorS
|
|
|
219
329
|
const config = {
|
|
220
330
|
client,
|
|
221
331
|
indexName: collectionName,
|
|
222
|
-
tenant: options.tenant
|
|
332
|
+
tenant: options.tenant ?? void 0,
|
|
223
333
|
textKey: options.textKey ? options.textKey : "text",
|
|
224
334
|
metadataKeys
|
|
225
335
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport { WeaviateStore } from '@langchain/weaviate';\nimport type { WeaviateLibArgs } from '@langchain/weaviate';\nimport type {\n\tIDataObject,\n\tINodeProperties,\n\tINodePropertyCollection,\n\tINodePropertyOptions,\n} from 'n8n-workflow';\nimport { type ProxiesParams, type TimeoutParams } from 'weaviate-client';\n\nimport type { WeaviateCompositeFilter, WeaviateCredential } from './Weaviate.utils';\nimport { createWeaviateClient, parseCompositeFilter } from './Weaviate.utils';\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\nimport { weaviateCollectionsSearch } from '../shared/createVectorStoreNode/methods/listSearch';\nimport { weaviateCollectionRLC } from '../shared/descriptions';\n\nclass ExtendedWeaviateVectorStore extends WeaviateStore {\n\tprivate static defaultFilter: WeaviateCompositeFilter;\n\n\tstatic async fromExistingCollection(\n\t\tembeddings: Embeddings,\n\t\targs: WeaviateLibArgs,\n\t\tdefaultFilter?: WeaviateCompositeFilter,\n\t): Promise<WeaviateStore> {\n\t\tif (defaultFilter) {\n\t\t\tExtendedWeaviateVectorStore.defaultFilter = defaultFilter;\n\t\t}\n\t\treturn await super.fromExistingIndex(embeddings, args);\n\t}\n\n\tasync similaritySearchVectorWithScore(query: number[], k: number, filter?: IDataObject) {\n\t\tfilter = filter ?? ExtendedWeaviateVectorStore.defaultFilter;\n\t\tif (filter) {\n\t\t\tconst composedFilter = parseCompositeFilter(filter as WeaviateCompositeFilter);\n\t\t\treturn await super.similaritySearchVectorWithScore(query, k, composedFilter);\n\t\t} else {\n\t\t\treturn await super.similaritySearchVectorWithScore(query, k, undefined);\n\t\t}\n\t}\n}\n\nconst sharedFields: INodeProperties[] = [weaviateCollectionRLC];\n\nconst shared_options: Array<INodePropertyOptions | INodeProperties | INodePropertyCollection> = [\n\t{\n\t\tdisplayName: 'Tenant Name',\n\t\tname: 'tenant',\n\t\ttype: 'string',\n\t\tdefault: undefined,\n\t\tvalidateType: 'string',\n\t\tdescription: 'Tenant Name. Collection must have been created with tenant support enabled.',\n\t},\n\t{\n\t\tdisplayName: 'Text Key',\n\t\tname: 'textKey',\n\t\ttype: 'string',\n\t\tdefault: 'text',\n\t\tvalidateType: 'string',\n\t\tdescription: 'The key in the document that contains the embedded text',\n\t},\n\t{\n\t\tdisplayName: 'Skip Init Checks',\n\t\tname: 'skip_init_checks',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tvalidateType: 'boolean',\n\t\tdescription: 'Whether to skip init checks while instantiating the client',\n\t},\n\t{\n\t\tdisplayName: 'Init Timeout',\n\t\tname: 'timeout_init',\n\t\ttype: 'number',\n\t\tdefault: 2,\n\t\tvalidateType: 'number',\n\t\tdescription: 'Number of timeout seconds for initial checks',\n\t},\n\t{\n\t\tdisplayName: 'Insert Timeout',\n\t\tname: 'timeout_insert',\n\t\ttype: 'number',\n\t\tdefault: 90,\n\t\tvalidateType: 'number',\n\t\tdescription: 'Number of timeout seconds for inserts',\n\t},\n\t{\n\t\tdisplayName: 'Query Timeout',\n\t\tname: 'timeout_query',\n\t\ttype: 'number',\n\t\tdefault: 30,\n\t\tvalidateType: 'number',\n\t\tdescription: 'Number of timeout seconds for queries',\n\t},\n\t{\n\t\tdisplayName: 'GRPC Proxy',\n\t\tname: 'proxy_grpc',\n\t\ttype: 'string',\n\t\tdefault: undefined,\n\t\tvalidateType: 'string',\n\t\tdescription: 'Proxy to use for GRPC',\n\t},\n];\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t...shared_options,\n\t\t\t{\n\t\t\t\tdisplayName: 'Clear Data',\n\t\t\t\tname: 'clearStore',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to clear the Collection/Tenant before inserting new data',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Search Filters',\n\t\t\t\tname: 'searchFilterJson',\n\t\t\t\ttype: 'json',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 5,\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'{\\n \"OR\": [\\n {\\n \"path\": [\"pdf_info_Author\"],\\n \"operator\": \"Equal\",\\n \"valueString\": \"Elis\"\\n },\\n {\\n \"path\": [\"pdf_info_Author\"],\\n \"operator\": \"Equal\",\\n \"valueString\": \"Pinnacle\"\\n } \\n ]\\n}',\n\t\t\t\tvalidateType: 'object',\n\t\t\t\tdescription:\n\t\t\t\t\t'Filter pageContent or metadata using this <a href=\"https://weaviate.io/\" target=\"_blank\">filtering syntax</a>',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Metadata Keys',\n\t\t\t\tname: 'metadataKeys',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'source,page',\n\t\t\t\tvalidateType: 'string',\n\t\t\t\tdescription: 'Select the metadata to retrieve along the content',\n\t\t\t},\n\t\t\t...shared_options,\n\t\t],\n\t},\n];\n\nexport class VectorStoreWeaviate extends createVectorStoreNode<ExtendedWeaviateVectorStore>({\n\tmeta: {\n\t\tdisplayName: 'Weaviate Vector Store',\n\t\tname: 'vectorStoreWeaviate',\n\t\tdescription: 'Work with your data in a Weaviate Cluster',\n\t\ticon: 'file:weaviate.svg',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreweaviate/',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'weaviateApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t},\n\tmethods: {\n\t\tlistSearch: { weaviateCollectionsSearch },\n\t},\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\tretrieveFields,\n\tasync getVectorStoreClient(context, filter, embeddings, itemIndex) {\n\t\tconst collection = context.getNodeParameter('weaviateCollection', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\n\t\tconst options = context.getNodeParameter('options', itemIndex, {}) as {\n\t\t\ttenant?: string;\n\t\t\ttextKey?: string;\n\t\t\ttimeout_init: number;\n\t\t\ttimeout_insert: number;\n\t\t\ttimeout_query: number;\n\t\t\tskip_init_checks: boolean;\n\t\t\tproxy_grpc: string;\n\t\t\tmetadataKeys?: string;\n\t\t};\n\t\t// check if textKey is valid\n\n\t\tconst credentials = await context.getCredentials('weaviateApi');\n\n\t\tconst timeout = {\n\t\t\tquery: options.timeout_query,\n\t\t\tinit: options.timeout_init,\n\t\t\tinsert: options.timeout_insert,\n\t\t};\n\n\t\tconst proxies = {\n\t\t\tgrpc: options.proxy_grpc,\n\t\t};\n\n\t\tconst client = await createWeaviateClient(\n\t\t\tcredentials as WeaviateCredential,\n\t\t\ttimeout as TimeoutParams,\n\t\t\tproxies as ProxiesParams,\n\t\t\toptions.skip_init_checks as boolean,\n\t\t);\n\n\t\tconst metadataKeys = options.metadataKeys ? options.metadataKeys.split(',') : [];\n\t\tconst config: WeaviateLibArgs = {\n\t\t\tclient,\n\t\t\tindexName: collection,\n\t\t\ttenant: options.tenant ? options.tenant : undefined,\n\t\t\ttextKey: options.textKey ? options.textKey : 'text',\n\t\t\tmetadataKeys: metadataKeys as string[] | undefined,\n\t\t};\n\n\t\tconst validFilter = (filter && Object.keys(filter).length > 0 ? filter : undefined) as\n\t\t\t| WeaviateCompositeFilter\n\t\t\t| undefined;\n\t\treturn await ExtendedWeaviateVectorStore.fromExistingCollection(\n\t\t\tembeddings,\n\t\t\tconfig,\n\t\t\tvalidFilter,\n\t\t);\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\tconst collectionName = context.getNodeParameter('weaviateCollection', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\n\t\tconst options = context.getNodeParameter('options', itemIndex, {}) as {\n\t\t\ttenant?: string;\n\t\t\ttextKey?: string;\n\t\t\tclearStore?: boolean;\n\t\t\tmetadataKeys?: string;\n\t\t};\n\n\t\tconst credentials = await context.getCredentials('weaviateApi');\n\n\t\tconst metadataKeys = options.metadataKeys ? options.metadataKeys.split(',') : [];\n\n\t\tconst client = await createWeaviateClient(credentials as WeaviateCredential);\n\n\t\tconst config: WeaviateLibArgs = {\n\t\t\tclient,\n\t\t\tindexName: collectionName,\n\t\t\ttenant: options.tenant ? options.tenant : undefined,\n\t\t\ttextKey: options.textKey ? options.textKey : 'text',\n\t\t\tmetadataKeys: metadataKeys as string[] | undefined,\n\t\t};\n\n\t\tif (options.clearStore) {\n\t\t\tif (!options.tenant) {\n\t\t\t\tawait client.collections.delete(collectionName);\n\t\t\t} else {\n\t\t\t\tconst collection = client.collections.get(collectionName);\n\t\t\t\tawait collection.tenants.remove([{ name: options.tenant }]);\n\t\t\t}\n\t\t}\n\n\t\tawait WeaviateStore.fromDocuments(documents, embeddings, config);\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAA8B;AAW9B,sBAA2D;AAC3D,mCAAsC;AACtC,wBAA0C;AAC1C,0BAAsC;AAEtC,MAAM,oCAAoC,8BAAc;AAAA,EAGvD,aAAa,uBACZ,YACA,MACA,eACyB;AACzB,QAAI,eAAe;AAClB,kCAA4B,gBAAgB;AAAA,IAC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UAAU,QAAQ,UAAU;AAAA,MAC7C;AAAA,IACD;AAEA,QAAI,QAAQ,YAAY;AACvB,UAAI,CAAC,QAAQ,QAAQ;AACpB,cAAM,OAAO,YAAY,OAAO,cAAc;AAAA,MAC/C,OAAO;AACN,cAAM,aAAa,OAAO,YAAY,IAAI,cAAc;AACxD,cAAM,WAAW,QAAQ,OAAO,CAAC,EAAE,MAAM,QAAQ,OAAO,CAAC,CAAC;AAAA,MAC3D;AAAA,IACD;AAEA,UAAM,8BAAc,cAAc,WAAW,YAAY,MAAM;AAAA,EAChE;AACD,CAAC,EAAE;AAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.ts"],"sourcesContent":["import { Document } from '@langchain/core/documents';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport type { WeaviateLibArgs as OriginalWeaviateLibArgs } from '@langchain/weaviate';\nimport { WeaviateStore } from '@langchain/weaviate';\nimport {\n\tApplicationError,\n\ttype IDataObject,\n\ttype INodeProperties,\n\ttype INodePropertyCollection,\n\ttype INodePropertyOptions,\n} from 'n8n-workflow';\nimport { type ProxiesParams, type TimeoutParams } from 'weaviate-client';\n\nimport type { WeaviateCompositeFilter, WeaviateCredential } from './Weaviate.utils';\nimport { createWeaviateClient, parseCompositeFilter } from './Weaviate.utils';\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\nimport { weaviateCollectionsSearch } from '../shared/createVectorStoreNode/methods/listSearch';\nimport { weaviateCollectionRLC } from '../shared/descriptions';\n\ntype WeaviateLibArgs = OriginalWeaviateLibArgs & {\n\thybridQuery?: string;\n\tautoCutLimit?: number;\n\talpha?: number;\n\tqueryProperties?: string;\n\tmaxVectorDistance?: number;\n\tfusionType?: 'Ranked' | 'RelativeScore';\n\thybridExplainScore?: boolean;\n};\n\nclass ExtendedWeaviateVectorStore extends WeaviateStore {\n\tprivate defaultFilter?: WeaviateCompositeFilter;\n\tprivate args!: WeaviateLibArgs;\n\n\tstatic async fromExistingCollection(\n\t\tembeddings: Embeddings,\n\t\targs: WeaviateLibArgs,\n\t\tdefaultFilter?: WeaviateCompositeFilter,\n\t): Promise<ExtendedWeaviateVectorStore> {\n\t\t// Call parent factory method but bound to this (subclass) so the created instance is of the subclass\n\t\tconst ctor = this as unknown as typeof ExtendedWeaviateVectorStore & typeof WeaviateStore;\n\t\tconst baseCandidate = await ctor.fromExistingIndex(embeddings, args);\n\n\t\tif (!(baseCandidate instanceof ExtendedWeaviateVectorStore)) {\n\t\t\tthrow new ApplicationError(\n\t\t\t\t'Weaviate store factory did not return an ExtendedWeaviateVectorStore instance',\n\t\t\t);\n\t\t}\n\n\t\tconst base = baseCandidate;\n\n\t\t// Attach per-instance config\n\t\tbase.args = args;\n\t\tif (defaultFilter) {\n\t\t\tbase.defaultFilter = defaultFilter;\n\t\t}\n\n\t\treturn base;\n\t}\n\n\tasync similaritySearchVectorWithScore(query: number[], k: number, filter?: IDataObject) {\n\t\tfilter = filter ?? this.defaultFilter;\n\t\tconst args = this.args;\n\n\t\tif (args.hybridQuery) {\n\t\t\tconst options = {\n\t\t\t\tlimit: k ?? undefined,\n\t\t\t\tautoLimit: args.autoCutLimit ?? undefined,\n\t\t\t\talpha: args.alpha ?? undefined,\n\t\t\t\tvector: query,\n\t\t\t\tfilter: filter ? parseCompositeFilter(filter as WeaviateCompositeFilter) : undefined,\n\t\t\t\tqueryProperties: args.queryProperties\n\t\t\t\t\t? args.queryProperties.split(',').map((prop) => prop.trim())\n\t\t\t\t\t: undefined,\n\t\t\t\tmaxVectorDistance: args.maxVectorDistance ?? undefined,\n\t\t\t\tfusionType: args.fusionType,\n\t\t\t\treturnMetadata: args.hybridExplainScore ? ['explainScore'] : undefined,\n\t\t\t};\n\t\t\tconst content = await super.hybridSearch(args.hybridQuery, options);\n\t\t\treturn content.map((doc) => {\n\t\t\t\tconst { score, ...metadata } = doc.metadata;\n\t\t\t\tif (typeof score !== 'number') {\n\t\t\t\t\tthrow new ApplicationError(`Unexpected score type: ${typeof score}`);\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tnew Document({\n\t\t\t\t\t\tpageContent: doc.pageContent,\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t}),\n\t\t\t\t\tscore,\n\t\t\t\t] as [Document, number];\n\t\t\t});\n\t\t}\n\t\treturn await super.similaritySearchVectorWithScore(\n\t\t\tquery,\n\t\t\tk,\n\t\t\tfilter ? parseCompositeFilter(filter as WeaviateCompositeFilter) : undefined,\n\t\t);\n\t}\n}\n\nconst sharedFields: INodeProperties[] = [weaviateCollectionRLC];\n\nconst shared_options: Array<INodePropertyOptions | INodeProperties | INodePropertyCollection> = [\n\t{\n\t\tdisplayName: 'Tenant Name',\n\t\tname: 'tenant',\n\t\ttype: 'string',\n\t\tdefault: undefined,\n\t\tvalidateType: 'string',\n\t\tdescription: 'Tenant Name. Collection must have been created with tenant support enabled.',\n\t},\n\t{\n\t\tdisplayName: 'Text Key',\n\t\tname: 'textKey',\n\t\ttype: 'string',\n\t\tdefault: 'text',\n\t\tvalidateType: 'string',\n\t\tdescription: 'The key in the document that contains the embedded text',\n\t},\n\t{\n\t\tdisplayName: 'Skip Init Checks',\n\t\tname: 'skip_init_checks',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tvalidateType: 'boolean',\n\t\tdescription: 'Whether to skip init checks while instantiating the client',\n\t},\n\t{\n\t\tdisplayName: 'Init Timeout',\n\t\tname: 'timeout_init',\n\t\ttype: 'number',\n\t\tdefault: 2,\n\t\tvalidateType: 'number',\n\t\tdescription: 'Number of timeout seconds for initial checks',\n\t},\n\t{\n\t\tdisplayName: 'Insert Timeout',\n\t\tname: 'timeout_insert',\n\t\ttype: 'number',\n\t\tdefault: 90,\n\t\tvalidateType: 'number',\n\t\tdescription: 'Number of timeout seconds for inserts',\n\t},\n\t{\n\t\tdisplayName: 'Query Timeout',\n\t\tname: 'timeout_query',\n\t\ttype: 'number',\n\t\tdefault: 30,\n\t\tvalidateType: 'number',\n\t\tdescription: 'Number of timeout seconds for queries',\n\t},\n\t{\n\t\tdisplayName: 'GRPC Proxy',\n\t\tname: 'proxy_grpc',\n\t\ttype: 'string',\n\t\tdefault: undefined,\n\t\tvalidateType: 'string',\n\t\tdescription: 'Proxy to use for GRPC',\n\t},\n];\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t...shared_options,\n\t\t\t{\n\t\t\t\tdisplayName: 'Clear Data',\n\t\t\t\tname: 'clearStore',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to clear the Collection/Tenant before inserting new data',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Search Filters',\n\t\t\t\tname: 'searchFilterJson',\n\t\t\t\ttype: 'json',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 5,\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'{\\n \"OR\": [\\n {\\n \"path\": [\"pdf_info_Author\"],\\n \"operator\": \"Equal\",\\n \"valueString\": \"Elis\"\\n },\\n {\\n \"path\": [\"pdf_info_Author\"],\\n \"operator\": \"Equal\",\\n \"valueString\": \"Pinnacle\"\\n } \\n ]\\n}',\n\t\t\t\tvalidateType: 'object',\n\t\t\t\tdescription:\n\t\t\t\t\t'Filter pageContent or metadata using this <a href=\"https://weaviate.io/\" target=\"_blank\">filtering syntax</a>',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Metadata Keys',\n\t\t\t\tname: 'metadataKeys',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'source,page',\n\t\t\t\tvalidateType: 'string',\n\t\t\t\tdescription: 'Select the metadata to retrieve along the content',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Hybrid: Query Text',\n\t\t\t\tname: 'hybridQuery',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tvalidateType: 'string',\n\t\t\t\tdescription: 'Provide a query text to combine vector search with a keyword/text search',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Hybrid: Explain Score',\n\t\t\t\tname: 'hybridExplainScore',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tvalidateType: 'boolean',\n\t\t\t\tdescription: 'Whether to show the score fused between hybrid and vector search explanation',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Hybrid: Fusion Type',\n\t\t\t\tname: 'fusionType',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Relative Score',\n\t\t\t\t\t\tvalue: 'RelativeScore',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Ranked',\n\t\t\t\t\t\tvalue: 'Ranked',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'RelativeScore',\n\t\t\t\tdescription: 'Select the fusion type for combining vector and keyword search results',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Hybrid: Auto Cut Limit',\n\t\t\t\tname: 'autoCutLimit',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: undefined,\n\t\t\t\tvalidateType: 'number',\n\t\t\t\tdescription: 'Limit result groups by detecting sudden jumps in score',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Hybrid: Alpha',\n\t\t\t\tname: 'alpha',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 0.5,\n\t\t\t\tvalidateType: 'number',\n\t\t\t\tdescription:\n\t\t\t\t\t'Change the relative weights of the keyword and vector components. 1.0 = pure vector, 0.0 = pure keyword.',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Hybrid: Query Properties',\n\t\t\t\tname: 'queryProperties',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: '',\n\t\t\t\tvalidateType: 'string',\n\t\t\t\tdescription:\n\t\t\t\t\t'Comma-separated list of properties to include in the query with optionally weighted values, e.g., \"question^2,answer\"',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Hybrid: Max Vector Distance',\n\t\t\t\tname: 'maxVectorDistance',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: undefined,\n\t\t\t\tvalidateType: 'number',\n\t\t\t\tdescription: 'Set the maximum allowable distance for the vector search component',\n\t\t\t},\n\t\t\t...shared_options,\n\t\t],\n\t},\n];\n\nexport class VectorStoreWeaviate extends createVectorStoreNode<ExtendedWeaviateVectorStore>({\n\tmeta: {\n\t\tdisplayName: 'Weaviate Vector Store',\n\t\tname: 'vectorStoreWeaviate',\n\t\tdescription: 'Work with your data in a Weaviate Cluster',\n\t\ticon: 'file:weaviate.svg',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreweaviate/',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'weaviateApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t},\n\tmethods: {\n\t\tlistSearch: { weaviateCollectionsSearch },\n\t},\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\tretrieveFields,\n\tasync getVectorStoreClient(context, filter, embeddings, itemIndex) {\n\t\tconst collection = context.getNodeParameter('weaviateCollection', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\n\t\tconst options = context.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tqueryProperties: string;\n\t\t\tmaxVectorDistance: number;\n\t\t\tfusionType: 'Ranked' | 'RelativeScore';\n\t\t\talpha?: number;\n\t\t\tautoCutLimit?: number;\n\t\t\thybridQuery?: string;\n\t\t\ttenant?: string;\n\t\t\ttextKey?: string;\n\t\t\ttimeout_init: number;\n\t\t\ttimeout_insert: number;\n\t\t\ttimeout_query: number;\n\t\t\tskip_init_checks: boolean;\n\t\t\tproxy_grpc: string;\n\t\t\tmetadataKeys?: string;\n\t\t\thybridExplainScore?: boolean;\n\t\t};\n\t\t// check if textKey is valid\n\n\t\tconst credentials = await context.getCredentials('weaviateApi');\n\n\t\tconst timeout = {\n\t\t\tquery: options.timeout_query,\n\t\t\tinit: options.timeout_init,\n\t\t\tinsert: options.timeout_insert,\n\t\t};\n\n\t\tconst proxies = {\n\t\t\tgrpc: options.proxy_grpc,\n\t\t};\n\n\t\tconst client = await createWeaviateClient(\n\t\t\tcredentials as WeaviateCredential,\n\t\t\ttimeout as TimeoutParams,\n\t\t\tproxies as ProxiesParams,\n\t\t\toptions.skip_init_checks,\n\t\t);\n\n\t\tconst metadataKeys = options.metadataKeys ? options.metadataKeys.split(',') : [];\n\t\tconst config: WeaviateLibArgs = {\n\t\t\tclient,\n\t\t\tindexName: collection,\n\t\t\ttenant: options.tenant ?? undefined,\n\t\t\ttextKey: options.textKey ? options.textKey : 'text',\n\t\t\tmetadataKeys: metadataKeys as string[] | undefined,\n\t\t\thybridQuery: options.hybridQuery ?? undefined,\n\t\t\tautoCutLimit: options.autoCutLimit ?? undefined,\n\t\t\talpha: options.alpha ?? undefined,\n\t\t\tqueryProperties: options.queryProperties,\n\t\t\tmaxVectorDistance: options.maxVectorDistance,\n\t\t\tfusionType: options.fusionType,\n\t\t\thybridExplainScore: options.hybridExplainScore ?? false,\n\t\t};\n\n\t\tconst validFilter = (filter && Object.keys(filter).length > 0 ? filter : undefined) as\n\t\t\t| WeaviateCompositeFilter\n\t\t\t| undefined;\n\t\treturn await ExtendedWeaviateVectorStore.fromExistingCollection(\n\t\t\tembeddings,\n\t\t\tconfig,\n\t\t\tvalidFilter,\n\t\t);\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\tconst collectionName = context.getNodeParameter('weaviateCollection', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\n\t\tconst options = context.getNodeParameter('options', itemIndex, {}) as {\n\t\t\ttenant?: string;\n\t\t\ttextKey?: string;\n\t\t\tclearStore?: boolean;\n\t\t\tmetadataKeys?: string;\n\t\t};\n\n\t\tconst credentials = await context.getCredentials('weaviateApi');\n\n\t\tconst metadataKeys = options.metadataKeys ? options.metadataKeys.split(',') : [];\n\n\t\tconst client = await createWeaviateClient(credentials as WeaviateCredential);\n\n\t\tconst config: WeaviateLibArgs = {\n\t\t\tclient,\n\t\t\tindexName: collectionName,\n\t\t\ttenant: options.tenant ?? undefined,\n\t\t\ttextKey: options.textKey ? options.textKey : 'text',\n\t\t\tmetadataKeys: metadataKeys as string[] | undefined,\n\t\t};\n\n\t\tif (options.clearStore) {\n\t\t\tif (!options.tenant) {\n\t\t\t\tawait client.collections.delete(collectionName);\n\t\t\t} else {\n\t\t\t\tconst collection = client.collections.get(collectionName);\n\t\t\t\tawait collection.tenants.remove([{ name: options.tenant }]);\n\t\t\t}\n\t\t}\n\n\t\tawait WeaviateStore.fromDocuments(documents, embeddings, config);\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB;AAGzB,sBAA8B;AAC9B,0BAMO;AAIP,sBAA2D;AAC3D,mCAAsC;AACtC,wBAA0C;AAC1C,0BAAsC;AAYtC,MAAM,oCAAoC,8BAAc;AAAA,EAIvD,aAAa,uBACZ,YACA,MACA,eACuC;AAEvC,UAAM,OAAO;AACb,UAAM,gBAAgB,MAAM,KAAK,kBAAkB,YAAY,IAAI;AAEnE,QAAI,EAAE,yBAAyB,8BAA8B;AAC5D,YAAM,IAAI;AAAA,QACT;AAAA,MACD;AAAA,IACD;AAEA,UAAM,OAAO;AAGb,SA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