@n8n/n8n-nodes-langchain 1.105.3 → 1.106.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.
Files changed (32) hide show
  1. package/dist/credentials/HuggingFaceApi.credentials.js +2 -2
  2. package/dist/credentials/HuggingFaceApi.credentials.js.map +1 -1
  3. package/dist/credentials/OllamaApi.credentials.js +18 -1
  4. package/dist/credentials/OllamaApi.credentials.js.map +1 -1
  5. package/dist/nodes/agents/Agent/V1/AgentV1.node.js +14 -0
  6. package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -1
  7. package/dist/nodes/agents/Agent/V2/AgentV2.node.js +14 -0
  8. package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
  9. package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js +14 -0
  10. package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js.map +1 -1
  11. package/dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js +5 -1
  12. package/dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js.map +1 -1
  13. package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js +5 -1
  14. package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js.map +1 -1
  15. package/dist/nodes/llms/LMOllama/LmOllama.node.js +5 -1
  16. package/dist/nodes/llms/LMOllama/LmOllama.node.js.map +1 -1
  17. package/dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js +1 -1
  18. package/dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js.map +1 -1
  19. package/dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js +10 -1
  20. package/dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js.map +1 -1
  21. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +34 -4
  22. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
  23. package/dist/nodes/trigger/ChatTrigger/templates.js +31 -4
  24. package/dist/nodes/trigger/ChatTrigger/templates.js.map +1 -1
  25. package/dist/nodes/trigger/ChatTrigger/types.js +21 -0
  26. package/dist/nodes/trigger/ChatTrigger/types.js.map +1 -1
  27. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +2 -1
  28. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -1
  29. package/dist/types/credentials.json +2 -2
  30. package/dist/types/nodes.json +14 -14
  31. package/dist/utils/N8nBinaryLoader.js.map +1 -1
  32. package/package.json +7 -7
@@ -36,6 +36,7 @@ var import_n8n_workflow = require("n8n-workflow");
36
36
  var import_constants = require("./constants");
37
37
  var import_GenericFunctions = require("./GenericFunctions");
38
38
  var import_templates = require("./templates");
39
+ var import_types = require("./types");
39
40
  const CHAT_TRIGGER_PATH_IDENTIFIER = "chat";
