@n8n/n8n-nodes-langchain 1.117.0 → 1.119.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/McpOAuth2Api.credentials.js +45 -0
- package/dist/credentials/McpOAuth2Api.credentials.js.map +1 -0
- package/dist/known/credentials.json +10 -0
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/Guardrails/Guardrails.node.js +73 -0
- package/dist/nodes/Guardrails/Guardrails.node.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/jailbreak.js +50 -0
- package/dist/nodes/Guardrails/actions/checks/jailbreak.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/keywords.js +66 -0
- package/dist/nodes/Guardrails/actions/checks/keywords.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/nsfw.js +53 -0
- package/dist/nodes/Guardrails/actions/checks/nsfw.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/pii.js +232 -0
- package/dist/nodes/Guardrails/actions/checks/pii.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/secretKeys.js +201 -0
- package/dist/nodes/Guardrails/actions/checks/secretKeys.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/topicalAlignment.js +38 -0
- package/dist/nodes/Guardrails/actions/checks/topicalAlignment.js.map +1 -0
- package/dist/nodes/Guardrails/actions/checks/urls.js +245 -0
- package/dist/nodes/Guardrails/actions/checks/urls.js.map +1 -0
- package/dist/nodes/Guardrails/actions/process.js +220 -0
- package/dist/nodes/Guardrails/actions/process.js.map +1 -0
- package/dist/nodes/Guardrails/actions/types.js +35 -0
- package/dist/nodes/Guardrails/actions/types.js.map +1 -0
- package/dist/nodes/Guardrails/description.js +454 -0
- package/dist/nodes/Guardrails/description.js.map +1 -0
- package/dist/nodes/Guardrails/guardrails.svg +11 -0
- package/dist/nodes/Guardrails/helpers/base.js +67 -0
- package/dist/nodes/Guardrails/helpers/base.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/common.js +45 -0
- package/dist/nodes/Guardrails/helpers/common.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/configureNodeInputs.js +50 -0
- package/dist/nodes/Guardrails/helpers/configureNodeInputs.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/mappers.js +100 -0
- package/dist/nodes/Guardrails/helpers/mappers.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/model.js +144 -0
- package/dist/nodes/Guardrails/helpers/model.js.map +1 -0
- package/dist/nodes/Guardrails/helpers/preflight.js +61 -0
- package/dist/nodes/Guardrails/helpers/preflight.js.map +1 -0
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js +6 -0
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js +8 -0
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V3/AgentV3.node.js +8 -0
- package/dist/nodes/agents/Agent/V3/AgentV3.node.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/description.js +10 -0
- package/dist/nodes/agents/Agent/agents/SqlAgent/description.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js +22 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js +8 -3
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/methods/config.js +4 -0
- package/dist/nodes/chains/ChainLLM/methods/config.js.map +1 -1
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +6 -0
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.js +19 -4
- package/dist/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +448 -24
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/common.js +155 -0
- package/dist/nodes/llms/LMChatOpenAi/common.js.map +1 -0
- package/dist/nodes/llms/LMChatOpenAi/types.js +17 -0
- package/dist/nodes/llms/LMChatOpenAi/types.js.map +1 -0
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js +21 -10
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js +48 -3
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/loadOptions.js +2 -1
- package/dist/nodes/mcp/McpClientTool/loadOptions.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/types.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/utils.js +66 -4
- package/dist/nodes/mcp/McpClientTool/utils.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +45 -2
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/helpers/utils.js +5 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js +6 -12
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v2/actions/text/response.operation.js +31 -6
- package/dist/nodes/vendors/OpenAi/v2/actions/text/response.operation.js.map +1 -1
- package/dist/types/credentials.json +1 -0
- package/dist/types/nodes.json +12 -11
- package/dist/utils/descriptions.js +18 -0
- package/dist/utils/descriptions.js.map +1 -1
- package/dist/utils/helpers.js +4 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/httpProxyAgent.js +14 -1
- package/dist/utils/httpProxyAgent.js.map +1 -1
- package/package.json +13 -11
|
@@ -25,6 +25,7 @@ __export(descriptions_exports, {
|
|
|
25
25
|
jsonSchemaExampleField: () => jsonSchemaExampleField,
|
|
26
26
|
promptTypeOptions: () => promptTypeOptions,
|
|
27
27
|
schemaTypeField: () => schemaTypeField,
|
|
28
|
+
textFromGuardrailsNode: () => textFromGuardrailsNode,
|
|
28
29
|
textFromPreviousNode: () => textFromPreviousNode,
|
|
29
30
|
textInput: () => textInput,
|
|
30
31
|
toolDescription: () => toolDescription
|
|
@@ -119,6 +120,11 @@ const promptTypeOptions = {
|
|
|
119
120
|
value: "auto",
|
|
120
121
|
description: "Looks for an input field called 'chatInput' that is coming from a directly connected Chat Trigger"
|
|
121
122
|
},
|
|
123
|
+
{
|
|
124
|
+
name: "Connected Guardrails Node",
|
|
125
|
+
value: "guardrails",
|
|
126
|
+
description: "Looks for an input field called 'guardrailsInput' that is coming from a directly connected Guardrails Node"
|
|
127
|
+
},
|
|
122
128
|
{
|
|
123
129
|
name: "Define below",
|
|
124
130
|
value: "define",
|
|
@@ -149,6 +155,17 @@ const textFromPreviousNode = {
|
|
|
149
155
|
},
|
|
150
156
|
disabledOptions: { show: { promptType: ["auto"] } }
|
|
151
157
|
};
|
|
158
|
+
const textFromGuardrailsNode = {
|
|
159
|
+
displayName: "Prompt (User Message)",
|
|
160
|
+
name: "text",
|
|
161
|
+
type: "string",
|
|
162
|
+
required: true,
|
|
163
|
+
default: "={{ $json.guardrailsInput }}",
|
|
164
|
+
typeOptions: {
|
|
165
|
+
rows: 2
|
|
166
|
+
},
|
|
167
|
+
disabledOptions: { show: { promptType: ["guardrails"] } }
|
|
168
|
+
};
|
|
152
169
|
const toolDescription = {
|
|
153
170
|
displayName: "Description",
|
|
154
171
|
name: "toolDescription",
|
|
@@ -167,6 +184,7 @@ const toolDescription = {
|
|
|
167
184
|
jsonSchemaExampleField,
|
|
168
185
|
promptTypeOptions,
|
|
169
186
|
schemaTypeField,
|
|
187
|
+
textFromGuardrailsNode,
|
|
170
188
|
textFromPreviousNode,
|
|
171
189
|
textInput,
|
|
172
190
|
toolDescription
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../utils/descriptions.ts"],"sourcesContent":["import type { DisplayCondition, INodeProperties, NodeParameterValue } from 'n8n-workflow';\n\nexport const schemaTypeField: INodeProperties = {\n\tdisplayName: 'Schema Type',\n\tname: 'schemaType',\n\ttype: 'options',\n\tnoDataExpression: true,\n\toptions: [\n\t\t{\n\t\t\tname: 'Generate From JSON Example',\n\t\t\tvalue: 'fromJson',\n\t\t\tdescription: 'Generate a schema from an example JSON object',\n\t\t},\n\t\t{\n\t\t\tname: 'Define using JSON Schema',\n\t\t\tvalue: 'manual',\n\t\t\tdescription: 'Define the JSON schema manually',\n\t\t},\n\t],\n\tdefault: 'fromJson',\n\tdescription: 'How to specify the schema for the function',\n};\n\n/**\n * Returns a field for inputting a JSON example that can be used to generate the schema.\n * @param props\n */\nexport const buildJsonSchemaExampleField = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName: 'JSON Example',\n\tname: 'jsonSchemaExample',\n\ttype: 'json',\n\tdefault: `{\n\t\"some_input\": \"some_value\"\n}`,\n\tnoDataExpression: true,\n\ttypeOptions: {\n\t\trows: 10,\n\t},\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['fromJson'],\n\t\t},\n\t},\n\tdescription: 'Example JSON object to use to generate the schema',\n});\n\n/**\n * Returns a notice field about the generated schema properties being required by default.\n * @param props\n */\nexport const buildJsonSchemaExampleNotice = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName:\n\t\t\"All properties will be required. To make them optional, use the 'JSON Schema' schema type instead\",\n\tname: 'notice',\n\ttype: 'notice',\n\tdefault: '',\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['fromJson'],\n\t\t},\n\t},\n});\n\nexport const jsonSchemaExampleField = buildJsonSchemaExampleField();\n\nexport const buildInputSchemaField = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName: 'Input Schema',\n\tname: 'inputSchema',\n\ttype: 'json',\n\tdefault: `{\n\"type\": \"object\",\n\"properties\": {\n\t\"some_input\": {\n\t\t\"type\": \"string\",\n\t\t\"description\": \"Some input to the function\"\n\t\t}\n\t}\n}`,\n\tnoDataExpression: false,\n\ttypeOptions: {\n\t\trows: 10,\n\t},\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['manual'],\n\t\t},\n\t},\n\tdescription: 'Schema to use for the function',\n\thint: 'Use <a target=\"_blank\" href=\"https://json-schema.org/\">JSON Schema</a> format (<a target=\"_blank\" href=\"https://json-schema.org/learn/miscellaneous-examples.html\">examples</a>). $refs syntax is currently not supported.',\n});\n\nexport const inputSchemaField = buildInputSchemaField();\n\nexport const promptTypeOptions: INodeProperties = {\n\tdisplayName: 'Source for Prompt (User Message)',\n\tname: 'promptType',\n\ttype: 'options',\n\toptions: [\n\t\t{\n\t\t\tname: 'Connected Chat Trigger Node',\n\t\t\tvalue: 'auto',\n\t\t\tdescription:\n\t\t\t\t\"Looks for an input field called 'chatInput' that is coming from a directly connected Chat Trigger\",\n\t\t},\n\t\t{\n\t\t\tname: 'Define below',\n\t\t\tvalue: 'define',\n\t\t\tdescription: 'Use an expression to reference data in previous nodes or enter static text',\n\t\t},\n\t],\n\tdefault: 'auto',\n};\n\nexport const textInput: INodeProperties = {\n\tdisplayName: 'Prompt (User Message)',\n\tname: 'text',\n\ttype: 'string',\n\trequired: true,\n\tdefault: '',\n\tplaceholder: 'e.g. Hello, how can you help me?',\n\ttypeOptions: {\n\t\trows: 2,\n\t},\n};\n\nexport const textFromPreviousNode: INodeProperties = {\n\tdisplayName: 'Prompt (User Message)',\n\tname: 'text',\n\ttype: 'string',\n\trequired: true,\n\tdefault: '={{ $json.chatInput }}',\n\ttypeOptions: {\n\t\trows: 2,\n\t},\n\tdisabledOptions: { show: { promptType: ['auto'] } },\n};\n\nexport const toolDescription: INodeProperties = {\n\tdisplayName: 'Description',\n\tname: 'toolDescription',\n\ttype: 'string',\n\tdefault: 'AI Agent that can call other tools',\n\trequired: true,\n\ttypeOptions: { rows: 2 },\n\tdescription:\n\t\t'Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,kBAAmC;AAAA,EAC/C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,kBAAkB;AAAA,EAClB,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IACd;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IACd;AAAA,EACD;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACd;AAMO,MAAM,8BAA8B,CAAC,WAEpB;AAAA,EACvB,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA;AAAA;AAAA,EAGT,kBAAkB;AAAA,EAClB,aAAa;AAAA,IACZ,MAAM;AAAA,EACP;AAAA,EACA,gBAAgB;AAAA,IACf,MAAM;AAAA,MACL,GAAG,OAAO;AAAA,MACV,YAAY,CAAC,UAAU;AAAA,IACxB;AAAA,EACD;AAAA,EACA,aAAa;AACd;AAMO,MAAM,+BAA+B,CAAC,WAErB;AAAA,EACvB,aACC;AAAA,EACD,MAAM;AAAA,EACN,MAAM;AAAA,EAC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AAAA,EAC/C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AAAA,EACV,aAAa,EAAE,MAAM,EAAE;AAAA,EACvB,aACC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../utils/descriptions.ts"],"sourcesContent":["import type { DisplayCondition, INodeProperties, NodeParameterValue } from 'n8n-workflow';\n\nexport const schemaTypeField: INodeProperties = {\n\tdisplayName: 'Schema Type',\n\tname: 'schemaType',\n\ttype: 'options',\n\tnoDataExpression: true,\n\toptions: [\n\t\t{\n\t\t\tname: 'Generate From JSON Example',\n\t\t\tvalue: 'fromJson',\n\t\t\tdescription: 'Generate a schema from an example JSON object',\n\t\t},\n\t\t{\n\t\t\tname: 'Define using JSON Schema',\n\t\t\tvalue: 'manual',\n\t\t\tdescription: 'Define the JSON schema manually',\n\t\t},\n\t],\n\tdefault: 'fromJson',\n\tdescription: 'How to specify the schema for the function',\n};\n\n/**\n * Returns a field for inputting a JSON example that can be used to generate the schema.\n * @param props\n */\nexport const buildJsonSchemaExampleField = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName: 'JSON Example',\n\tname: 'jsonSchemaExample',\n\ttype: 'json',\n\tdefault: `{\n\t\"some_input\": \"some_value\"\n}`,\n\tnoDataExpression: true,\n\ttypeOptions: {\n\t\trows: 10,\n\t},\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['fromJson'],\n\t\t},\n\t},\n\tdescription: 'Example JSON object to use to generate the schema',\n});\n\n/**\n * Returns a notice field about the generated schema properties being required by default.\n * @param props\n */\nexport const buildJsonSchemaExampleNotice = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName:\n\t\t\"All properties will be required. To make them optional, use the 'JSON Schema' schema type instead\",\n\tname: 'notice',\n\ttype: 'notice',\n\tdefault: '',\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['fromJson'],\n\t\t},\n\t},\n});\n\nexport const jsonSchemaExampleField = buildJsonSchemaExampleField();\n\nexport const buildInputSchemaField = (props?: {\n\tshowExtraProps?: Record<string, Array<NodeParameterValue | DisplayCondition> | undefined>;\n}): INodeProperties => ({\n\tdisplayName: 'Input Schema',\n\tname: 'inputSchema',\n\ttype: 'json',\n\tdefault: `{\n\"type\": \"object\",\n\"properties\": {\n\t\"some_input\": {\n\t\t\"type\": \"string\",\n\t\t\"description\": \"Some input to the function\"\n\t\t}\n\t}\n}`,\n\tnoDataExpression: false,\n\ttypeOptions: {\n\t\trows: 10,\n\t},\n\tdisplayOptions: {\n\t\tshow: {\n\t\t\t...props?.showExtraProps,\n\t\t\tschemaType: ['manual'],\n\t\t},\n\t},\n\tdescription: 'Schema to use for the function',\n\thint: 'Use <a target=\"_blank\" href=\"https://json-schema.org/\">JSON Schema</a> format (<a target=\"_blank\" href=\"https://json-schema.org/learn/miscellaneous-examples.html\">examples</a>). $refs syntax is currently not supported.',\n});\n\nexport const inputSchemaField = buildInputSchemaField();\n\nexport const promptTypeOptions: INodeProperties = {\n\tdisplayName: 'Source for Prompt (User Message)',\n\tname: 'promptType',\n\ttype: 'options',\n\toptions: [\n\t\t{\n\t\t\tname: 'Connected Chat Trigger Node',\n\t\t\tvalue: 'auto',\n\t\t\tdescription:\n\t\t\t\t\"Looks for an input field called 'chatInput' that is coming from a directly connected Chat Trigger\",\n\t\t},\n\t\t{\n\t\t\tname: 'Connected Guardrails Node',\n\t\t\tvalue: 'guardrails',\n\t\t\tdescription:\n\t\t\t\t\"Looks for an input field called 'guardrailsInput' that is coming from a directly connected Guardrails Node\",\n\t\t},\n\t\t{\n\t\t\tname: 'Define below',\n\t\t\tvalue: 'define',\n\t\t\tdescription: 'Use an expression to reference data in previous nodes or enter static text',\n\t\t},\n\t],\n\tdefault: 'auto',\n};\n\nexport const textInput: INodeProperties = {\n\tdisplayName: 'Prompt (User Message)',\n\tname: 'text',\n\ttype: 'string',\n\trequired: true,\n\tdefault: '',\n\tplaceholder: 'e.g. Hello, how can you help me?',\n\ttypeOptions: {\n\t\trows: 2,\n\t},\n};\n\nexport const textFromPreviousNode: INodeProperties = {\n\tdisplayName: 'Prompt (User Message)',\n\tname: 'text',\n\ttype: 'string',\n\trequired: true,\n\tdefault: '={{ $json.chatInput }}',\n\ttypeOptions: {\n\t\trows: 2,\n\t},\n\tdisabledOptions: { show: { promptType: ['auto'] } },\n};\n\nexport const textFromGuardrailsNode: INodeProperties = {\n\tdisplayName: 'Prompt (User Message)',\n\tname: 'text',\n\ttype: 'string',\n\trequired: true,\n\tdefault: '={{ $json.guardrailsInput }}',\n\ttypeOptions: {\n\t\trows: 2,\n\t},\n\tdisabledOptions: { show: { promptType: ['guardrails'] } },\n};\n\nexport const toolDescription: INodeProperties = {\n\tdisplayName: 'Description',\n\tname: 'toolDescription',\n\ttype: 'string',\n\tdefault: 'AI Agent that can call other tools',\n\trequired: true,\n\ttypeOptions: { rows: 2 },\n\tdescription:\n\t\t'Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,kBAAmC;AAAA,EAC/C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,kBAAkB;AAAA,EAClB,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IACd;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,IACd;AAAA,EACD;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACd;AAMO,MAAM,8BAA8B,CAAC,WAE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A,EACD;AAAA,EACA,SAAS;AACV;AAEO,MAAM,YAA6B;AAAA,EACzC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AAAA,EACb,aAAa;AAAA,IACZ,MAAM;AAAA,EACP;AACD;AAEO,MAAM,uBAAwC;AAAA,EACpD,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AAAA,IACZ,MAAM;AAAA,EACP;AAAA,EACA,iBAAiB,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE;AACnD;AAEO,MAAM,yBAA0C;AAAA,EACtD,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,aAAa;AAAA,IACZ,MAAM;AAAA,EACP;AAAA,EACA,iBAAiB,EAAE,MAAM,EAAE,YAAY,CAAC,YAAY,EAAE,EAAE;AACzD;AAEO,MAAM,kBAAmC;AAAA,EAC/C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AAAA,EACV,aAAa,EAAE,MAAM,EAAE;AAAA,EACvB,aACC;AACF;","names":[]}
|
package/dist/utils/helpers.js
CHANGED
|
@@ -76,12 +76,15 @@ function getPromptInputByType(options) {
|
|
|
76
76
|
let input;
|
|
77
77
|
if (promptType === "auto") {
|
|
78
78
|
input = ctx.evaluateExpression('{{ $json["chatInput"] }}', i);
|
|
79
|
+
} else if (promptType === "guardrails") {
|
|
80
|
+
input = ctx.evaluateExpression('{{ $json["guardrailsInput"] }}', i);
|
|
79
81
|
} else {
|
|
80
82
|
input = ctx.getNodeParameter(inputKey, i);
|
|
81
83
|
}
|
|
82
84
|
if (input === void 0) {
|
|
85
|
+
const key = promptType === "auto" ? "chatInput" : "guardrailsInput";
|
|
83
86
|
throw new import_n8n_workflow.NodeOperationError(ctx.getNode(), "No prompt specified", {
|
|
84
|
-
description:
|
|
87
|
+
description: `Expected to find the prompt in an input field called '${key}' (this is what the ${promptType === "auto" ? "chat trigger node" : "guardrails node"} node outputs). To use something else, change the 'Prompt' parameter`
|
|
85
88
|
});
|
|
86
89
|
}
|
|
87
90
|
return input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../utils/helpers.ts"],"sourcesContent":["import type { BaseChatMessageHistory } from '@langchain/core/chat_history';\nimport type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport type { BaseLLM } from '@langchain/core/language_models/llms';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport type { Tool } from '@langchain/core/tools';\nimport { Toolkit } from 'langchain/agents';\nimport type { BaseChatMemory } from 'langchain/memory';\nimport { NodeConnectionTypes, NodeOperationError, jsonStringify } from 'n8n-workflow';\nimport type {\n\tAiEvent,\n\tIDataObject,\n\tIExecuteFunctions,\n\tISupplyDataFunctions,\n\tIWebhookFunctions,\n} from 'n8n-workflow';\n\nimport { N8nTool } from './N8nTool';\n\nfunction hasMethods<T>(obj: unknown, ...methodNames: Array<string | symbol>): obj is T {\n\treturn methodNames.every(\n\t\t(methodName) =>\n\t\t\ttypeof obj === 'object' &&\n\t\t\tobj !== null &&\n\t\t\tmethodName in obj &&\n\t\t\ttypeof (obj as Record<string | symbol, unknown>)[methodName] === 'function',\n\t);\n}\n\nexport function getMetadataFiltersValues(\n\tctx: IExecuteFunctions | ISupplyDataFunctions,\n\titemIndex: number,\n): Record<string, never> | undefined {\n\tconst options = ctx.getNodeParameter('options', itemIndex, {});\n\n\tif (options.metadata) {\n\t\tconst { metadataValues: metadata } = options.metadata as {\n\t\t\tmetadataValues: Array<{\n\t\t\t\tname: string;\n\t\t\t\tvalue: string;\n\t\t\t}>;\n\t\t};\n\t\tif (metadata.length > 0) {\n\t\t\treturn metadata.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {});\n\t\t}\n\t}\n\n\tif (options.searchFilterJson) {\n\t\treturn ctx.getNodeParameter('options.searchFilterJson', itemIndex, '', {\n\t\t\tensureType: 'object',\n\t\t}) as Record<string, never>;\n\t}\n\n\treturn undefined;\n}\n\nexport function isBaseChatMemory(obj: unknown) {\n\treturn hasMethods<BaseChatMemory>(obj, 'loadMemoryVariables', 'saveContext');\n}\n\nexport function isBaseChatMessageHistory(obj: unknown) {\n\treturn hasMethods<BaseChatMessageHistory>(obj, 'getMessages', 'addMessage');\n}\n\nexport function isChatInstance(model: unknown): model is BaseChatModel {\n\tconst namespace = (model as BaseLLM)?.lc_namespace ?? [];\n\n\treturn namespace.includes('chat_models');\n}\n\nexport function isToolsInstance(model: unknown): model is Tool {\n\tconst namespace = (model as Tool)?.lc_namespace ?? [];\n\n\treturn namespace.includes('tools');\n}\n\nexport function getPromptInputByType(options: {\n\tctx: IExecuteFunctions | ISupplyDataFunctions;\n\ti: number;\n\tpromptTypeKey: string;\n\tinputKey: string;\n}) {\n\tconst { ctx, i, promptTypeKey, inputKey } = options;\n\tconst promptType = ctx.getNodeParameter(promptTypeKey, i, 'define') as string;\n\n\tlet input;\n\tif (promptType === 'auto') {\n\t\tinput = ctx.evaluateExpression('{{ $json[\"chatInput\"] }}', i) as string;\n\t} else {\n\t\tinput = ctx.getNodeParameter(inputKey, i) as string;\n\t}\n\n\tif (input === undefined) {\n\t\tthrow new NodeOperationError(ctx.getNode(), 'No prompt specified', {\n\t\t\tdescription:\n\t\t\t\t\"Expected to find the prompt in an input field called 'chatInput' (this is what the chat trigger node outputs). To use something else, change the 'Prompt' parameter\",\n\t\t});\n\t}\n\n\treturn input;\n}\n\nexport function getSessionId(\n\tctx: ISupplyDataFunctions | IWebhookFunctions,\n\titemIndex: number,\n\tselectorKey = 'sessionIdType',\n\tautoSelect = 'fromInput',\n\tcustomKey = 'sessionKey',\n) {\n\tlet sessionId = '';\n\tconst selectorType = ctx.getNodeParameter(selectorKey, itemIndex) as string;\n\n\tif (selectorType === autoSelect) {\n\t\t// If memory node is used in webhook like node(like chat trigger node), it doesn't have access to evaluateExpression\n\t\t// so we try to extract sessionId from the bodyData\n\t\tif ('getBodyData' in ctx) {\n\t\t\tconst bodyData = ctx.getBodyData() ?? {};\n\t\t\tsessionId = bodyData.sessionId as string;\n\t\t} else {\n\t\t\tsessionId = ctx.evaluateExpression('{{ $json.sessionId }}', itemIndex) as string;\n\n\t\t\t// try to get sessionId from chat trigger\n\t\t\tif (!sessionId || sessionId === undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tconst chatTrigger = ctx.getChatTrigger();\n\n\t\t\t\t\tif (chatTrigger) {\n\t\t\t\t\t\tsessionId = ctx.evaluateExpression(\n\t\t\t\t\t\t\t`{{ $('${chatTrigger.name}').first().json.sessionId }}`,\n\t\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\t) as string;\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {}\n\t\t\t}\n\t\t}\n\n\t\tif (sessionId === '' || sessionId === undefined) {\n\t\t\tthrow new NodeOperationError(ctx.getNode(), 'No session ID found', {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Expected to find the session ID in an input field called 'sessionId' (this is what the chat trigger node outputs). To use something else, change the 'Session ID' parameter\",\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tsessionId = ctx.getNodeParameter(customKey, itemIndex, '') as string;\n\t\tif (sessionId === '' || sessionId === undefined) {\n\t\t\tthrow new NodeOperationError(ctx.getNode(), 'Key parameter is empty', {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Provide a key to use as session ID in the 'Key' parameter or use the 'Connected Chat Trigger Node' option to use the session ID from your Chat Trigger\",\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn sessionId;\n}\n\nexport function logAiEvent(\n\texecuteFunctions: IExecuteFunctions | ISupplyDataFunctions,\n\tevent: AiEvent,\n\tdata?: IDataObject,\n) {\n\ttry {\n\t\texecuteFunctions.logAiEvent(event, data ? jsonStringify(data) : undefined);\n\t} catch (error) {\n\t\texecuteFunctions.logger.debug(`Error logging AI event: ${event}`);\n\t}\n}\n\nexport function serializeChatHistory(chatHistory: BaseMessage[]): string {\n\treturn chatHistory\n\t\t.map((chatMessage) => {\n\t\t\tif (chatMessage._getType() === 'human') {\n\t\t\t\treturn `Human: ${chatMessage.content}`;\n\t\t\t} else if (chatMessage._getType() === 'ai') {\n\t\t\t\treturn `Assistant: ${chatMessage.content}`;\n\t\t\t} else {\n\t\t\t\treturn `${chatMessage.content}`;\n\t\t\t}\n\t\t})\n\t\t.join('\\n');\n}\n\nexport function escapeSingleCurlyBrackets(text?: string): string | undefined {\n\tif (text === undefined) return undefined;\n\n\tlet result = text;\n\n\tresult = result\n\t\t// First handle triple brackets to avoid interference with double brackets\n\t\t.replace(/(?<!{){{{(?!{)/g, '{{{{')\n\t\t.replace(/(?<!})}}}(?!})/g, '}}}}')\n\t\t// Then handle single brackets, but only if they're not part of double brackets\n\t\t// Convert single { to {{ if it's not already part of {{ or {{{\n\t\t.replace(/(?<!{){(?!{)/g, '{{')\n\t\t// Convert single } to }} if it's not already part of }} or }}}\n\t\t.replace(/(?<!})}(?!})/g, '}}');\n\n\treturn result;\n}\n\nexport const getConnectedTools = async (\n\tctx: IExecuteFunctions | IWebhookFunctions | ISupplyDataFunctions,\n\tenforceUniqueNames: boolean,\n\tconvertStructuredTool: boolean = true,\n\tescapeCurlyBrackets: boolean = false,\n) => {\n\tconst toolkitConnections = (await ctx.getInputConnectionData(\n\t\tNodeConnectionTypes.AiTool,\n\t\t0,\n\t)) as Array<Toolkit | Tool>;\n\n\t// Get parent nodes to map toolkits to their source nodes\n\tconst parentNodes =\n\t\t'getParentNodes' in ctx\n\t\t\t? ctx.getParentNodes(ctx.getNode().name, {\n\t\t\t\t\tconnectionType: NodeConnectionTypes.AiTool,\n\t\t\t\t\tdepth: 1,\n\t\t\t\t})\n\t\t\t: [];\n\n\tconst connectedTools = (toolkitConnections ?? []).flatMap((toolOrToolkit, index) => {\n\t\tif (toolOrToolkit instanceof Toolkit) {\n\t\t\tconst tools = toolOrToolkit.getTools() as Tool[];\n\t\t\t// Add metadata to each tool from the toolkit\n\t\t\treturn tools.map((tool) => {\n\t\t\t\tconst sourceNode = parentNodes[index] ?? tool.name;\n\n\t\t\t\ttool.metadata ??= {};\n\t\t\t\ttool.metadata.isFromToolkit = true;\n\t\t\t\ttool.metadata.sourceNodeName = sourceNode?.name;\n\t\t\t\treturn tool;\n\t\t\t});\n\t\t} else {\n\t\t\tconst sourceNode = parentNodes[index] ?? toolOrToolkit.name;\n\t\t\ttoolOrToolkit.metadata ??= {};\n\t\t\ttoolOrToolkit.metadata.isFromToolkit = false;\n\t\t\ttoolOrToolkit.metadata.sourceNodeName = sourceNode?.name;\n\t\t}\n\n\t\treturn toolOrToolkit;\n\t});\n\n\tif (!enforceUniqueNames) return connectedTools;\n\n\tconst seenNames = new Set<string>();\n\n\tconst finalTools: Tool[] = [];\n\n\tfor (const tool of connectedTools) {\n\t\tconst { name } = tool;\n\t\tif (seenNames.has(name)) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t`You have multiple tools with the same name: '${name}', please rename them to avoid conflicts`,\n\t\t\t);\n\t\t}\n\t\tseenNames.add(name);\n\n\t\tif (escapeCurlyBrackets) {\n\t\t\ttool.description = escapeSingleCurlyBrackets(tool.description) ?? tool.description;\n\t\t}\n\n\t\tif (convertStructuredTool && tool instanceof N8nTool) {\n\t\t\tfinalTools.push(tool.asDynamicTool());\n\t\t} else {\n\t\t\tfinalTools.push(tool);\n\t\t}\n\t}\n\n\treturn finalTools;\n};\n\n/**\n * Sometimes model output is wrapped in an additional object property.\n * This function unwraps the output if it is in the format { output: { output: { ... } } }\n */\nexport function unwrapNestedOutput(output: Record<string, unknown>): Record<string, unknown> {\n\tif (\n\t\t'output' in output &&\n\t\tObject.keys(output).length === 1 &&\n\t\ttypeof output.output === 'object' &&\n\t\toutput.output !== null &&\n\t\t'output' in output.output &&\n\t\tObject.keys(output.output).length === 1\n\t) {\n\t\treturn output.output as Record<string, unknown>;\n\t}\n\n\treturn output;\n}\n\n/**\n * Detects if a text contains a character that repeats sequentially for a specified threshold.\n * This is used to prevent performance issues with tiktoken on highly repetitive content.\n * @param text The text to check\n * @param threshold The minimum number of sequential repeats to detect (default: 1000)\n * @returns true if a character repeats sequentially for at least the threshold amount\n */\nexport function hasLongSequentialRepeat(text: string, threshold = 1000): boolean {\n\ttry {\n\t\t// Validate inputs\n\t\tif (\n\t\t\ttext === null ||\n\t\t\ttypeof text !== 'string' ||\n\t\t\ttext.length === 0 ||\n\t\t\tthreshold <= 0 ||\n\t\t\ttext.length < threshold\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// Use string iterator to avoid creating array copy (memory efficient)\n\t\tconst iterator = text[Symbol.iterator]();\n\t\tlet prev = iterator.next();\n\n\t\tif (prev.done) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet count = 1;\n\t\tfor (const char of iterator) {\n\t\t\tif (char === prev.value) {\n\t\t\t\tcount++;\n\t\t\t\tif (count >= threshold) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcount = 1;\n\t\t\t\tprev = { value: char, done: false };\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t} catch (error) {\n\t\t// On any error, return false to allow normal processing\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAwB;AAExB,0BAAuE;AASvE,qBAAwB;AAExB,SAAS,WAAc,QAAiB,aAA+C;AACtF,SAAO,YAAY;AAAA,IAClB,CAAC,eACA,OAAO,QAAQ,YACf,QAAQ,QACR,cAAc,OACd,OAAQ,IAAyC,UAAU,MAAM;AAAA,EACnE;AACD;AAEO,SAAS,yBACf,K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;AAAA,EACR,SAAS,OAAO;AAEf,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../utils/helpers.ts"],"sourcesContent":["import type { BaseChatMessageHistory } from '@langchain/core/chat_history';\nimport type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport type { BaseLLM } from '@langchain/core/language_models/llms';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport type { Tool } from '@langchain/core/tools';\nimport { Toolkit } from 'langchain/agents';\nimport type { BaseChatMemory } from 'langchain/memory';\nimport { NodeConnectionTypes, NodeOperationError, jsonStringify } from 'n8n-workflow';\nimport type {\n\tAiEvent,\n\tIDataObject,\n\tIExecuteFunctions,\n\tISupplyDataFunctions,\n\tIWebhookFunctions,\n} from 'n8n-workflow';\n\nimport { N8nTool } from './N8nTool';\n\nfunction hasMethods<T>(obj: unknown, ...methodNames: Array<string | symbol>): obj is T {\n\treturn methodNames.every(\n\t\t(methodName) =>\n\t\t\ttypeof obj === 'object' &&\n\t\t\tobj !== null &&\n\t\t\tmethodName in obj &&\n\t\t\ttypeof (obj as Record<string | symbol, unknown>)[methodName] === 'function',\n\t);\n}\n\nexport function getMetadataFiltersValues(\n\tctx: IExecuteFunctions | ISupplyDataFunctions,\n\titemIndex: number,\n): Record<string, never> | undefined {\n\tconst options = ctx.getNodeParameter('options', itemIndex, {});\n\n\tif (options.metadata) {\n\t\tconst { metadataValues: metadata } = options.metadata as {\n\t\t\tmetadataValues: Array<{\n\t\t\t\tname: string;\n\t\t\t\tvalue: string;\n\t\t\t}>;\n\t\t};\n\t\tif (metadata.length > 0) {\n\t\t\treturn metadata.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {});\n\t\t}\n\t}\n\n\tif (options.searchFilterJson) {\n\t\treturn ctx.getNodeParameter('options.searchFilterJson', itemIndex, '', {\n\t\t\tensureType: 'object',\n\t\t}) as Record<string, never>;\n\t}\n\n\treturn undefined;\n}\n\nexport function isBaseChatMemory(obj: unknown) {\n\treturn hasMethods<BaseChatMemory>(obj, 'loadMemoryVariables', 'saveContext');\n}\n\nexport function isBaseChatMessageHistory(obj: unknown) {\n\treturn hasMethods<BaseChatMessageHistory>(obj, 'getMessages', 'addMessage');\n}\n\nexport function isChatInstance(model: unknown): model is BaseChatModel {\n\tconst namespace = (model as BaseLLM)?.lc_namespace ?? [];\n\n\treturn namespace.includes('chat_models');\n}\n\nexport function isToolsInstance(model: unknown): model is Tool {\n\tconst namespace = (model as Tool)?.lc_namespace ?? [];\n\n\treturn namespace.includes('tools');\n}\n\nexport function getPromptInputByType(options: {\n\tctx: IExecuteFunctions | ISupplyDataFunctions;\n\ti: number;\n\tpromptTypeKey: string;\n\tinputKey: string;\n}) {\n\tconst { ctx, i, promptTypeKey, inputKey } = options;\n\tconst promptType = ctx.getNodeParameter(promptTypeKey, i, 'define') as string;\n\n\tlet input;\n\tif (promptType === 'auto') {\n\t\tinput = ctx.evaluateExpression('{{ $json[\"chatInput\"] }}', i) as string;\n\t} else if (promptType === 'guardrails') {\n\t\tinput = ctx.evaluateExpression('{{ $json[\"guardrailsInput\"] }}', i) as string;\n\t} else {\n\t\tinput = ctx.getNodeParameter(inputKey, i) as string;\n\t}\n\n\tif (input === undefined) {\n\t\tconst key = promptType === 'auto' ? 'chatInput' : 'guardrailsInput';\n\t\tthrow new NodeOperationError(ctx.getNode(), 'No prompt specified', {\n\t\t\tdescription: `Expected to find the prompt in an input field called '${key}' (this is what the ${promptType === 'auto' ? 'chat trigger node' : 'guardrails node'} node outputs). To use something else, change the 'Prompt' parameter`,\n\t\t});\n\t}\n\n\treturn input;\n}\n\nexport function getSessionId(\n\tctx: ISupplyDataFunctions | IWebhookFunctions,\n\titemIndex: number,\n\tselectorKey = 'sessionIdType',\n\tautoSelect = 'fromInput',\n\tcustomKey = 'sessionKey',\n) {\n\tlet sessionId = '';\n\tconst selectorType = ctx.getNodeParameter(selectorKey, itemIndex) as string;\n\n\tif (selectorType === autoSelect) {\n\t\t// If memory node is used in webhook like node(like chat trigger node), it doesn't have access to evaluateExpression\n\t\t// so we try to extract sessionId from the bodyData\n\t\tif ('getBodyData' in ctx) {\n\t\t\tconst bodyData = ctx.getBodyData() ?? {};\n\t\t\tsessionId = bodyData.sessionId as string;\n\t\t} else {\n\t\t\tsessionId = ctx.evaluateExpression('{{ $json.sessionId }}', itemIndex) as string;\n\n\t\t\t// try to get sessionId from chat trigger\n\t\t\tif (!sessionId || sessionId === undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tconst chatTrigger = ctx.getChatTrigger();\n\n\t\t\t\t\tif (chatTrigger) {\n\t\t\t\t\t\tsessionId = ctx.evaluateExpression(\n\t\t\t\t\t\t\t`{{ $('${chatTrigger.name}').first().json.sessionId }}`,\n\t\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\t) as string;\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {}\n\t\t\t}\n\t\t}\n\n\t\tif (sessionId === '' || sessionId === undefined) {\n\t\t\tthrow new NodeOperationError(ctx.getNode(), 'No session ID found', {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Expected to find the session ID in an input field called 'sessionId' (this is what the chat trigger node outputs). To use something else, change the 'Session ID' parameter\",\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t} else {\n\t\tsessionId = ctx.getNodeParameter(customKey, itemIndex, '') as string;\n\t\tif (sessionId === '' || sessionId === undefined) {\n\t\t\tthrow new NodeOperationError(ctx.getNode(), 'Key parameter is empty', {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Provide a key to use as session ID in the 'Key' parameter or use the 'Connected Chat Trigger Node' option to use the session ID from your Chat Trigger\",\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn sessionId;\n}\n\nexport function logAiEvent(\n\texecuteFunctions: IExecuteFunctions | ISupplyDataFunctions,\n\tevent: AiEvent,\n\tdata?: IDataObject,\n) {\n\ttry {\n\t\texecuteFunctions.logAiEvent(event, data ? jsonStringify(data) : undefined);\n\t} catch (error) {\n\t\texecuteFunctions.logger.debug(`Error logging AI event: ${event}`);\n\t}\n}\n\nexport function serializeChatHistory(chatHistory: BaseMessage[]): string {\n\treturn chatHistory\n\t\t.map((chatMessage) => {\n\t\t\tif (chatMessage._getType() === 'human') {\n\t\t\t\treturn `Human: ${chatMessage.content}`;\n\t\t\t} else if (chatMessage._getType() === 'ai') {\n\t\t\t\treturn `Assistant: ${chatMessage.content}`;\n\t\t\t} else {\n\t\t\t\treturn `${chatMessage.content}`;\n\t\t\t}\n\t\t})\n\t\t.join('\\n');\n}\n\nexport function escapeSingleCurlyBrackets(text?: string): string | undefined {\n\tif (text === undefined) return undefined;\n\n\tlet result = text;\n\n\tresult = result\n\t\t// First handle triple brackets to avoid interference with double brackets\n\t\t.replace(/(?<!{){{{(?!{)/g, '{{{{')\n\t\t.replace(/(?<!})}}}(?!})/g, '}}}}')\n\t\t// Then handle single brackets, but only if they're not part of double brackets\n\t\t// Convert single { to {{ if it's not already part of {{ or {{{\n\t\t.replace(/(?<!{){(?!{)/g, '{{')\n\t\t// Convert single } to }} if it's not already part of }} or }}}\n\t\t.replace(/(?<!})}(?!})/g, '}}');\n\n\treturn result;\n}\n\nexport const getConnectedTools = async (\n\tctx: IExecuteFunctions | IWebhookFunctions | ISupplyDataFunctions,\n\tenforceUniqueNames: boolean,\n\tconvertStructuredTool: boolean = true,\n\tescapeCurlyBrackets: boolean = false,\n) => {\n\tconst toolkitConnections = (await ctx.getInputConnectionData(\n\t\tNodeConnectionTypes.AiTool,\n\t\t0,\n\t)) as Array<Toolkit | Tool>;\n\n\t// Get parent nodes to map toolkits to their source nodes\n\tconst parentNodes =\n\t\t'getParentNodes' in ctx\n\t\t\t? ctx.getParentNodes(ctx.getNode().name, {\n\t\t\t\t\tconnectionType: NodeConnectionTypes.AiTool,\n\t\t\t\t\tdepth: 1,\n\t\t\t\t})\n\t\t\t: [];\n\n\tconst connectedTools = (toolkitConnections ?? []).flatMap((toolOrToolkit, index) => {\n\t\tif (toolOrToolkit instanceof Toolkit) {\n\t\t\tconst tools = toolOrToolkit.getTools() as Tool[];\n\t\t\t// Add metadata to each tool from the toolkit\n\t\t\treturn tools.map((tool) => {\n\t\t\t\tconst sourceNode = parentNodes[index] ?? tool.name;\n\n\t\t\t\ttool.metadata ??= {};\n\t\t\t\ttool.metadata.isFromToolkit = true;\n\t\t\t\ttool.metadata.sourceNodeName = sourceNode?.name;\n\t\t\t\treturn tool;\n\t\t\t});\n\t\t} else {\n\t\t\tconst sourceNode = parentNodes[index] ?? toolOrToolkit.name;\n\t\t\ttoolOrToolkit.metadata ??= {};\n\t\t\ttoolOrToolkit.metadata.isFromToolkit = false;\n\t\t\ttoolOrToolkit.metadata.sourceNodeName = sourceNode?.name;\n\t\t}\n\n\t\treturn toolOrToolkit;\n\t});\n\n\tif (!enforceUniqueNames) return connectedTools;\n\n\tconst seenNames = new Set<string>();\n\n\tconst finalTools: Tool[] = [];\n\n\tfor (const tool of connectedTools) {\n\t\tconst { name } = tool;\n\t\tif (seenNames.has(name)) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tctx.getNode(),\n\t\t\t\t`You have multiple tools with the same name: '${name}', please rename them to avoid conflicts`,\n\t\t\t);\n\t\t}\n\t\tseenNames.add(name);\n\n\t\tif (escapeCurlyBrackets) {\n\t\t\ttool.description = escapeSingleCurlyBrackets(tool.description) ?? tool.description;\n\t\t}\n\n\t\tif (convertStructuredTool && tool instanceof N8nTool) {\n\t\t\tfinalTools.push(tool.asDynamicTool());\n\t\t} else {\n\t\t\tfinalTools.push(tool);\n\t\t}\n\t}\n\n\treturn finalTools;\n};\n\n/**\n * Sometimes model output is wrapped in an additional object property.\n * This function unwraps the output if it is in the format { output: { output: { ... } } }\n */\nexport function unwrapNestedOutput(output: Record<string, unknown>): Record<string, unknown> {\n\tif (\n\t\t'output' in output &&\n\t\tObject.keys(output).length === 1 &&\n\t\ttypeof output.output === 'object' &&\n\t\toutput.output !== null &&\n\t\t'output' in output.output &&\n\t\tObject.keys(output.output).length === 1\n\t) {\n\t\treturn output.output as Record<string, unknown>;\n\t}\n\n\treturn output;\n}\n\n/**\n * Detects if a text contains a character that repeats sequentially for a specified threshold.\n * This is used to prevent performance issues with tiktoken on highly repetitive content.\n * @param text The text to check\n * @param threshold The minimum number of sequential repeats to detect (default: 1000)\n * @returns true if a character repeats sequentially for at least the threshold amount\n */\nexport function hasLongSequentialRepeat(text: string, threshold = 1000): boolean {\n\ttry {\n\t\t// Validate inputs\n\t\tif (\n\t\t\ttext === null ||\n\t\t\ttypeof text !== 'string' ||\n\t\t\ttext.length === 0 ||\n\t\t\tthreshold <= 0 ||\n\t\t\ttext.length < threshold\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// Use string iterator to avoid creating array copy (memory efficient)\n\t\tconst iterator = text[Symbol.iterator]();\n\t\tlet prev = iterator.next();\n\n\t\tif (prev.done) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet count = 1;\n\t\tfor (const char of iterator) {\n\t\t\tif (char === prev.value) {\n\t\t\t\tcount++;\n\t\t\t\tif (count >= threshold) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcount = 1;\n\t\t\t\tprev = { value: char, done: false };\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t} catch (error) {\n\t\t// On any error, return false to allow normal processing\n\t\treturn false;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAwB;AAExB,0BAAuE;AASvE,qBAAwB;AAExB,SAAS,WAAc,QAAiB,aAA+C;AACtF,SAAO,YAAY;AAAA,IAClB,CAAC,eACA,OAAO,QAAQ,YACf,QAAQ,QACR,cAAc,OACd,OAAQ,IAAyC,UAAU,MAAM;AAAA,EACnE;AACD;AAEO,SAAS,yBACf,KACA,WACoC;AACpC,QAAM,UAAU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,WAAW;AACvB,iBAAO;AAAA,QACR;AAAA,MACD,OAAO;AACN,gBAAQ;AACR,eAAO,EAAE,OAAO,MAAM,MAAM,MAAM;AAAA,MACnC;AAAA,IACD;AAEA,WAAO;AAAA,EACR,SAAS,OAAO;AAEf,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
@@ -28,20 +28,33 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var httpProxyAgent_exports = {};
|
|
30
30
|
__export(httpProxyAgent_exports, {
|
|
31
|
+
getNodeProxyAgent: () => getNodeProxyAgent,
|
|
31
32
|
getProxyAgent: () => getProxyAgent
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(httpProxyAgent_exports);
|
|
35
|
+
var import_https_proxy_agent = require("https-proxy-agent");
|
|
34
36
|
var import_proxy_from_env = __toESM(require("proxy-from-env"));
|
|
35
37
|
var import_undici = require("undici");
|
|
38
|
+
function getProxyUrlFromEnv(targetUrl) {
|
|
39
|
+
return import_proxy_from_env.default.getProxyForUrl(targetUrl ?? "https://example.nonexistent/");
|
|
40
|
+
}
|
|
36
41
|
function getProxyAgent(targetUrl) {
|
|
37
|
-
const proxyUrl =
|
|
42
|
+
const proxyUrl = getProxyUrlFromEnv(targetUrl);
|
|
38
43
|
if (!proxyUrl) {
|
|
39
44
|
return void 0;
|
|
40
45
|
}
|
|
41
46
|
return new import_undici.ProxyAgent(proxyUrl);
|
|
42
47
|
}
|
|
48
|
+
function getNodeProxyAgent(targetUrl) {
|
|
49
|
+
const proxyUrl = getProxyUrlFromEnv(targetUrl);
|
|
50
|
+
if (!proxyUrl) {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
return new import_https_proxy_agent.HttpsProxyAgent(proxyUrl);
|
|
54
|
+
}
|
|
43
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
56
|
0 && (module.exports = {
|
|
57
|
+
getNodeProxyAgent,
|
|
45
58
|
getProxyAgent
|
|
46
59
|
});
|
|
47
60
|
//# sourceMappingURL=httpProxyAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../utils/httpProxyAgent.ts"],"sourcesContent":["import proxyFromEnv from 'proxy-from-env';\nimport { ProxyAgent } from 'undici';\n\n/**\n *
|
|
1
|
+
{"version":3,"sources":["../../utils/httpProxyAgent.ts"],"sourcesContent":["import { HttpsProxyAgent } from 'https-proxy-agent';\nimport proxyFromEnv from 'proxy-from-env';\nimport { ProxyAgent } from 'undici';\n\n/**\n * Resolves the proxy URL from environment variables for a given target URL.\n *\n * @param targetUrl - The target URL to check proxy configuration for (optional)\n * @returns The proxy URL string or undefined if no proxy is configured\n *\n * @remarks\n * There are cases where we don't know the target URL in advance (e.g. when we need to provide a proxy agent to ChatAwsBedrock).\n * In such case we use a dummy URL.\n * This will lead to `NO_PROXY` environment variable not being respected, but it is better than not having a proxy agent at all.\n */\nfunction getProxyUrlFromEnv(targetUrl?: string): string {\n\treturn proxyFromEnv.getProxyForUrl(targetUrl ?? 'https://example.nonexistent/');\n}\n\n/**\n * Returns a ProxyAgent or undefined based on the environment variables and target URL.\n * When target URL is not provided, NO_PROXY environment variable is not respected.\n */\nexport function getProxyAgent(targetUrl?: string) {\n\tconst proxyUrl = getProxyUrlFromEnv(targetUrl);\n\n\tif (!proxyUrl) {\n\t\treturn undefined;\n\t}\n\n\treturn new ProxyAgent(proxyUrl);\n}\n\n/**\n * Returns a Node.js HTTP/HTTPS proxy agent for use with AWS SDK v3 clients.\n * AWS SDK v3 requires Node.js http.Agent/https.Agent instances (not undici ProxyAgent).\n *\n * @param targetUrl - The target URL to check proxy configuration for\n * @returns HttpsProxyAgent instance or undefined if no proxy is configured\n */\nexport function getNodeProxyAgent(targetUrl?: string) {\n\tconst proxyUrl = getProxyUrlFromEnv(targetUrl);\n\n\tif (!proxyUrl) {\n\t\treturn undefined;\n\t}\n\n\treturn new HttpsProxyAgent(proxyUrl);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAChC,4BAAyB;AACzB,oBAA2B;AAa3B,SAAS,mBAAmB,WAA4B;AACvD,SAAO,sBAAAA,QAAa,eAAe,aAAa,8BAA8B;AAC/E;AAMO,SAAS,cAAc,WAAoB;AACjD,QAAM,WAAW,mBAAmB,SAAS;AAE7C,MAAI,CAAC,UAAU;AACd,WAAO;AAAA,EACR;AAEA,SAAO,IAAI,yBAAW,QAAQ;AAC/B;AASO,SAAS,kBAAkB,WAAoB;AACrD,QAAM,WAAW,mBAAmB,SAAS;AAE7C,MAAI,CAAC,UAAU;AACd,WAAO;AAAA,EACR;AAEA,SAAO,IAAI,yCAAgB,QAAQ;AACpC;","names":["proxyFromEnv"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/n8n-nodes-langchain",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.119.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"dist/credentials/GooglePalmApi.credentials.js",
|
|
20
20
|
"dist/credentials/GroqApi.credentials.js",
|
|
21
21
|
"dist/credentials/HuggingFaceApi.credentials.js",
|
|
22
|
+
"dist/credentials/McpOAuth2Api.credentials.js",
|
|
22
23
|
"dist/credentials/MotorheadApi.credentials.js",
|
|
23
24
|
"dist/credentials/MilvusApi.credentials.js",
|
|
24
25
|
"dist/credentials/MistralCloudApi.credentials.js",
|
|
@@ -139,7 +140,8 @@
|
|
|
139
140
|
"dist/nodes/vector_store/VectorStoreZepInsert/VectorStoreZepInsert.node.js",
|
|
140
141
|
"dist/nodes/vector_store/VectorStoreZepLoad/VectorStoreZepLoad.node.js",
|
|
141
142
|
"dist/nodes/ToolExecutor/ToolExecutor.node.js",
|
|
142
|
-
"dist/nodes/ModelSelector/ModelSelector.node.js"
|
|
143
|
+
"dist/nodes/ModelSelector/ModelSelector.node.js",
|
|
144
|
+
"dist/nodes/Guardrails/Guardrails.node.js"
|
|
143
145
|
]
|
|
144
146
|
},
|
|
145
147
|
"devDependencies": {
|
|
@@ -154,8 +156,8 @@
|
|
|
154
156
|
"fast-glob": "3.2.12",
|
|
155
157
|
"jest-mock-extended": "^3.0.4",
|
|
156
158
|
"tsup": "^8.5.0",
|
|
157
|
-
"
|
|
158
|
-
"n8n-
|
|
159
|
+
"n8n-core": "1.119.0",
|
|
160
|
+
"@n8n/eslint-plugin-community-nodes": "0.6.0"
|
|
159
161
|
},
|
|
160
162
|
"dependencies": {
|
|
161
163
|
"@aws-sdk/client-sso-oidc": "3.808.0",
|
|
@@ -183,9 +185,9 @@
|
|
|
183
185
|
"@langchain/redis": "0.1.1",
|
|
184
186
|
"@langchain/textsplitters": "0.1.0",
|
|
185
187
|
"@langchain/weaviate": "0.2.0",
|
|
186
|
-
"@modelcontextprotocol/sdk": "1.
|
|
188
|
+
"@modelcontextprotocol/sdk": "1.20.0",
|
|
187
189
|
"@mozilla/readability": "0.6.0",
|
|
188
|
-
"@n8n/typeorm": "0.3.20-
|
|
190
|
+
"@n8n/typeorm": "0.3.20-15",
|
|
189
191
|
"@n8n/vm2": "3.9.25",
|
|
190
192
|
"@pinecone-database/pinecone": "^5.0.2",
|
|
191
193
|
"@qdrant/js-client-rest": "1.14.1",
|
|
@@ -222,14 +224,14 @@
|
|
|
222
224
|
"weaviate-client": "3.6.2",
|
|
223
225
|
"zod": "3.25.67",
|
|
224
226
|
"zod-to-json-schema": "3.23.3",
|
|
225
|
-
"@n8n/client-oauth2": "0.
|
|
226
|
-
"@n8n/config": "1.60.0",
|
|
227
|
+
"@n8n/client-oauth2": "0.31.0",
|
|
227
228
|
"@n8n/di": "0.9.0",
|
|
228
229
|
"@n8n/errors": "^0.5.0",
|
|
229
|
-
"@n8n/
|
|
230
|
+
"@n8n/config": "1.62.0",
|
|
230
231
|
"@n8n/typescript-config": "1.3.0",
|
|
231
|
-
"n8n-
|
|
232
|
-
"n8n-
|
|
232
|
+
"@n8n/json-schema-to-zod": "1.5.0",
|
|
233
|
+
"n8n-workflow": "1.117.0",
|
|
234
|
+
"n8n-nodes-base": "1.118.0"
|
|
233
235
|
},
|
|
234
236
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
235
237
|
"homepage": "https://n8n.io",
|