40
41
  const allowFileUploadsOption = {
41
42
  displayName: "Allow File Uploads",
@@ -576,7 +577,9 @@ class ChatTrigger extends import_n8n_workflow.Node {
576
577
  async webhook(ctx) {
577
578
  const res = ctx.getResponseObject();
578
579
  const isPublic = ctx.getNodeParameter("public", false);
580
+ (0, import_n8n_workflow.assertParamIsBoolean)("public", isPublic, ctx.getNode());
579
581
  const nodeMode = ctx.getNodeParameter("mode", "hostedChat");
582
+ (0, import_n8n_workflow.assertParamIsString)("mode", nodeMode, ctx.getNode());
580
583
  if (!isPublic) {
581
584
  res.status(404).end();
582
585
  return {
@@ -584,6 +587,24 @@ class ChatTrigger extends import_n8n_workflow.Node {
584
587
  };
585
588
  }
586
589
  const options = ctx.getNodeParameter("options", {});
590
+ (0, import_n8n_workflow.validateNodeParameters)(
591
+ options,
592
+ {
593
+ getStarted: { type: "string" },
594
+ inputPlaceholder: { type: "string" },
595
+ loadPreviousSession: { type: "string" },
596
+ showWelcomeScreen: { type: "boolean" },
597
+ subtitle: { type: "string" },
598
+ title: { type: "string" },
599
+ allowFileUploads: { type: "boolean" },
600
+ allowedFilesMimeTypes: { type: "string" },
601
+ customCss: { type: "string" },
602
+ responseMode: { type: "string" }
603
+ },
604
+ ctx.getNode()
605
+ );
606
+ const loadPreviousSession = options.loadPreviousSession;
607
+ (0, import_types.assertValidLoadPreviousSessionOption)(loadPreviousSession, ctx.getNode());
587
608
  const enableStreaming = options.responseMode === "streaming";
588
609
  const req = ctx.getRequestObject();
589
610
  const webhookName = ctx.getWebhookName();
@@ -604,19 +625,28 @@ class ChatTrigger extends import_n8n_workflow.Node {
604
625
  if (nodeMode === "hostedChat") {
605
626
  if (webhookName === "setup") {
606
627
  const webhookUrlRaw = ctx.getNodeWebhookUrl("default");
628
+ if (!webhookUrlRaw) {
629
+ throw new import_n8n_workflow.NodeOperationError(ctx.getNode(), "Default webhook url not set");
630
+ }
607
631
  const webhookUrl = mode === "test" ? webhookUrlRaw.replace("/webhook", "/webhook-test") : webhookUrlRaw;
608
632
  const authentication = ctx.getNodeParameter("authentication");
609
633
  const initialMessagesRaw = ctx.getNodeParameter("initialMessages", "");
610
- const initialMessages = initialMessagesRaw.split("\n").filter((line) => line).map((line) => line.trim());
634
+ (0, import_n8n_workflow.assertParamIsString)("initialMessage", initialMessagesRaw, ctx.getNode());
611
635
  const instanceId = ctx.getInstanceId();
612
- const i18nConfig = (0, import_pick.default)(options, ["getStarted", "inputPlaceholder", "subtitle", "title"]);
636
+ const i18nConfig = {};
637
+ const keys = ["getStarted", "inputPlaceholder", "subtitle", "title"];
638
+ for (const key of keys) {
639
+ if (options[key] !== void 0) {
640
+ i18nConfig[key] = options[key];
641
+ }
642
+ }
613
643
  const page = (0, import_templates.createPage)({
614
644
  i18n: {
615
645
  en: i18nConfig
616
646
  },
617
647
  showWelcomeScreen: options.showWelcomeScreen,
618
- loadPreviousSession: options.loadPreviousSession,
619
- initialMessages,
648
+ loadPreviousSession,
649
+ initialMessages: initialMessagesRaw,
620
650
  webhookUrl,
621
651
  mode,
622
652
  instanceId,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/ChatTrigger.node.ts"],"sourcesContent":["import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';\nimport pick from 'lodash/pick';\nimport { Node, NodeConnectionTypes } from 'n8n-workflow';\nimport type {\n\tIDataObject,\n\tIWebhookFunctions,\n\tIWebhookResponseData,\n\tINodeTypeDescription,\n\tMultiPartFormData,\n\tINodeExecutionData,\n\tIBinaryData,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nimport { cssVariables } from './constants';\nimport { validateAuth } from './GenericFunctions';\nimport { createPage } from './templates';\nimport type { LoadPreviousSessionChatOption } from './types';\n\nconst CHAT_TRIGGER_PATH_IDENTIFIER = 'chat';\nconst allowFileUploadsOption: INodeProperties = {\n\tdisplayName: 'Allow File Uploads',\n\tname: 'allowFileUploads',\n\ttype: 'boolean',\n\tdefault: false,\n\tdescription: 'Whether to allow file uploads in the chat',\n};\nconst allowedFileMimeTypeOption: INodeProperties = {\n\tdisplayName: 'Allowed File Mime Types',\n\tname: 'allowedFilesMimeTypes',\n\ttype: 'string',\n\tdefault: '*',\n\tplaceholder: 'e.g. image/*, text/*, application/pdf',\n\tdescription:\n\t\t'Allowed file types for upload. Comma-separated list of <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\" target=\"_blank\">MIME types</a>.',\n};\n\nconst respondToWebhookResponseMode = {\n\tname: \"Using 'Respond to Webhook' Node\",\n\tvalue: 'responseNode',\n\tdescription: 'Response defined in that node',\n};\n\nconst lastNodeResponseMode = {\n\tname: 'When Last Node Finishes',\n\tvalue: 'lastNode',\n\tdescription: 'Returns data of the last-executed node',\n};\n\nconst streamingResponseMode = {\n\tname: 'Streaming',\n\tvalue: 'streaming',\n\tdescription: 'Streaming response from specified nodes (e.g. Agents)',\n};\n\nconst respondNodesResponseMode = {\n\tname: 'Using Response Nodes',\n\tvalue: 'responseNodes',\n\tdescription:\n\t\t\"Send responses to the chat by using 'Respond to Chat' or 'Respond to Webhook' nodes\",\n};\n\nconst commonOptionsFields: INodeProperties[] = [\n\t// CORS parameters are only valid for when chat is used in hosted or webhook mode\n\t{\n\t\tdisplayName: 'Allowed Origins (CORS)',\n\t\tname: 'allowedOrigins',\n\t\ttype: 'string',\n\t\tdefault: '*',\n\t\tdescription:\n\t\t\t'Comma-separated list of URLs allowed for cross-origin non-preflight requests. Use * (default) to allow all origins.',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat', 'webhook'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\t...allowFileUploadsOption,\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\t...allowedFileMimeTypeOption,\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Input Placeholder',\n\t\tname: 'inputPlaceholder',\n\t\ttype: 'string',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: 'Type your question..',\n\t\tplaceholder: 'e.g. Type your message here',\n\t\tdescription: 'Shown as placeholder text in the chat input field',\n\t},\n\t{\n\t\tdisplayName: 'Load Previous Session',\n\t\tname: 'loadPreviousSession',\n\t\ttype: 'options',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Off',\n\t\t\t\tvalue: 'notSupported',\n\t\t\t\tdescription: 'Loading messages of previous session is turned off',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'From Memory',\n\t\t\t\tvalue: 'memory',\n\t\t\t\tdescription: 'Load session messages from memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Manually',\n\t\t\t\tvalue: 'manually',\n\t\t\t\tdescription: 'Manually return messages of session',\n\t\t\t},\n\t\t],\n\t\tdefault: 'notSupported',\n\t\tdescription: 'If loading messages of a previous session should be enabled',\n\t},\n\t{\n\t\tdisplayName: 'Require Button Click to Start Chat',\n\t\tname: 'showWelcomeScreen',\n\t\ttype: 'boolean',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: false,\n\t\tdescription: 'Whether to show the welcome screen at the start of the chat',\n\t},\n\t{\n\t\tdisplayName: 'Start Conversation Button Text',\n\t\tname: 'getStarted',\n\t\ttype: 'string',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tshowWelcomeScreen: [true],\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: 'New Conversation',\n\t\tplaceholder: 'e.g. New Conversation',\n\t\tdescription: 'Shown as part of the welcome screen, in the middle of the chat window',\n\t},\n\t{\n\t\tdisplayName: 'Subtitle',\n\t\tname: 'subtitle',\n\t\ttype: 'string',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: \"Start a chat. We're here to help you 24/7.\",\n\t\tplaceholder: \"e.g. We're here for you\",\n\t\tdescription: 'Shown at the top of the chat, under the title',\n\t},\n\t{\n\t\tdisplayName: 'Title',\n\t\tname: 'title',\n\t\ttype: 'string',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: 'Hi there! 👋',\n\t\tplaceholder: 'e.g. Welcome',\n\t\tdescription: 'Shown at the top of the chat',\n\t},\n\t{\n\t\tdisplayName: 'Custom Chat Styling',\n\t\tname: 'customCss',\n\t\ttype: 'string',\n\t\ttypeOptions: {\n\t\t\trows: 10,\n\t\t\teditor: 'cssEditor',\n\t\t},\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: `\n${cssVariables}\n\n/* You can override any class styles, too. Right-click inspect in Chat UI to find class to override. */\n.chat-message {\n\tmax-width: 50%;\n}\n`.trim(),\n\t\tdescription: 'Override default styling of the public chat interface with CSS',\n\t},\n];\n\nexport class ChatTrigger extends Node {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Chat Trigger',\n\t\tname: 'chatTrigger',\n\t\ticon: 'fa:comments',\n\t\ticonColor: 'black',\n\t\tgroup: ['trigger'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdefaultVersion: 1.3,\n\t\tdescription: 'Runs the workflow when an n8n generated webchat is submitted',\n\t\tdefaults: {\n\t\t\tname: 'When chat message received',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['Core Nodes'],\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/core-nodes/n8n-nodes-langchain.chattrigger/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tmaxNodes: 1,\n\t\tinputs: `={{ (() => {\n\t\t\tif (!['hostedChat', 'webhook'].includes($parameter.mode)) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tif ($parameter.options?.loadPreviousSession !== 'memory') {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Memory',\n\t\t\t\t\tmaxConnections: 1,\n\t\t\t\t\ttype: '${NodeConnectionTypes.AiMemory}',\n\t\t\t\t\trequired: true,\n\t\t\t\t}\n\t\t\t];\n\t\t })() }}`,\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed\n\t\t\t\tname: 'httpBasicAuth',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['basicAuth'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\twebhooks: [\n\t\t\t{\n\t\t\t\tname: 'setup',\n\t\t\t\thttpMethod: 'GET',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tpath: CHAT_TRIGGER_PATH_IDENTIFIER,\n\t\t\t\tndvHideUrl: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'POST',\n\t\t\t\tresponseMode: '={{$parameter.options?.[\"responseMode\"] || \"lastNode\" }}',\n\t\t\t\tpath: CHAT_TRIGGER_PATH_IDENTIFIER,\n\t\t\t\tndvHideMethod: true,\n\t\t\t\tndvHideUrl: '={{ !$parameter.public }}',\n\t\t\t},\n\t\t],\n\t\teventTriggerDescription: 'Waiting for you to submit the chat',\n\t\tactivationMessage: 'You can now make calls to your production chat URL.',\n\t\ttriggerPanel: false,\n\t\tproperties: [\n\t\t\t/**\n\t\t\t * @note If we change this property, also update it in ChatEmbedModal.vue\n\t\t\t */\n\t\t\t{\n\t\t\t\tdisplayName: 'Make Chat Publicly Available',\n\t\t\t\tname: 'public',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether the chat should be publicly available or only accessible through the manual chat interface',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Mode',\n\t\t\t\tname: 'mode',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Hosted Chat',\n\t\t\t\t\t\tvalue: 'hostedChat',\n\t\t\t\t\t\tdescription: 'Chat on a page served by n8n',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Embedded Chat',\n\t\t\t\t\t\tvalue: 'webhook',\n\t\t\t\t\t\tdescription: 'Chat through a widget embedded in another page, or by calling a webhook',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'hostedChat',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'Chat will be live at the URL above once you activate this workflow. Live executions will show up in the ‘executions’ tab',\n\t\t\t\tname: 'hostedChatNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'Follow the instructions <a href=\"https://www.npmjs.com/package/@n8n/chat\" target=\"_blank\">here</a> to embed chat in a webpage (or just call the webhook URL at the top of this section). Chat will be live once you activate this workflow',\n\t\t\t\tname: 'embeddedChatNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['webhook'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'options',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Basic Auth',\n\t\t\t\t\t\tvalue: 'basicAuth',\n\t\t\t\t\t\tdescription: 'Simple username and password (the same one for all users)',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\t\t\tname: 'n8n User Auth',\n\t\t\t\t\t\tvalue: 'n8nUserAuth',\n\t\t\t\t\t\tdescription: 'Require user to be logged in with their n8n account',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'None',\n\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription: 'The way to authenticate',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Initial Message(s)',\n\t\t\t\tname: 'initialMessages',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t\tdefault: 'Hi there! 👋\\nMy name is Nathan. How can I assist you today?',\n\t\t\t\tdescription: 'Default messages shown at the start of the chat, one per line',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tpublic: [false],\n\t\t\t\t\t\t'@version': [1, 1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [allowFileUploadsOption, allowedFileMimeTypeOption],\n\t\t\t},\n\t\t\t// Options for versions 1.0 and 1.1 (without streaming)\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat', 'webhook'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t\t'@version': [1, 1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t...commonOptionsFields,\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, respondToWebhookResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the webhook',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t// Options for version 1.2 (with streaming)\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat', 'webhook'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t\t'@version': [1.2],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t...commonOptionsFields,\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, respondToWebhookResponseMode, streamingResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the webhook',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tpublic: [false],\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\tallowFileUploadsOption,\n\t\t\t\t\tallowedFileMimeTypeOption,\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, respondNodesResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the chat',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat', 'webhook'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t...commonOptionsFields,\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, streamingResponseMode, respondToWebhookResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the chat',\n\t\t\t\t\t\tdisplayOptions: { show: { '/mode': ['webhook'] } },\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, streamingResponseMode, respondNodesResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the webhook',\n\t\t\t\t\t\tdisplayOptions: { show: { '/mode': ['hostedChat'] } },\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tprivate async handleFormData(context: IWebhookFunctions) {\n\t\tconst req = context.getRequestObject() as MultiPartFormData.Request;\n\t\tconst options = context.getNodeParameter('options', {}) as IDataObject;\n\t\tconst { data, files } = req.body;\n\n\t\tconst returnItem: INodeExecutionData = {\n\t\t\tjson: data,\n\t\t};\n\n\t\tif (files && Object.keys(files).length) {\n\t\t\treturnItem.json.files = [] as Array<Omit<IBinaryData, 'data'>>;\n\t\t\treturnItem.binary = {};\n\n\t\t\tconst count = 0;\n\t\t\tfor (const fileKey of Object.keys(files)) {\n\t\t\t\tconst processedFiles: MultiPartFormData.File[] = [];\n\t\t\t\tif (Array.isArray(files[fileKey])) {\n\t\t\t\t\tprocessedFiles.push(...files[fileKey]);\n\t\t\t\t} else {\n\t\t\t\t\tprocessedFiles.push(files[fileKey]);\n\t\t\t\t}\n\n\t\t\t\tlet fileIndex = 0;\n\t\t\t\tfor (const file of processedFiles) {\n\t\t\t\t\tlet binaryPropertyName = 'data';\n\n\t\t\t\t\t// Remove the '[]' suffix from the binaryPropertyName if it exists\n\t\t\t\t\tif (binaryPropertyName.endsWith('[]')) {\n\t\t\t\t\t\tbinaryPropertyName = binaryPropertyName.slice(0, -2);\n\t\t\t\t\t}\n\t\t\t\t\tif (options.binaryPropertyName) {\n\t\t\t\t\t\tbinaryPropertyName = `${options.binaryPropertyName.toString()}${count}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst binaryFile = await context.nodeHelpers.copyBinaryFile(\n\t\t\t\t\t\tfile.filepath,\n\t\t\t\t\t\tfile.originalFilename ?? file.newFilename,\n\t\t\t\t\t\tfile.mimetype,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst binaryKey = `${binaryPropertyName}${fileIndex}`;\n\n\t\t\t\t\tconst binaryInfo = {\n\t\t\t\t\t\t...pick(binaryFile, ['fileName', 'fileSize', 'fileType', 'mimeType', 'fileExtension']),\n\t\t\t\t\t\tbinaryKey,\n\t\t\t\t\t};\n\n\t\t\t\t\treturnItem.binary = Object.assign(returnItem.binary ?? {}, {\n\t\t\t\t\t\t[`${binaryKey}`]: binaryFile,\n\t\t\t\t\t});\n\t\t\t\t\treturnItem.json.files = [\n\t\t\t\t\t\t...(returnItem.json.files as Array<Omit<IBinaryData, 'data'>>),\n\t\t\t\t\t\tbinaryInfo,\n\t\t\t\t\t];\n\t\t\t\t\tfileIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn returnItem;\n\t}\n\n\tasync webhook(ctx: IWebhookFunctions): Promise<IWebhookResponseData> {\n\t\tconst res = ctx.getResponseObject();\n\n\t\tconst isPublic = ctx.getNodeParameter('public', false) as boolean;\n\t\tconst nodeMode = ctx.getNodeParameter('mode', 'hostedChat') as string;\n\t\tif (!isPublic) {\n\t\t\tres.status(404).end();\n\t\t\treturn {\n\t\t\t\tnoWebhookResponse: true,\n\t\t\t};\n\t\t}\n\n\t\tconst options = ctx.getNodeParameter('options', {}) as {\n\t\t\tgetStarted?: string;\n\t\t\tinputPlaceholder?: string;\n\t\t\tloadPreviousSession?: LoadPreviousSessionChatOption;\n\t\t\tshowWelcomeScreen?: boolean;\n\t\t\tsubtitle?: string;\n\t\t\ttitle?: string;\n\t\t\tallowFileUploads?: boolean;\n\t\t\tallowedFilesMimeTypes?: string;\n\t\t\tcustomCss?: string;\n\t\t\tresponseMode?: string;\n\t\t};\n\n\t\tconst enableStreaming = options.responseMode === 'streaming';\n\n\t\tconst req = ctx.getRequestObject();\n\t\tconst webhookName = ctx.getWebhookName();\n\t\tconst mode = ctx.getMode() === 'manual' ? 'test' : 'production';\n\t\tconst bodyData = ctx.getBodyData() ?? {};\n\n\t\ttry {\n\t\t\tawait validateAuth(ctx);\n\t\t} catch (error) {\n\t\t\tif (error) {\n\t\t\t\tres.writeHead((error as IDataObject).responseCode as number, {\n\t\t\t\t\t'www-authenticate': 'Basic realm=\"Webhook\"',\n\t\t\t\t});\n\t\t\t\tres.end((error as IDataObject).message as string);\n\t\t\t\treturn { noWebhookResponse: true };\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tif (nodeMode === 'hostedChat') {\n\t\t\t// Show the chat on GET request\n\t\t\tif (webhookName === 'setup') {\n\t\t\t\tconst webhookUrlRaw = ctx.getNodeWebhookUrl('default') as string;\n\t\t\t\tconst webhookUrl =\n\t\t\t\t\tmode === 'test' ? webhookUrlRaw.replace('/webhook', '/webhook-test') : webhookUrlRaw;\n\t\t\t\tconst authentication = ctx.getNodeParameter('authentication') as\n\t\t\t\t\t| 'none'\n\t\t\t\t\t| 'basicAuth'\n\t\t\t\t\t| 'n8nUserAuth';\n\t\t\t\tconst initialMessagesRaw = ctx.getNodeParameter('initialMessages', '') as string;\n\t\t\t\tconst initialMessages = initialMessagesRaw\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.filter((line) => line)\n\t\t\t\t\t.map((line) => line.trim());\n\t\t\t\tconst instanceId = ctx.getInstanceId();\n\n\t\t\t\tconst i18nConfig = pick(options, ['getStarted', 'inputPlaceholder', 'subtitle', 'title']);\n\n\t\t\t\tconst page = createPage({\n\t\t\t\t\ti18n: {\n\t\t\t\t\t\ten: i18nConfig,\n\t\t\t\t\t},\n\t\t\t\t\tshowWelcomeScreen: options.showWelcomeScreen,\n\t\t\t\t\tloadPreviousSession: options.loadPreviousSession,\n\t\t\t\t\tinitialMessages,\n\t\t\t\t\twebhookUrl,\n\t\t\t\t\tmode,\n\t\t\t\t\tinstanceId,\n\t\t\t\t\tauthentication,\n\t\t\t\t\tallowFileUploads: options.allowFileUploads,\n\t\t\t\t\tallowedFilesMimeTypes: options.allowedFilesMimeTypes,\n\t\t\t\t\tcustomCss: options.customCss,\n\t\t\t\t\tenableStreaming,\n\t\t\t\t});\n\n\t\t\t\tres.status(200).send(page).end();\n\t\t\t\treturn {\n\t\t\t\t\tnoWebhookResponse: true,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (bodyData.action === 'loadPreviousSession') {\n\t\t\tif (options?.loadPreviousSession === 'memory') {\n\t\t\t\tconst memory = (await ctx.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t\t| BaseChatMemory\n\t\t\t\t\t| undefined;\n\t\t\t\tconst messages = ((await memory?.chatHistory.getMessages()) ?? [])\n\t\t\t\t\t.filter((message) => !message?.additional_kwargs?.hideFromUI)\n\t\t\t\t\t.map((message) => message?.toJSON());\n\t\t\t\treturn {\n\t\t\t\t\twebhookResponse: { data: messages },\n\t\t\t\t};\n\t\t\t} else if (!options?.loadPreviousSession || options?.loadPreviousSession === 'notSupported') {\n\t\t\t\t// If messages of a previous session should not be loaded, simply return an empty array\n\t\t\t\treturn {\n\t\t\t\t\twebhookResponse: { data: [] },\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tlet returnData: INodeExecutionData[];\n\t\tconst webhookResponse: IDataObject = { status: 200 };\n\n\t\t// Handle streaming responses\n\t\tif (enableStreaming) {\n\t\t\t// Set up streaming response headers\n\t\t\tres.writeHead(200, {\n\t\t\t\t'Content-Type': 'application/json; charset=utf-8',\n\t\t\t\t'Transfer-Encoding': 'chunked',\n\t\t\t\t'Cache-Control': 'no-cache',\n\t\t\t\tConnection: 'keep-alive',\n\t\t\t});\n\n\t\t\t// Flush headers immediately\n\t\t\tres.flushHeaders();\n\n\t\t\tif (req.contentType === 'multipart/form-data') {\n\t\t\t\treturnData = [await this.handleFormData(ctx)];\n\t\t\t} else {\n\t\t\t\treturnData = [{ json: bodyData }];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tworkflowData: [ctx.helpers.returnJsonArray(returnData)],\n\t\t\t\tnoWebhookResponse: true,\n\t\t\t};\n\t\t}\n\n\t\tif (req.contentType === 'multipart/form-data') {\n\t\t\treturnData = [await this.handleFormData(ctx)];\n\t\t\treturn {\n\t\t\t\twebhookResponse,\n\t\t\t\tworkflowData: [returnData],\n\t\t\t};\n\t\t} else {\n\t\t\treturnData = [{ json: bodyData }];\n\t\t}\n\n\t\treturn {\n\t\t\twebhookResponse,\n\t\t\tworkflowData: [ctx.helpers.returnJsonArray(returnData)],\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAiB;AACjB,0BAA0C;AAY1C,uBAA6B;AAC7B,8BAA6B;AAC7B,uBAA2B;AAG3B,MAAM,+BAA+B;AACrC,MAAM,yBAA0C;AAAA,EAC/C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AACd;AACA,MAAM,4BAA6C;AAAA,EAClD,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,aAAa;AAAA,EACb,aACC;AACF;AAEA,MAAM,+BAA+B;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AACd;AAEA,MAAM,uBAAuB;AAAA,EAC5B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AACd;AAEA,MAAM,wBAAwB;AAAA,EAC7B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AACd;AAEA,MAAM,2BAA2B;AAAA,EAChC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aACC;AACF;AAEA,MAAM,sBAAyC;AAAA;AAAA,EAE9C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACC;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,SAAS,CAAC,cAAc,SAAS;AAAA,MAClC;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,GAAG;AAAA,IACH,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,SAAS,CAAC,YAAY;AAAA,MACvB;AAAA,IACD;AAAA,E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AAAA,MACpB;AAAA,IACD;AAEA,QAAI,IAAI,gBAAgB,uBAAuB;AAC9C,mBAAa,CAAC,MAAM,KAAK,eAAe,GAAG,CAAC;AAC5C,aAAO;AAAA,QACN;AAAA,QACA,cAAc,CAAC,UAAU;AAAA,MAC1B;AAAA,IACD,OAAO;AACN,mBAAa,CAAC,EAAE,MAAM,SAAS,CAAC;AAAA,IACjC;AAEA,WAAO;AAAA,MACN;AAAA,MACA,cAAc,CAAC,IAAI,QAAQ,gBAAgB,UAAU,CAAC;AAAA,IACvD;AAAA,EACD;AACD;","names":["pick"]}
1
+ {"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/ChatTrigger.node.ts"],"sourcesContent":["import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';\nimport pick from 'lodash/pick';\nimport {\n\tNode,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\tassertParamIsBoolean,\n\tvalidateNodeParameters,\n\tassertParamIsString,\n} from 'n8n-workflow';\nimport type {\n\tIDataObject,\n\tIWebhookFunctions,\n\tIWebhookResponseData,\n\tINodeTypeDescription,\n\tMultiPartFormData,\n\tINodeExecutionData,\n\tIBinaryData,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nimport { cssVariables } from './constants';\nimport { validateAuth } from './GenericFunctions';\nimport { createPage } from './templates';\nimport { assertValidLoadPreviousSessionOption } from './types';\n\nconst CHAT_TRIGGER_PATH_IDENTIFIER = 'chat';\nconst allowFileUploadsOption: INodeProperties = {\n\tdisplayName: 'Allow File Uploads',\n\tname: 'allowFileUploads',\n\ttype: 'boolean',\n\tdefault: false,\n\tdescription: 'Whether to allow file uploads in the chat',\n};\nconst allowedFileMimeTypeOption: INodeProperties = {\n\tdisplayName: 'Allowed File Mime Types',\n\tname: 'allowedFilesMimeTypes',\n\ttype: 'string',\n\tdefault: '*',\n\tplaceholder: 'e.g. image/*, text/*, application/pdf',\n\tdescription:\n\t\t'Allowed file types for upload. Comma-separated list of <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types\" target=\"_blank\">MIME types</a>.',\n};\n\nconst respondToWebhookResponseMode = {\n\tname: \"Using 'Respond to Webhook' Node\",\n\tvalue: 'responseNode',\n\tdescription: 'Response defined in that node',\n};\n\nconst lastNodeResponseMode = {\n\tname: 'When Last Node Finishes',\n\tvalue: 'lastNode',\n\tdescription: 'Returns data of the last-executed node',\n};\n\nconst streamingResponseMode = {\n\tname: 'Streaming',\n\tvalue: 'streaming',\n\tdescription: 'Streaming response from specified nodes (e.g. Agents)',\n};\n\nconst respondNodesResponseMode = {\n\tname: 'Using Response Nodes',\n\tvalue: 'responseNodes',\n\tdescription:\n\t\t\"Send responses to the chat by using 'Respond to Chat' or 'Respond to Webhook' nodes\",\n};\n\nconst commonOptionsFields: INodeProperties[] = [\n\t// CORS parameters are only valid for when chat is used in hosted or webhook mode\n\t{\n\t\tdisplayName: 'Allowed Origins (CORS)',\n\t\tname: 'allowedOrigins',\n\t\ttype: 'string',\n\t\tdefault: '*',\n\t\tdescription:\n\t\t\t'Comma-separated list of URLs allowed for cross-origin non-preflight requests. Use * (default) to allow all origins.',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat', 'webhook'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\t...allowFileUploadsOption,\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\t...allowedFileMimeTypeOption,\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Input Placeholder',\n\t\tname: 'inputPlaceholder',\n\t\ttype: 'string',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: 'Type your question..',\n\t\tplaceholder: 'e.g. Type your message here',\n\t\tdescription: 'Shown as placeholder text in the chat input field',\n\t},\n\t{\n\t\tdisplayName: 'Load Previous Session',\n\t\tname: 'loadPreviousSession',\n\t\ttype: 'options',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Off',\n\t\t\t\tvalue: 'notSupported',\n\t\t\t\tdescription: 'Loading messages of previous session is turned off',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'From Memory',\n\t\t\t\tvalue: 'memory',\n\t\t\t\tdescription: 'Load session messages from memory',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Manually',\n\t\t\t\tvalue: 'manually',\n\t\t\t\tdescription: 'Manually return messages of session',\n\t\t\t},\n\t\t],\n\t\tdefault: 'notSupported',\n\t\tdescription: 'If loading messages of a previous session should be enabled',\n\t},\n\t{\n\t\tdisplayName: 'Require Button Click to Start Chat',\n\t\tname: 'showWelcomeScreen',\n\t\ttype: 'boolean',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: false,\n\t\tdescription: 'Whether to show the welcome screen at the start of the chat',\n\t},\n\t{\n\t\tdisplayName: 'Start Conversation Button Text',\n\t\tname: 'getStarted',\n\t\ttype: 'string',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tshowWelcomeScreen: [true],\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: 'New Conversation',\n\t\tplaceholder: 'e.g. New Conversation',\n\t\tdescription: 'Shown as part of the welcome screen, in the middle of the chat window',\n\t},\n\t{\n\t\tdisplayName: 'Subtitle',\n\t\tname: 'subtitle',\n\t\ttype: 'string',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: \"Start a chat. We're here to help you 24/7.\",\n\t\tplaceholder: \"e.g. We're here for you\",\n\t\tdescription: 'Shown at the top of the chat, under the title',\n\t},\n\t{\n\t\tdisplayName: 'Title',\n\t\tname: 'title',\n\t\ttype: 'string',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: 'Hi there! 👋',\n\t\tplaceholder: 'e.g. Welcome',\n\t\tdescription: 'Shown at the top of the chat',\n\t},\n\t{\n\t\tdisplayName: 'Custom Chat Styling',\n\t\tname: 'customCss',\n\t\ttype: 'string',\n\t\ttypeOptions: {\n\t\t\trows: 10,\n\t\t\teditor: 'cssEditor',\n\t\t},\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t},\n\t\t},\n\t\tdefault: `\n${cssVariables}\n\n/* You can override any class styles, too. Right-click inspect in Chat UI to find class to override. */\n.chat-message {\n\tmax-width: 50%;\n}\n`.trim(),\n\t\tdescription: 'Override default styling of the public chat interface with CSS',\n\t},\n];\n\nexport class ChatTrigger extends Node {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Chat Trigger',\n\t\tname: 'chatTrigger',\n\t\ticon: 'fa:comments',\n\t\ticonColor: 'black',\n\t\tgroup: ['trigger'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdefaultVersion: 1.3,\n\t\tdescription: 'Runs the workflow when an n8n generated webchat is submitted',\n\t\tdefaults: {\n\t\t\tname: 'When chat message received',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['Core Nodes'],\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/core-nodes/n8n-nodes-langchain.chattrigger/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tmaxNodes: 1,\n\t\tinputs: `={{ (() => {\n\t\t\tif (!['hostedChat', 'webhook'].includes($parameter.mode)) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tif ($parameter.options?.loadPreviousSession !== 'memory') {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Memory',\n\t\t\t\t\tmaxConnections: 1,\n\t\t\t\t\ttype: '${NodeConnectionTypes.AiMemory}',\n\t\t\t\t\trequired: true,\n\t\t\t\t}\n\t\t\t];\n\t\t })() }}`,\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-credentials-name-unsuffixed\n\t\t\t\tname: 'httpBasicAuth',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['basicAuth'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\twebhooks: [\n\t\t\t{\n\t\t\t\tname: 'setup',\n\t\t\t\thttpMethod: 'GET',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tpath: CHAT_TRIGGER_PATH_IDENTIFIER,\n\t\t\t\tndvHideUrl: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'POST',\n\t\t\t\tresponseMode: '={{$parameter.options?.[\"responseMode\"] || \"lastNode\" }}',\n\t\t\t\tpath: CHAT_TRIGGER_PATH_IDENTIFIER,\n\t\t\t\tndvHideMethod: true,\n\t\t\t\tndvHideUrl: '={{ !$parameter.public }}',\n\t\t\t},\n\t\t],\n\t\teventTriggerDescription: 'Waiting for you to submit the chat',\n\t\tactivationMessage: 'You can now make calls to your production chat URL.',\n\t\ttriggerPanel: false,\n\t\tproperties: [\n\t\t\t/**\n\t\t\t * @note If we change this property, also update it in ChatEmbedModal.vue\n\t\t\t */\n\t\t\t{\n\t\t\t\tdisplayName: 'Make Chat Publicly Available',\n\t\t\t\tname: 'public',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether the chat should be publicly available or only accessible through the manual chat interface',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Mode',\n\t\t\t\tname: 'mode',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Hosted Chat',\n\t\t\t\t\t\tvalue: 'hostedChat',\n\t\t\t\t\t\tdescription: 'Chat on a page served by n8n',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Embedded Chat',\n\t\t\t\t\t\tvalue: 'webhook',\n\t\t\t\t\t\tdescription: 'Chat through a widget embedded in another page, or by calling a webhook',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'hostedChat',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'Chat will be live at the URL above once you activate this workflow. Live executions will show up in the ‘executions’ tab',\n\t\t\t\tname: 'hostedChatNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'Follow the instructions <a href=\"https://www.npmjs.com/package/@n8n/chat\" target=\"_blank\">here</a> to embed chat in a webpage (or just call the webhook URL at the top of this section). Chat will be live once you activate this workflow',\n\t\t\t\tname: 'embeddedChatNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['webhook'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'options',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Basic Auth',\n\t\t\t\t\t\tvalue: 'basicAuth',\n\t\t\t\t\t\tdescription: 'Simple username and password (the same one for all users)',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\t\t\tname: 'n8n User Auth',\n\t\t\t\t\t\tvalue: 'n8nUserAuth',\n\t\t\t\t\t\tdescription: 'Require user to be logged in with their n8n account',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'None',\n\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription: 'The way to authenticate',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Initial Message(s)',\n\t\t\t\tname: 'initialMessages',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 3,\n\t\t\t\t},\n\t\t\t\tdefault: 'Hi there! 👋\\nMy name is Nathan. How can I assist you today?',\n\t\t\t\tdescription: 'Default messages shown at the start of the chat, one per line',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tpublic: [false],\n\t\t\t\t\t\t'@version': [1, 1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [allowFileUploadsOption, allowedFileMimeTypeOption],\n\t\t\t},\n\t\t\t// Options for versions 1.0 and 1.1 (without streaming)\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat', 'webhook'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t\t'@version': [1, 1.1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t...commonOptionsFields,\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, respondToWebhookResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the webhook',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t// Options for version 1.2 (with streaming)\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat', 'webhook'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t\t'@version': [1.2],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t...commonOptionsFields,\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, respondToWebhookResponseMode, streamingResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the webhook',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tpublic: [false],\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\tallowFileUploadsOption,\n\t\t\t\t\tallowedFileMimeTypeOption,\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, respondNodesResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the chat',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tmode: ['hostedChat', 'webhook'],\n\t\t\t\t\t\tpublic: [true],\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tplaceholder: 'Add Field',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t...commonOptionsFields,\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, streamingResponseMode, respondToWebhookResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the chat',\n\t\t\t\t\t\tdisplayOptions: { show: { '/mode': ['webhook'] } },\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Response Mode',\n\t\t\t\t\t\tname: 'responseMode',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [lastNodeResponseMode, streamingResponseMode, respondNodesResponseMode],\n\t\t\t\t\t\tdefault: 'lastNode',\n\t\t\t\t\t\tdescription: 'When and how to respond to the webhook',\n\t\t\t\t\t\tdisplayOptions: { show: { '/mode': ['hostedChat'] } },\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tprivate async handleFormData(context: IWebhookFunctions) {\n\t\tconst req = context.getRequestObject() as MultiPartFormData.Request;\n\t\tconst options = context.getNodeParameter('options', {}) as IDataObject;\n\t\tconst { data, files } = req.body;\n\n\t\tconst returnItem: INodeExecutionData = {\n\t\t\tjson: data,\n\t\t};\n\n\t\tif (files && Object.keys(files).length) {\n\t\t\treturnItem.json.files = [] as Array<Omit<IBinaryData, 'data'>>;\n\t\t\treturnItem.binary = {};\n\n\t\t\tconst count = 0;\n\t\t\tfor (const fileKey of Object.keys(files)) {\n\t\t\t\tconst processedFiles: MultiPartFormData.File[] = [];\n\t\t\t\tif (Array.isArray(files[fileKey])) {\n\t\t\t\t\tprocessedFiles.push(...files[fileKey]);\n\t\t\t\t} else {\n\t\t\t\t\tprocessedFiles.push(files[fileKey]);\n\t\t\t\t}\n\n\t\t\t\tlet fileIndex = 0;\n\t\t\t\tfor (const file of processedFiles) {\n\t\t\t\t\tlet binaryPropertyName = 'data';\n\n\t\t\t\t\t// Remove the '[]' suffix from the binaryPropertyName if it exists\n\t\t\t\t\tif (binaryPropertyName.endsWith('[]')) {\n\t\t\t\t\t\tbinaryPropertyName = binaryPropertyName.slice(0, -2);\n\t\t\t\t\t}\n\t\t\t\t\tif (options.binaryPropertyName) {\n\t\t\t\t\t\tbinaryPropertyName = `${options.binaryPropertyName.toString()}${count}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst binaryFile = await context.nodeHelpers.copyBinaryFile(\n\t\t\t\t\t\tfile.filepath,\n\t\t\t\t\t\tfile.originalFilename ?? file.newFilename,\n\t\t\t\t\t\tfile.mimetype,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst binaryKey = `${binaryPropertyName}${fileIndex}`;\n\n\t\t\t\t\tconst binaryInfo = {\n\t\t\t\t\t\t...pick(binaryFile, ['fileName', 'fileSize', 'fileType', 'mimeType', 'fileExtension']),\n\t\t\t\t\t\tbinaryKey,\n\t\t\t\t\t};\n\n\t\t\t\t\treturnItem.binary = Object.assign(returnItem.binary ?? {}, {\n\t\t\t\t\t\t[`${binaryKey}`]: binaryFile,\n\t\t\t\t\t});\n\t\t\t\t\treturnItem.json.files = [\n\t\t\t\t\t\t...(returnItem.json.files as Array<Omit<IBinaryData, 'data'>>),\n\t\t\t\t\t\tbinaryInfo,\n\t\t\t\t\t];\n\t\t\t\t\tfileIndex += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn returnItem;\n\t}\n\n\tasync webhook(ctx: IWebhookFunctions): Promise<IWebhookResponseData> {\n\t\tconst res = ctx.getResponseObject();\n\n\t\tconst isPublic = ctx.getNodeParameter('public', false);\n\t\tassertParamIsBoolean('public', isPublic, ctx.getNode());\n\n\t\tconst nodeMode = ctx.getNodeParameter('mode', 'hostedChat');\n\t\tassertParamIsString('mode', nodeMode, ctx.getNode());\n\n\t\tif (!isPublic) {\n\t\t\tres.status(404).end();\n\t\t\treturn {\n\t\t\t\tnoWebhookResponse: true,\n\t\t\t};\n\t\t}\n\n\t\tconst options = ctx.getNodeParameter('options', {});\n\t\tvalidateNodeParameters(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\tgetStarted: { type: 'string' },\n\t\t\t\tinputPlaceholder: { type: 'string' },\n\t\t\t\tloadPreviousSession: { type: 'string' },\n\t\t\t\tshowWelcomeScreen: { type: 'boolean' },\n\t\t\t\tsubtitle: { type: 'string' },\n\t\t\t\ttitle: { type: 'string' },\n\t\t\t\tallowFileUploads: { type: 'boolean' },\n\t\t\t\tallowedFilesMimeTypes: { type: 'string' },\n\t\t\t\tcustomCss: { type: 'string' },\n\t\t\t\tresponseMode: { type: 'string' },\n\t\t\t},\n\t\t\tctx.getNode(),\n\t\t);\n\n\t\tconst loadPreviousSession = options.loadPreviousSession;\n\t\tassertValidLoadPreviousSessionOption(loadPreviousSession, ctx.getNode());\n\n\t\tconst enableStreaming = options.responseMode === 'streaming';\n\n\t\tconst req = ctx.getRequestObject();\n\t\tconst webhookName = ctx.getWebhookName();\n\t\tconst mode = ctx.getMode() === 'manual' ? 'test' : 'production';\n\t\tconst bodyData = ctx.getBodyData() ?? {};\n\n\t\ttry {\n\t\t\tawait validateAuth(ctx);\n\t\t} catch (error) {\n\t\t\tif (error) {\n\t\t\t\tres.writeHead((error as IDataObject).responseCode as number, {\n\t\t\t\t\t'www-authenticate': 'Basic realm=\"Webhook\"',\n\t\t\t\t});\n\t\t\t\tres.end((error as IDataObject).message as string);\n\t\t\t\treturn { noWebhookResponse: true };\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tif (nodeMode === 'hostedChat') {\n\t\t\t// Show the chat on GET request\n\t\t\tif (webhookName === 'setup') {\n\t\t\t\tconst webhookUrlRaw = ctx.getNodeWebhookUrl('default');\n\t\t\t\tif (!webhookUrlRaw) {\n\t\t\t\t\tthrow new NodeOperationError(ctx.getNode(), 'Default webhook url not set');\n\t\t\t\t}\n\n\t\t\t\tconst webhookUrl =\n\t\t\t\t\tmode === 'test' ? webhookUrlRaw.replace('/webhook', '/webhook-test') : webhookUrlRaw;\n\t\t\t\tconst authentication = ctx.getNodeParameter('authentication') as\n\t\t\t\t\t| 'none'\n\t\t\t\t\t| 'basicAuth'\n\t\t\t\t\t| 'n8nUserAuth';\n\t\t\t\tconst initialMessagesRaw = ctx.getNodeParameter('initialMessages', '');\n\t\t\t\tassertParamIsString('initialMessage', initialMessagesRaw, ctx.getNode());\n\t\t\t\tconst instanceId = ctx.getInstanceId();\n\n\t\t\t\tconst i18nConfig: Record<string, string> = {};\n\t\t\t\tconst keys = ['getStarted', 'inputPlaceholder', 'subtitle', 'title'] as const;\n\t\t\t\tfor (const key of keys) {\n\t\t\t\t\tif (options[key] !== undefined) {\n\t\t\t\t\t\ti18nConfig[key] = options[key];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst page = createPage({\n\t\t\t\t\ti18n: {\n\t\t\t\t\t\ten: i18nConfig,\n\t\t\t\t\t},\n\t\t\t\t\tshowWelcomeScreen: options.showWelcomeScreen,\n\t\t\t\t\tloadPreviousSession,\n\t\t\t\t\tinitialMessages: initialMessagesRaw,\n\t\t\t\t\twebhookUrl,\n\t\t\t\t\tmode,\n\t\t\t\t\tinstanceId,\n\t\t\t\t\tauthentication,\n\t\t\t\t\tallowFileUploads: options.allowFileUploads,\n\t\t\t\t\tallowedFilesMimeTypes: options.allowedFilesMimeTypes,\n\t\t\t\t\tcustomCss: options.customCss,\n\t\t\t\t\tenableStreaming,\n\t\t\t\t});\n\n\t\t\t\tres.status(200).send(page).end();\n\t\t\t\treturn {\n\t\t\t\t\tnoWebhookResponse: true,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (bodyData.action === 'loadPreviousSession') {\n\t\t\tif (options?.loadPreviousSession === 'memory') {\n\t\t\t\tconst memory = (await ctx.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t\t| BaseChatMemory\n\t\t\t\t\t| undefined;\n\t\t\t\tconst messages = ((await memory?.chatHistory.getMessages()) ?? [])\n\t\t\t\t\t.filter((message) => !message?.additional_kwargs?.hideFromUI)\n\t\t\t\t\t.map((message) => message?.toJSON());\n\t\t\t\treturn {\n\t\t\t\t\twebhookResponse: { data: messages },\n\t\t\t\t};\n\t\t\t} else if (!options?.loadPreviousSession || options?.loadPreviousSession === 'notSupported') {\n\t\t\t\t// If messages of a previous session should not be loaded, simply return an empty array\n\t\t\t\treturn {\n\t\t\t\t\twebhookResponse: { data: [] },\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tlet returnData: INodeExecutionData[];\n\t\tconst webhookResponse: IDataObject = { status: 200 };\n\n\t\t// Handle streaming responses\n\t\tif (enableStreaming) {\n\t\t\t// Set up streaming response headers\n\t\t\tres.writeHead(200, {\n\t\t\t\t'Content-Type': 'application/json; charset=utf-8',\n\t\t\t\t'Transfer-Encoding': 'chunked',\n\t\t\t\t'Cache-Control': 'no-cache',\n\t\t\t\tConnection: 'keep-alive',\n\t\t\t});\n\n\t\t\t// Flush headers immediately\n\t\t\tres.flushHeaders();\n\n\t\t\tif (req.contentType === 'multipart/form-data') {\n\t\t\t\treturnData = [await this.handleFormData(ctx)];\n\t\t\t} else {\n\t\t\t\treturnData = [{ json: bodyData }];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tworkflowData: [ctx.helpers.returnJsonArray(returnData)],\n\t\t\t\tnoWebhookResponse: true,\n\t\t\t};\n\t\t}\n\n\t\tif (req.contentType === 'multipart/form-data') {\n\t\t\treturnData = [await this.handleFormData(ctx)];\n\t\t\treturn {\n\t\t\t\twebhookResponse,\n\t\t\t\tworkflowData: [returnData],\n\t\t\t};\n\t\t} else {\n\t\t\treturnData = [{ json: bodyData }];\n\t\t}\n\n\t\treturn {\n\t\t\twebhookResponse,\n\t\t\tworkflowData: [ctx.helpers.returnJsonArray(returnData)],\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAiB;AACjB,0BAOO;AAYP,uBAA6B;AAC7B,8BAA6B;AAC7B,uBAA2B;AAC3B,mBAAqD;AAErD,MAAM,+BAA+B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,EAAE,QAAQ,IAAI;AAGnD,QAAI,iBAAiB;AAEpB,UAAI,UAAU,KAAK;AAAA,QAClB,gBAAgB;AAAA,QAChB,qBAAqB;AAAA,QACrB,iBAAiB;AAAA,QACjB,YAAY;AAAA,MACb,CAAC;AAGD,UAAI,aAAa;AAEjB,UAAI,IAAI,gBAAgB,uBAAuB;AAC9C,qBAAa,CAAC,MAAM,KAAK,eAAe,GAAG,CAAC;AAAA,MAC7C,OAAO;AACN,qBAAa,CAAC,EAAE,MAAM,SAAS,CAAC;AAAA,MACjC;AAEA,aAAO;AAAA,QACN,cAAc,CAAC,IAAI,QAAQ,gBAAgB,UAAU,CAAC;AAAA,QACtD,mBAAmB;AAAA,MACpB;AAAA,IACD;AAEA,QAAI,IAAI,gBAAgB,uBAAuB;AAC9C,mBAAa,CAAC,MAAM,KAAK,eAAe,GAAG,CAAC;AAC5C,aAAO;AAAA,QACN;AAAA,QACA,cAAc,CAAC,UAAU;AAAA,MAC1B;AAAA,IACD,OAAO;AACN,mBAAa,CAAC,EAAE,MAAM,SAAS,CAAC;AAAA,IACjC;AAEA,WAAO;AAAA,MACN;AAAA,MACA,cAAc,CAAC,IAAI,QAAQ,gBAAgB,UAAU,CAAC;AAAA,IACvD;AAAA,EACD;AACD;","names":["pick"]}
@@ -28,10 +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 templates_exports = {};
30
30
  __export(templates_exports, {
31
- createPage: () => createPage
31
+ createPage: () => createPage,
32
+ getSanitizedI18nConfig: () => getSanitizedI18nConfig,
33
+ getSanitizedInitialMessages: () => getSanitizedInitialMessages
32
34
  });
33
35
  module.exports = __toCommonJS(templates_exports);
34
36
  var import_sanitize_html = __toESM(require("sanitize-html"));
37
+ function sanitizeUserInput(input) {
38
+ let sanitized = (0, import_sanitize_html.default)(input, {
39
+ allowedTags: [],
40
+ allowedAttributes: {}
41
+ });
42
+ sanitized = sanitized.replace(/javascript:/gi, "");
43
+ sanitized = sanitized.replace(/data:/gi, "");
44
+ sanitized = sanitized.replace(/vbscript:/gi, "");
45
+ return sanitized;
46
+ }
47
+ function getSanitizedInitialMessages(initialMessages) {
48
+ const sanitizedString = sanitizeUserInput(initialMessages);
49
+ return sanitizedString.split("\n").map((line) => line.trim()).filter((line) => line !== "");
50
+ }
51
+ function getSanitizedI18nConfig(config) {
52
+ const sanitized = {};
53
+ for (const [key, value] of Object.entries(config)) {
54
+ sanitized[key] = sanitizeUserInput(value);
55
+ }
56
+ return sanitized;
57
+ }
35
58
  function createPage({
36
59
  instanceId,
37
60
  webhookUrl,
@@ -66,6 +89,8 @@ function createPage({
66
89
  const sanitizedLoadPreviousSession = validLoadPreviousSessionOptions.includes(
67
90
  loadPreviousSession
68
91
  ) ? loadPreviousSession : "notSupported";
92
+ const sanitizedInitialMessages = getSanitizedInitialMessages(initialMessages);
93
+ const sanitizedI18nConfig = getSanitizedI18nConfig(en || {});
69
94
  return `<!doctype html>
70
95
  <html lang="en">
71
96
  <head>
@@ -132,9 +157,9 @@ function createPage({
132
157
  allowFileUploads: ${sanitizedAllowFileUploads},
133
158
  allowedFilesMimeTypes: '${sanitizedAllowedFilesMimeTypes}',
134
159
  i18n: {
135
- ${en ? `en: ${JSON.stringify(en)},` : ""}
160
+ ${Object.keys(sanitizedI18nConfig).length ? `en: ${JSON.stringify(sanitizedI18nConfig)},` : ""}
136
161
  },
137
- ${initialMessages.length ? `initialMessages: ${JSON.stringify(initialMessages)},` : ""}
162
+ ${sanitizedInitialMessages.length ? `initialMessages: ${JSON.stringify(sanitizedInitialMessages)},` : ""}
138
163
  enableStreaming: ${!!enableStreaming},
139
164
  });
140
165
  })();
@@ -144,6 +169,8 @@ function createPage({
144
169
  }
145
170
  // Annotate the CommonJS export names for ESM import in node:
146
171
  0 && (module.exports = {
147
- createPage
172
+ createPage,
173
+ getSanitizedI18nConfig,
174
+ getSanitizedInitialMessages
148
175
  });
149
176
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/templates.ts"],"sourcesContent":["import sanitizeHtml from 'sanitize-html';\n\nimport type { AuthenticationChatOption, LoadPreviousSessionChatOption } from './types';\nexport function createPage({\n\tinstanceId,\n\twebhookUrl,\n\tshowWelcomeScreen,\n\tloadPreviousSession,\n\ti18n: { en },\n\tinitialMessages,\n\tauthentication,\n\tallowFileUploads,\n\tallowedFilesMimeTypes,\n\tcustomCss,\n\tenableStreaming,\n}: {\n\tinstanceId: string;\n\twebhookUrl?: string;\n\tshowWelcomeScreen?: boolean;\n\tloadPreviousSession?: LoadPreviousSessionChatOption;\n\ti18n: {\n\t\ten: Record<string, string>;\n\t};\n\tinitialMessages: string[];\n\tmode: 'test' | 'production';\n\tauthentication: AuthenticationChatOption;\n\tallowFileUploads?: boolean;\n\tallowedFilesMimeTypes?: string;\n\tcustomCss?: string;\n\tenableStreaming?: boolean;\n}) {\n\tconst validAuthenticationOptions: AuthenticationChatOption[] = [\n\t\t'none',\n\t\t'basicAuth',\n\t\t'n8nUserAuth',\n\t];\n\tconst validLoadPreviousSessionOptions: LoadPreviousSessionChatOption[] = [\n\t\t'manually',\n\t\t'memory',\n\t\t'notSupported',\n\t];\n\n\tconst sanitizedAuthentication = validAuthenticationOptions.includes(authentication)\n\t\t? authentication\n\t\t: 'none';\n\tconst sanitizedShowWelcomeScreen = !!showWelcomeScreen;\n\tconst sanitizedAllowFileUploads = !!allowFileUploads;\n\tconst sanitizedAllowedFilesMimeTypes = allowedFilesMimeTypes?.toString() ?? '';\n\tconst sanitizedCustomCss = sanitizeHtml(`<style>${customCss?.toString() ?? ''}</style>`, {\n\t\tallowedTags: ['style'],\n\t\tallowedAttributes: false,\n\t});\n\n\tconst sanitizedLoadPreviousSession = validLoadPreviousSessionOptions.includes(\n\t\tloadPreviousSession as LoadPreviousSessionChatOption,\n\t)\n\t\t? loadPreviousSession\n\t\t: 'notSupported';\n\n\treturn `<!doctype html>\n\t<html lang=\"en\">\n\t\t<head>\n\t\t\t<meta charset=\"utf-8\">\n\t\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t\t<title>Chat</title>\n\t\t\t<link href=\"https://cdn.jsdelivr.net/npm/normalize.css@8.0.1/normalize.min.css\" rel=\"stylesheet\" />\n\t\t\t<link href=\"https://cdn.jsdelivr.net/npm/@n8n/chat/dist/style.css\" rel=\"stylesheet\" />\n\t\t\t<style>\n\t\t\t\thtml,\n\t\t\t\tbody,\n\t\t\t\t#n8n-chat {\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\theight: 100%;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t${sanitizedCustomCss}\n\t\t</head>\n\t\t<body>\n\t\t\t<script type=\"module\">\n\t\t\t\timport { createChat } from 'https://cdn.jsdelivr.net/npm/@n8n/chat/dist/chat.bundle.es.js';\n\n\t\t\t\t(async function () {\n\t\t\t\t\tconst authentication = '${sanitizedAuthentication}';\n\t\t\t\t\tlet metadata;\n\t\t\t\t\tif (authentication === 'n8nUserAuth') {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await fetch('/rest/login', {\n\t\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\t\theaders: { 'browser-id': localStorage.getItem('n8n-browserId') }\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (response.status !== 200) {\n\t\t\t\t\t\t\t\tthrow new Error('Not logged in');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst responseData = await response.json();\n\t\t\t\t\t\t\tmetadata = {\n\t\t\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\t\t\tid: responseData.data.id,\n\t\t\t\t\t\t\t\t\tfirstName: responseData.data.firstName,\n\t\t\t\t\t\t\t\t\tlastName: responseData.data.lastName,\n\t\t\t\t\t\t\t\t\temail: responseData.data.email,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\twindow.location.href = '/signin?redirect=' + window.location.href;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateChat({\n\t\t\t\t\t\tmode: 'fullscreen',\n\t\t\t\t\t\twebhookUrl: '${webhookUrl}',\n\t\t\t\t\t\tshowWelcomeScreen: ${sanitizedShowWelcomeScreen},\n\t\t\t\t\t\tloadPreviousSession: ${sanitizedLoadPreviousSession !== 'notSupported'},\n\t\t\t\t\t\tmetadata: metadata,\n\t\t\t\t\t\twebhookConfig: {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t\t\t'X-Instance-Id': '${instanceId}',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tallowFileUploads: ${sanitizedAllowFileUploads},\n\t\t\t\t\t\tallowedFilesMimeTypes: '${sanitizedAllowedFilesMimeTypes}',\n\t\t\t\t\t\ti18n: {\n\t\t\t\t\t\t\t${en ? `en: ${JSON.stringify(en)},` : ''}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t${initialMessages.length ? `initialMessages: ${JSON.stringify(initialMessages)},` : ''}\n\t\t\t\t\t\tenableStreaming: ${!!enableStreaming},\n\t\t\t\t\t});\n\t\t\t\t})();\n\t\t\t</script>\n\t\t</body>\n\t</html>`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAyB;AAGlB,SAAS,WAAW;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM,EAAE,GAAG;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAeG;AACF,QAAM,6BAAyD;AAAA,IAC9D;AAAA,IACA;AAAA,IACA;AAAA,EAC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ates.ts"],"sourcesContent":["import sanitizeHtml from 'sanitize-html';\n\nimport type { AuthenticationChatOption, LoadPreviousSessionChatOption } from './types';\n\nfunction sanitizeUserInput(input: string): string {\n\t// Sanitize HTML tags and entities\n\tlet sanitized = sanitizeHtml(input, {\n\t\tallowedTags: [],\n\t\tallowedAttributes: {},\n\t});\n\t// Remove dangerous protocols\n\tsanitized = sanitized.replace(/javascript:/gi, '');\n\tsanitized = sanitized.replace(/data:/gi, '');\n\tsanitized = sanitized.replace(/vbscript:/gi, '');\n\treturn sanitized;\n}\n\nexport function getSanitizedInitialMessages(initialMessages: string): string[] {\n\tconst sanitizedString = sanitizeUserInput(initialMessages);\n\n\treturn sanitizedString\n\t\t.split('\\n')\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== '');\n}\n\nexport function getSanitizedI18nConfig(config: Record<string, string>): Record<string, string> {\n\tconst sanitized: Record<string, string> = {};\n\n\tfor (const [key, value] of Object.entries<string>(config)) {\n\t\tsanitized[key] = sanitizeUserInput(value);\n\t}\n\n\treturn sanitized;\n}\nexport function createPage({\n\tinstanceId,\n\twebhookUrl,\n\tshowWelcomeScreen,\n\tloadPreviousSession,\n\ti18n: { en },\n\tinitialMessages,\n\tauthentication,\n\tallowFileUploads,\n\tallowedFilesMimeTypes,\n\tcustomCss,\n\tenableStreaming,\n}: {\n\tinstanceId: string;\n\twebhookUrl?: string;\n\tshowWelcomeScreen?: boolean;\n\tloadPreviousSession?: LoadPreviousSessionChatOption;\n\ti18n: {\n\t\ten: Record<string, string>;\n\t};\n\tinitialMessages: string;\n\tmode: 'test' | 'production';\n\tauthentication: AuthenticationChatOption;\n\tallowFileUploads?: boolean;\n\tallowedFilesMimeTypes?: string;\n\tcustomCss?: string;\n\tenableStreaming?: boolean;\n}) {\n\tconst validAuthenticationOptions: AuthenticationChatOption[] = [\n\t\t'none',\n\t\t'basicAuth',\n\t\t'n8nUserAuth',\n\t];\n\tconst validLoadPreviousSessionOptions: LoadPreviousSessionChatOption[] = [\n\t\t'manually',\n\t\t'memory',\n\t\t'notSupported',\n\t];\n\n\tconst sanitizedAuthentication = validAuthenticationOptions.includes(authentication)\n\t\t? authentication\n\t\t: 'none';\n\tconst sanitizedShowWelcomeScreen = !!showWelcomeScreen;\n\tconst sanitizedAllowFileUploads = !!allowFileUploads;\n\tconst sanitizedAllowedFilesMimeTypes = allowedFilesMimeTypes?.toString() ?? '';\n\tconst sanitizedCustomCss = sanitizeHtml(`<style>${customCss?.toString() ?? ''}</style>`, {\n\t\tallowedTags: ['style'],\n\t\tallowedAttributes: false,\n\t});\n\n\tconst sanitizedLoadPreviousSession = validLoadPreviousSessionOptions.includes(\n\t\tloadPreviousSession as LoadPreviousSessionChatOption,\n\t)\n\t\t? loadPreviousSession\n\t\t: 'notSupported';\n\n\tconst sanitizedInitialMessages = getSanitizedInitialMessages(initialMessages);\n\tconst sanitizedI18nConfig = getSanitizedI18nConfig(en || {});\n\n\treturn `<!doctype html>\n\t<html lang=\"en\">\n\t\t<head>\n\t\t\t<meta charset=\"utf-8\">\n\t\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t\t<title>Chat</title>\n\t\t\t<link href=\"https://cdn.jsdelivr.net/npm/normalize.css@8.0.1/normalize.min.css\" rel=\"stylesheet\" />\n\t\t\t<link href=\"https://cdn.jsdelivr.net/npm/@n8n/chat/dist/style.css\" rel=\"stylesheet\" />\n\t\t\t<style>\n\t\t\t\thtml,\n\t\t\t\tbody,\n\t\t\t\t#n8n-chat {\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\theight: 100%;\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t${sanitizedCustomCss}\n\t\t</head>\n\t\t<body>\n\t\t\t<script type=\"module\">\n\t\t\t\timport { createChat } from 'https://cdn.jsdelivr.net/npm/@n8n/chat/dist/chat.bundle.es.js';\n\n\t\t\t\t(async function () {\n\t\t\t\t\tconst authentication = '${sanitizedAuthentication}';\n\t\t\t\t\tlet metadata;\n\t\t\t\t\tif (authentication === 'n8nUserAuth') {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await fetch('/rest/login', {\n\t\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\t\theaders: { 'browser-id': localStorage.getItem('n8n-browserId') }\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (response.status !== 200) {\n\t\t\t\t\t\t\t\tthrow new Error('Not logged in');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst responseData = await response.json();\n\t\t\t\t\t\t\tmetadata = {\n\t\t\t\t\t\t\t\tuser: {\n\t\t\t\t\t\t\t\t\tid: responseData.data.id,\n\t\t\t\t\t\t\t\t\tfirstName: responseData.data.firstName,\n\t\t\t\t\t\t\t\t\tlastName: responseData.data.lastName,\n\t\t\t\t\t\t\t\t\temail: responseData.data.email,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\twindow.location.href = '/signin?redirect=' + window.location.href;\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateChat({\n\t\t\t\t\t\tmode: 'fullscreen',\n\t\t\t\t\t\twebhookUrl: '${webhookUrl}',\n\t\t\t\t\t\tshowWelcomeScreen: ${sanitizedShowWelcomeScreen},\n\t\t\t\t\t\tloadPreviousSession: ${sanitizedLoadPreviousSession !== 'notSupported'},\n\t\t\t\t\t\tmetadata: metadata,\n\t\t\t\t\t\twebhookConfig: {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t\t\t'X-Instance-Id': '${instanceId}',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tallowFileUploads: ${sanitizedAllowFileUploads},\n\t\t\t\t\t\tallowedFilesMimeTypes: '${sanitizedAllowedFilesMimeTypes}',\n\t\t\t\t\t\ti18n: {\n\t\t\t\t\t\t\t${Object.keys(sanitizedI18nConfig).length ? `en: ${JSON.stringify(sanitizedI18nConfig)},` : ''}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t${sanitizedInitialMessages.length ? `initialMessages: ${JSON.stringify(sanitizedInitialMessages)},` : ''}\n\t\t\t\t\t\tenableStreaming: ${!!enableStreaming},\n\t\t\t\t\t});\n\t\t\t\t})();\n\t\t\t</script>\n\t\t</body>\n\t</html>`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAyB;AAIzB,SAAS,kBAAkB,OAAuB;AAEjD,MAAI,gBAAY,qBAAAA,SAAa,OAAO;AAAA,IACnC,aAAa,CAAC;AAAA,IACd,mBAAmB,CAAC;AAAA,EACrB,CAAC;AAED,cAAY,UAAU,QAAQ,iBAAiB,EAAE;AACjD,cAAY,UAAU,QAAQ,WAAW,EAAE;AAC3C,cAAY,UAAU,QAAQ,eAAe,EAAE;AAC/C,SAAO;AACR;AAEO,SAAS,4BAA4B,iBAAmC;AAC9E,QAAM,kBAAkB,kBAAkB,eAAe;AAEzD,SAAO,gBACL,MAAM,IAAI,EACV,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,CAAC,SAAS,SAAS,EAAE;AAC/B;AAEO,SAAS,uBAAuB,QAAwD;AAC9F,QAAM,YAAoC,CAAC;AAE3C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAgB,MAAM,GAAG;AAC1D,cAAU,GAAG,IAAI,kBAAkB,KAAK;AAAA,EACzC;AAEA,SAAO;AACR;AACO,SAAS,WAAW;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAM,EAAE,GAAG;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAeG;AACF,QAAM,6BAAyD;AAAA,IAC9D;AAAA,I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,EAAE;AAAA,yBACrF,CAAC,CAAC,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAM1C;","names":["sanitizeHtml"]}
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -13,5 +17,22 @@ var __copyProps = (to, from, except, desc) => {
13
17
  };
14
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
19
  var types_exports = {};
20
+ __export(types_exports, {
21
+ assertValidLoadPreviousSessionOption: () => assertValidLoadPreviousSessionOption
22
+ });
16
23
  module.exports = __toCommonJS(types_exports);
24
+ var import_n8n_workflow = require("n8n-workflow");
25
+ const validOptions = ["notSupported", "memory", "manually"];
26
+ function isValidLoadPreviousSessionOption(value) {
27
+ return typeof value === "string" && validOptions.includes(value);
28
+ }
29
+ function assertValidLoadPreviousSessionOption(value, node) {
30
+ if (value && !isValidLoadPreviousSessionOption(value)) {
31
+ throw new import_n8n_workflow.NodeOperationError(node, `Invalid loadPreviousSession option: ${value}`);
32
+ }
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ assertValidLoadPreviousSessionOption
37
+ });
17
38
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/types.ts"],"sourcesContent":["export type AuthenticationChatOption = 'none' | 'basicAuth' | 'n8nUserAuth';\nexport type LoadPreviousSessionChatOption = 'manually' | 'memory' | 'notSupported';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/trigger/ChatTrigger/types.ts"],"sourcesContent":["import type { INode } from 'n8n-workflow';\nimport { NodeOperationError } from 'n8n-workflow';\n\nconst validOptions = ['notSupported', 'memory', 'manually'] as const;\nexport type AuthenticationChatOption = 'none' | 'basicAuth' | 'n8nUserAuth';\nexport type LoadPreviousSessionChatOption = (typeof validOptions)[number];\n\nfunction isValidLoadPreviousSessionOption(value: unknown): value is LoadPreviousSessionChatOption {\n\treturn typeof value === 'string' && (validOptions as readonly string[]).includes(value);\n}\n\nexport function assertValidLoadPreviousSessionOption(\n\tvalue: string | undefined,\n\tnode: INode,\n): asserts value is LoadPreviousSessionChatOption | undefined {\n\tif (value && !isValidLoadPreviousSessionOption(value)) {\n\t\tthrow new NodeOperationError(node, `Invalid loadPreviousSession option: ${value}`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAmC;AAEnC,MAAM,eAAe,CAAC,gBAAgB,UAAU,UAAU;AAI1D,SAAS,iCAAiC,OAAwD;AACjG,SAAO,OAAO,UAAU,YAAa,aAAmC,SAAS,KAAK;AACvF;AAEO,SAAS,qCACf,OACA,MAC6D;AAC7D,MAAI,SAAS,CAAC,iCAAiC,KAAK,GAAG;AACtD,UAAM,IAAI,uCAAmB,MAAM,uCAAuC,KAAK,EAAE;AAAA,EAClF;AACD;","names":[]}
@@ -32,7 +32,8 @@ const ragStarterCallout = {
32
32
  typeOptions: {
33
33
  calloutAction: {
34
34
  label: "RAG starter template",
35
- type: "openRagStarterTemplate"
35
+ type: "openSampleWorkflowTemplate",
36
+ templateId: "rag-starter-template"
36
37
  }
37
38
  },
38
39
  default: ""
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeTypeDescription,\n\tSupplyData,\n\tISupplyDataFunctions,\n\tINodeType,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\n// Import custom types\nimport {\n\thandleLoadOperation,\n\thandleInsertOperation,\n\thandleUpdateOperation,\n\thandleRetrieveOperation,\n\thandleRetrieveAsToolOperation,\n} from './operations';\nimport type { NodeOperationMode, VectorStoreNodeConstructorArgs } from './types';\n// Import utility functions\nimport { transformDescriptionForOperationMode, getOperationModeOptions } from './utils';\n\nconst ragStarterCallout: INodeProperties = {\n\tdisplayName: 'Tip: Get a feel for vector stores in n8n with our',\n\tname: 'ragStarterCallout',\n\ttype: 'callout',\n\ttypeOptions: {\n\t\tcalloutAction: {\n\t\t\tlabel: 'RAG starter template',\n\t\t\ttype: 'openRagStarterTemplate',\n\t\t},\n\t},\n\tdefault: '',\n};\n\n/**\n * Creates a vector store node with the given configuration\n * This factory function produces a complete node class that implements all vector store operations\n */\nexport const createVectorStoreNode = <T extends VectorStore = VectorStore>(\n\targs: VectorStoreNodeConstructorArgs<T>,\n) =>\n\tclass VectorStoreNodeType implements INodeType {\n\t\tdescription: INodeTypeDescription = {\n\t\t\tdisplayName: args.meta.displayName,\n\t\t\tname: args.meta.name,\n\t\t\tdescription: args.meta.description,\n\t\t\ticon: args.meta.icon,\n\t\t\ticonColor: args.meta.iconColor,\n\t\t\tgroup: ['transform'],\n\t\t\t// 1.2 has changes to VectorStoreInMemory node.\n\t\t\t// 1.3 drops `toolName` and uses node name as the tool name.\n\t\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\t\tdefaults: {\n\t\t\t\tname: args.meta.displayName,\n\t\t\t},\n\t\t\tcodex: {\n\t\t\t\tcategories: args.meta.categories ?? ['AI'],\n\t\t\t\tsubcategories: args.meta.subcategories ?? {\n\t\t\t\t\tAI: ['Vector Stores', 'Tools', 'Root Nodes'],\n\t\t\t\t\t'Vector Stores': ['Other Vector Stores'],\n\t\t\t\t\tTools: ['Other Tools'],\n\t\t\t\t},\n\t\t\t\tresources: {\n\t\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl: args.meta.docsUrl,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\tcredentials: args.meta.credentials,\n\n\t\t\tinputs: `={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst useReranker = parameters?.useReranker;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"${NodeConnectionTypes.AiEmbedding}\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (['load', 'retrieve', 'retrieve-as-tool'].includes(mode) && useReranker) {\n\t\t\t\t\tinputs.push({ displayName: \"Reranker\", type: \"${NodeConnectionTypes.AiReranker}\", required: true, maxConnections: 1})\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\t\treturn inputs;\n\t\t\t\t}\n\n\t\t\t\tif (['insert', 'load', 'update'].includes(mode)) {\n\t\t\t\t\tinputs.push({ displayName: \"\", type: \"${NodeConnectionTypes.Main}\"})\n\t\t\t\t}\n\n\t\t\t\tif (['insert'].includes(mode)) {\n\t\t\t\t\tinputs.push({ displayName: \"Document\", type: \"${NodeConnectionTypes.AiDocument}\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}`,\n\t\t\toutputs: `={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode ?? 'retrieve';\n\n\t\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\t\treturn [{ displayName: \"Tool\", type: \"${NodeConnectionTypes.AiTool}\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"${NodeConnectionTypes.AiVectorStore}\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"${NodeConnectionTypes.Main}\"}]\n\t\t\t})($parameter)\n\t\t}}`,\n\t\t\tproperties: [\n\t\t\t\tragStarterCallout,\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Operation Mode',\n\t\t\t\t\tname: 'mode',\n\t\t\t\t\ttype: 'options',\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdefault: 'retrieve',\n\t\t\t\t\toptions: getOperationModeOptions(args),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...getConnectionHintNoticeField([NodeConnectionTypes.AiRetriever]),\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Name',\n\t\t\t\t\tname: 'toolName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription: 'Name of the vector store',\n\t\t\t\t\tplaceholder: 'e.g. company_knowledge_base',\n\t\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t\t\tmode: ['retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Description',\n\t\t\t\t\tname: 'toolDescription',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttypeOptions: { rows: 2 },\n\t\t\t\t\tdescription:\n\t\t\t\t\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\t\t\t\t\tplaceholder: `e.g. ${args.meta.description}`,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...args.sharedFields,\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Embedding Batch Size',\n\t\t\t\t\tname: 'embeddingBatchSize',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 200,\n\t\t\t\t\tdescription: 'Number of documents to embed in a single batch',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['insert'],\n\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...transformDescriptionForOperationMode(args.insertFields ?? [], 'insert'),\n\t\t\t\t// Prompt and topK are always used for the load operation\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Prompt',\n\t\t\t\t\tname: 'prompt',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Search prompt to retrieve matching documents from the vector store using similarity-based ranking',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Limit',\n\t\t\t\t\tname: 'topK',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 4,\n\t\t\t\t\tdescription: 'Number of top results to fetch from vector store',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Include Metadata',\n\t\t\t\t\tname: 'includeDocumentMetadata',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: true,\n\t\t\t\t\tdescription: 'Whether or not to include document metadata',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Rerank Results',\n\t\t\t\t\tname: 'useReranker',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tdescription: 'Whether or not to rerank results',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// ID is always used for update operation\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'ID',\n\t\t\t\t\tname: 'id',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription: 'ID of an embedding entry',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['update'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...transformDescriptionForOperationMode(args.loadFields ?? [], [\n\t\t\t\t\t'load',\n\t\t\t\t\t'retrieve-as-tool',\n\t\t\t\t]),\n\t\t\t\t...transformDescriptionForOperationMode(args.retrieveFields ?? [], 'retrieve'),\n\t\t\t\t...transformDescriptionForOperationMode(args.updateFields ?? [], 'update'),\n\t\t\t],\n\t\t};\n\n\t\tmethods = args.methods;\n\n\t\t/**\n\t\t * Method to execute the node in regular workflow mode\n\t\t * Supports 'load', 'insert', and 'update' operation modes\n\t\t */\n\t\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\t\tconst mode = this.getNodeParameter('mode', 0) as NodeOperationMode;\n\t\t\t// Get the embeddings model connected to this node\n\t\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t\t0,\n\t\t\t)) as Embeddings;\n\n\t\t\t// Handle each operation mode with dedicated modules\n\t\t\tif (mode === 'load') {\n\t\t\t\tconst items = this.getInputData(0);\n\t\t\t\tconst resultData = [];\n\n\t\t\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\t\t\tconst docs = await handleLoadOperation(this, args, embeddings, itemIndex);\n\t\t\t\t\tresultData.push(...docs);\n\t\t\t\t}\n\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tif (mode === 'insert') {\n\t\t\t\tconst resultData = await handleInsertOperation(this, args, embeddings);\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tif (mode === 'update') {\n\t\t\t\tconst resultData = await handleUpdateOperation(this, args, embeddings);\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Only the \"load\", \"update\" and \"insert\" operation modes are supported with execute',\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Method to supply data to AI nodes\n\t\t * Supports 'retrieve' and 'retrieve-as-tool' operation modes\n\t\t */\n\t\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\t\tconst mode = this.getNodeParameter('mode', 0) as NodeOperationMode;\n\n\t\t\t// Get the embeddings model connected to this node\n\t\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t\t0,\n\t\t\t)) as Embeddings;\n\n\t\t\t// Handle each supply data operation mode with dedicated modules\n\t\t\tif (mode === 'retrieve') {\n\t\t\t\treturn await handleRetrieveOperation(this, args, embeddings, itemIndex);\n\t\t\t}\n\n\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\treturn await handleRetrieveAsToolOperation(this, args, embeddings, itemIndex);\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Only the \"retrieve\" and \"retrieve-as-tool\" operation mode is supported to supply data',\n\t\t\t);\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAAwD;AAWxD,0BAA6C;AAG7C,wBAMO;AAGP,mBAA8E;AAE9E,MAAM,oBAAqC;AAAA,EAC1C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aAAa;AAAA,IACZ,eAAe;AAAA,MACd,OAAO;AAAA,MACP,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA,SAAS;AACV;AAMO,MAAM,wBAAwB,CACpC,SAEA,MAAM,oBAAyC;AAAA,EAA/C;AACC,uBAAoC;AAAA,MACnC,aAAa,KAAK,KAAK;AAAA,MACvB,MAAM,KAAK,KAAK;AAAA,MAChB,aAAa,KAAK,KAAK;AAAA,MACvB,MAAM,KAAK,KAAK;AAAA,MAChB,WAAW,KAAK,KAAK;AAAA,MACrB,OAAO,CAAC,WAAW;AAAA;AAAA;AAAA,MAGnB,SAAS,CAAC,GAAG,KAAK,KAAK,GAAG;AAAA,MAC1B,UAAU;AAAA,QACT,MAAM,KAAK,KAAK;AAAA,MACjB;AAAA,MACA,OAAO;AAAA,QACN,YAAY,KAAK,KAAK,cAAc,CAAC,IAAI;AAAA,QACzC,eAAe,KAAK,KAAK,iBAAiB;AAAA,UACzC,IAAI,CAAC,iBAAiB,SAAS,YAAY;AAAA,UAC3C,iBAAiB,CAAC,qBAAqB;AAAA,UACvC,OAAO,CAAC,aAAa;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK,KAAK,KAAK;AAAA,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,MAAM,UAAU;AACrE,aAAO,CAAC,UAAU;AAAA,IACnB;AAEA,UAAM,IAAI;AAAA,MACT,KAAK,QAAQ;AAAA,MACb;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAuC,WAAwC;AACpF,UAAM,OAAO,KAAK,iBAAiB,QAAQ,CAAC;AAG5C,UAAM,aAAc,MAAM,KAAK;AAAA,MAC9B,wCAAoB;AAAA,MACpB;AAAA,IACD;AAGA,QAAI,SAAS,YAAY;AACxB,aAAO,UAAM,2CAAwB,MAAM,MAAM,YAAY,SAAS;AAAA,IACvE;AAEA,QAAI,SAAS,oBAAoB;AAChC,aAAO,UAAM,iDAA8B,MAAM,MAAM,YAAY,SAAS;AAAA,IAC7E;AAEA,UAAM,IAAI;AAAA,MACT,KAAK,QAAQ;AAAA,MACb;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../../nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeTypeDescription,\n\tSupplyData,\n\tISupplyDataFunctions,\n\tINodeType,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\n// Import custom types\nimport {\n\thandleLoadOperation,\n\thandleInsertOperation,\n\thandleUpdateOperation,\n\thandleRetrieveOperation,\n\thandleRetrieveAsToolOperation,\n} from './operations';\nimport type { NodeOperationMode, VectorStoreNodeConstructorArgs } from './types';\n// Import utility functions\nimport { transformDescriptionForOperationMode, getOperationModeOptions } from './utils';\n\nconst ragStarterCallout: INodeProperties = {\n\tdisplayName: 'Tip: Get a feel for vector stores in n8n with our',\n\tname: 'ragStarterCallout',\n\ttype: 'callout',\n\ttypeOptions: {\n\t\tcalloutAction: {\n\t\t\tlabel: 'RAG starter template',\n\t\t\ttype: 'openSampleWorkflowTemplate',\n\t\t\ttemplateId: 'rag-starter-template',\n\t\t},\n\t},\n\tdefault: '',\n};\n\n/**\n * Creates a vector store node with the given configuration\n * This factory function produces a complete node class that implements all vector store operations\n */\nexport const createVectorStoreNode = <T extends VectorStore = VectorStore>(\n\targs: VectorStoreNodeConstructorArgs<T>,\n) =>\n\tclass VectorStoreNodeType implements INodeType {\n\t\tdescription: INodeTypeDescription = {\n\t\t\tdisplayName: args.meta.displayName,\n\t\t\tname: args.meta.name,\n\t\t\tdescription: args.meta.description,\n\t\t\ticon: args.meta.icon,\n\t\t\ticonColor: args.meta.iconColor,\n\t\t\tgroup: ['transform'],\n\t\t\t// 1.2 has changes to VectorStoreInMemory node.\n\t\t\t// 1.3 drops `toolName` and uses node name as the tool name.\n\t\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\t\tdefaults: {\n\t\t\t\tname: args.meta.displayName,\n\t\t\t},\n\t\t\tcodex: {\n\t\t\t\tcategories: args.meta.categories ?? ['AI'],\n\t\t\t\tsubcategories: args.meta.subcategories ?? {\n\t\t\t\t\tAI: ['Vector Stores', 'Tools', 'Root Nodes'],\n\t\t\t\t\t'Vector Stores': ['Other Vector Stores'],\n\t\t\t\t\tTools: ['Other Tools'],\n\t\t\t\t},\n\t\t\t\tresources: {\n\t\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl: args.meta.docsUrl,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t\tcredentials: args.meta.credentials,\n\n\t\t\tinputs: `={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode;\n\t\t\t\tconst useReranker = parameters?.useReranker;\n\t\t\t\tconst inputs = [{ displayName: \"Embedding\", type: \"${NodeConnectionTypes.AiEmbedding}\", required: true, maxConnections: 1}]\n\n\t\t\t\tif (['load', 'retrieve', 'retrieve-as-tool'].includes(mode) && useReranker) {\n\t\t\t\t\tinputs.push({ displayName: \"Reranker\", type: \"${NodeConnectionTypes.AiReranker}\", required: true, maxConnections: 1})\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\t\treturn inputs;\n\t\t\t\t}\n\n\t\t\t\tif (['insert', 'load', 'update'].includes(mode)) {\n\t\t\t\t\tinputs.push({ displayName: \"\", type: \"${NodeConnectionTypes.Main}\"})\n\t\t\t\t}\n\n\t\t\t\tif (['insert'].includes(mode)) {\n\t\t\t\t\tinputs.push({ displayName: \"Document\", type: \"${NodeConnectionTypes.AiDocument}\", required: true, maxConnections: 1})\n\t\t\t\t}\n\t\t\t\treturn inputs\n\t\t\t})($parameter)\n\t\t}}`,\n\t\t\toutputs: `={{\n\t\t\t((parameters) => {\n\t\t\t\tconst mode = parameters?.mode ?? 'retrieve';\n\n\t\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\t\treturn [{ displayName: \"Tool\", type: \"${NodeConnectionTypes.AiTool}\"}]\n\t\t\t\t}\n\n\t\t\t\tif (mode === 'retrieve') {\n\t\t\t\t\treturn [{ displayName: \"Vector Store\", type: \"${NodeConnectionTypes.AiVectorStore}\"}]\n\t\t\t\t}\n\t\t\t\treturn [{ displayName: \"\", type: \"${NodeConnectionTypes.Main}\"}]\n\t\t\t})($parameter)\n\t\t}}`,\n\t\t\tproperties: [\n\t\t\t\tragStarterCallout,\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Operation Mode',\n\t\t\t\t\tname: 'mode',\n\t\t\t\t\ttype: 'options',\n\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\tdefault: 'retrieve',\n\t\t\t\t\toptions: getOperationModeOptions(args),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...getConnectionHintNoticeField([NodeConnectionTypes.AiRetriever]),\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Name',\n\t\t\t\t\tname: 'toolName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription: 'Name of the vector store',\n\t\t\t\t\tplaceholder: 'e.g. company_knowledge_base',\n\t\t\t\t\tvalidateType: 'string-alphanumeric',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t\t\tmode: ['retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Description',\n\t\t\t\t\tname: 'toolDescription',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttypeOptions: { rows: 2 },\n\t\t\t\t\tdescription:\n\t\t\t\t\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\t\t\t\t\tplaceholder: `e.g. ${args.meta.description}`,\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...args.sharedFields,\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Embedding Batch Size',\n\t\t\t\t\tname: 'embeddingBatchSize',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 200,\n\t\t\t\t\tdescription: 'Number of documents to embed in a single batch',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['insert'],\n\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.1 } }],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...transformDescriptionForOperationMode(args.insertFields ?? [], 'insert'),\n\t\t\t\t// Prompt and topK are always used for the load operation\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Prompt',\n\t\t\t\t\tname: 'prompt',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Search prompt to retrieve matching documents from the vector store using similarity-based ranking',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Limit',\n\t\t\t\t\tname: 'topK',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 4,\n\t\t\t\t\tdescription: 'Number of top results to fetch from vector store',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Include Metadata',\n\t\t\t\t\tname: 'includeDocumentMetadata',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: true,\n\t\t\t\t\tdescription: 'Whether or not to include document metadata',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Rerank Results',\n\t\t\t\t\tname: 'useReranker',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t\tdescription: 'Whether or not to rerank results',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['load', 'retrieve', 'retrieve-as-tool'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// ID is always used for update operation\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'ID',\n\t\t\t\t\tname: 'id',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdescription: 'ID of an embedding entry',\n\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\tmode: ['update'],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...transformDescriptionForOperationMode(args.loadFields ?? [], [\n\t\t\t\t\t'load',\n\t\t\t\t\t'retrieve-as-tool',\n\t\t\t\t]),\n\t\t\t\t...transformDescriptionForOperationMode(args.retrieveFields ?? [], 'retrieve'),\n\t\t\t\t...transformDescriptionForOperationMode(args.updateFields ?? [], 'update'),\n\t\t\t],\n\t\t};\n\n\t\tmethods = args.methods;\n\n\t\t/**\n\t\t * Method to execute the node in regular workflow mode\n\t\t * Supports 'load', 'insert', and 'update' operation modes\n\t\t */\n\t\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\t\tconst mode = this.getNodeParameter('mode', 0) as NodeOperationMode;\n\t\t\t// Get the embeddings model connected to this node\n\t\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t\t0,\n\t\t\t)) as Embeddings;\n\n\t\t\t// Handle each operation mode with dedicated modules\n\t\t\tif (mode === 'load') {\n\t\t\t\tconst items = this.getInputData(0);\n\t\t\t\tconst resultData = [];\n\n\t\t\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\t\t\tconst docs = await handleLoadOperation(this, args, embeddings, itemIndex);\n\t\t\t\t\tresultData.push(...docs);\n\t\t\t\t}\n\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tif (mode === 'insert') {\n\t\t\t\tconst resultData = await handleInsertOperation(this, args, embeddings);\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tif (mode === 'update') {\n\t\t\t\tconst resultData = await handleUpdateOperation(this, args, embeddings);\n\t\t\t\treturn [resultData];\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Only the \"load\", \"update\" and \"insert\" operation modes are supported with execute',\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Method to supply data to AI nodes\n\t\t * Supports 'retrieve' and 'retrieve-as-tool' operation modes\n\t\t */\n\t\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\t\tconst mode = this.getNodeParameter('mode', 0) as NodeOperationMode;\n\n\t\t\t// Get the embeddings model connected to this node\n\t\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t\t0,\n\t\t\t)) as Embeddings;\n\n\t\t\t// Handle each supply data operation mode with dedicated modules\n\t\t\tif (mode === 'retrieve') {\n\t\t\t\treturn await handleRetrieveOperation(this, args, embeddings, itemIndex);\n\t\t\t}\n\n\t\t\tif (mode === 'retrieve-as-tool') {\n\t\t\t\treturn await handleRetrieveAsToolOperation(this, args, embeddings, itemIndex);\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'Only the \"retrieve\" and \"retrieve-as-tool\" operation mode is supported to supply data',\n\t\t\t);\n\t\t}\n\t};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAAwD;AAWxD,0BAA6C;AAG7C,wBAMO;AAGP,mBAA8E;AAE9E,MAAM,oBAAqC;AAAA,EAC1C,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aAAa;AAAA,IACZ,eAAe;AAAA,MACd,OAAO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,IAC7E;AAEA,UAAM,IAAI;AAAA,MACT,KAAK,QAAQ;AAAA,MACb;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
@@ -6,11 +6,11 @@
6
6
  {"name":"deepSeekApi","displayName":"DeepSeek","documentationUrl":"deepseek","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Base URL","name":"url","type":"hidden","default":"https://api.deepseek.com"}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{ $credentials.url }}","url":"/models"}},"supportedNodes":["lmChatDeepSeek"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatDeepSeek/deepseek.svg"},
7
7
  {"name":"googlePalmApi","displayName":"Google Gemini(PaLM) Api","documentationUrl":"google","properties":[{"displayName":"Host","name":"host","required":true,"type":"string","default":"https://generativelanguage.googleapis.com"},{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"qs":{"key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{$credentials.host}}/v1beta/models"}},"supportedNodes":["googleGemini","embeddingsGoogleGemini","lmChatGoogleGemini"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vendors/GoogleGemini/gemini.svg"},
8
8
  {"name":"groqApi","displayName":"Groq","documentationUrl":"groq","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://api.groq.com/openai/v1","url":"/models"}},"supportedNodes":["lmChatGroq"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatGroq/groq.svg"},
9
- {"name":"huggingFaceApi","displayName":"HuggingFaceApi","documentationUrl":"huggingface","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://api-inference.huggingface.co","url":"/models/gpt2"}},"supportedNodes":["embeddingsHuggingFaceInference","lmOpenHuggingFaceInference"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/huggingface.svg"},
9
+ {"name":"huggingFaceApi","displayName":"HuggingFaceApi","documentationUrl":"huggingface","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://huggingface.co","url":"/api/whoami-v2"}},"supportedNodes":["embeddingsHuggingFaceInference","lmOpenHuggingFaceInference"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/huggingface.svg"},
10
10
  {"name":"motorheadApi","displayName":"MotorheadApi","documentationUrl":"motorhead","properties":[{"displayName":"Host","name":"host","required":true,"type":"string","default":"https://api.getmetal.io/v1"},{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Client ID","name":"clientId","type":"string","default":""}],"authenticate":{"type":"generic","properties":{"headers":{"x-metal-client-id":"={{$credentials.clientId}}","x-metal-api-key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{$credentials.host}}/keys/current"}},"supportedNodes":["memoryMotorhead"],"icon":"fa:file-export","iconColor":"black"},
11
11
  {"name":"milvusApi","displayName":"Milvus","documentationUrl":"milvus","properties":[{"displayName":"Base URL","name":"baseUrl","required":true,"type":"string","default":"http://localhost:19530"},{"displayName":"Username","name":"username","type":"string","default":""},{"displayName":"Password","name":"password","type":"string","typeOptions":{"password":true},"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.username}}:{{$credentials.password}}"}}},"test":{"request":{"baseURL":"={{ $credentials.baseUrl }}","url":"/v1/vector/collections","method":"GET"}},"supportedNodes":["vectorStoreMilvus"],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMilvus/milvus-icon-black.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMilvus/milvus-icon-white.svg"}},
12
12
  {"name":"mistralCloudApi","displayName":"Mistral Cloud API","documentationUrl":"mistral","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://api.mistral.ai/v1","url":"/models","method":"GET"}},"supportedNodes":["embeddingsMistralCloud","lmChatMistralCloud"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsMistralCloud/mistral.svg"},
13
- {"name":"ollamaApi","displayName":"Ollama","documentationUrl":"ollama","properties":[{"displayName":"Base URL","name":"baseUrl","required":true,"type":"string","default":"http://localhost:11434"}],"test":{"request":{"baseURL":"={{ $credentials.baseUrl }}","url":"/","method":"GET"}},"supportedNodes":["embeddingsOllama","lmChatOllama","lmOllama"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsOllama/ollama.svg"},
13
+ {"name":"ollamaApi","displayName":"Ollama","documentationUrl":"ollama","properties":[{"displayName":"Base URL","name":"baseUrl","required":true,"type":"string","default":"http://localhost:11434"},{"displayName":"API Key","hint":"When using Ollama behind a proxy with authentication (such as Open WebUI), provide the Bearer token/API key here. This is not required for the default Ollama installation","name":"apiKey","type":"string","typeOptions":{"password":true},"default":"","required":false}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{ $credentials.baseUrl }}","url":"/api/tags","method":"GET"}},"supportedNodes":["embeddingsOllama","lmChatOllama","lmOllama"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsOllama/ollama.svg"},
14
14
  {"name":"openRouterApi","displayName":"OpenRouter","documentationUrl":"openrouter","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Base URL","name":"url","type":"hidden","default":"https://openrouter.ai/api/v1"}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{ $credentials.url }}","url":"/key"}},"supportedNodes":["lmChatOpenRouter"],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatOpenRouter/openrouter.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatOpenRouter/openrouter.dark.svg"}},
15
15
  {"name":"pineconeApi","displayName":"PineconeApi","documentationUrl":"pinecone","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Api-Key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://api.pinecone.io/indexes","headers":{"accept":"application/json; charset=utf-8"}}},"supportedNodes":["vectorStorePinecone","vectorStorePineconeInsert","vectorStorePineconeLoad"],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStorePinecone/pinecone.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStorePinecone/pinecone.dark.svg"}},
16
16
  {"name":"qdrantApi","displayName":"QdrantApi","documentationUrl":"https://docs.n8n.io/integrations/builtin/credentials/qdrant/","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":false,"default":""},{"displayName":"Qdrant URL","name":"qdrantUrl","type":"string","required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"api-key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{$credentials.qdrantUrl}}","url":"/collections"}},"supportedNodes":["vectorStoreQdrant"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreQdrant/qdrant.svg"},