@n8n/n8n-nodes-langchain 1.101.1 → 1.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/credentials/CohereApi.credentials.js +7 -1
- package/dist/credentials/CohereApi.credentials.js.map +1 -1
- package/dist/known/credentials.json +2 -0
- package/dist/known/nodes.json +12 -0
- package/dist/nodes/agents/Agent/Agent.node.js +1 -0
- package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
- package/dist/nodes/agents/Agent/AgentTool.node.js +57 -0
- package/dist/nodes/agents/Agent/AgentTool.node.js.map +1 -0
- package/dist/nodes/agents/Agent/V2/AgentToolV2.node.js +104 -0
- package/dist/nodes/agents/Agent/V2/AgentToolV2.node.js.map +1 -0
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js +4 -66
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V2/utils.js +92 -0
- package/dist/nodes/agents/Agent/V2/utils.js.map +1 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js +13 -10
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js +14 -7
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/common.js.map +1 -1
- package/dist/nodes/chains/SentimentAnalysis/SentimentAnalysis.node.js +1 -1
- package/dist/nodes/chains/SentimentAnalysis/SentimentAnalysis.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js +6 -0
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js +2 -2
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
- package/dist/nodes/llms/LmChatCohere/LmChatCohere.node.js +181 -0
- package/dist/nodes/llms/LmChatCohere/LmChatCohere.node.js.map +1 -0
- package/dist/nodes/llms/LmChatCohere/cohere.dark.svg +5 -0
- package/dist/nodes/llms/LmChatCohere/cohere.svg +5 -0
- package/dist/nodes/llms/N8nLlmTracing.js +4 -4
- package/dist/nodes/llms/N8nLlmTracing.js.map +1 -1
- package/dist/nodes/mcp/McpTrigger/McpTrigger.node.js +1 -1
- package/dist/nodes/mcp/McpTrigger/McpTrigger.node.js.map +1 -1
- package/dist/nodes/text_splitters/TextSplitterTokenSplitter/TokenTextSplitter.js +1 -3
- package/dist/nodes/text_splitters/TextSplitterTokenSplitter/TokenTextSplitter.js.map +1 -1
- package/dist/nodes/tools/ToolCode/ToolCode.node.js +1 -2
- package/dist/nodes/tools/ToolCode/ToolCode.node.js.map +1 -1
- package/dist/nodes/tools/ToolVectorStore/ToolVectorStore.node.js +1 -2
- package/dist/nodes/tools/ToolVectorStore/ToolVectorStore.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.js +2 -2
- package/dist/nodes/tools/ToolWorkflow/v2/ToolWorkflowV2.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +2 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/templates.js +3 -1
- package/dist/nodes/trigger/ChatTrigger/templates.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js +2 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js.map +1 -1
- package/dist/nodes/vendors/GoogleGemini/GoogleGemini.node.js +42 -0
- package/dist/nodes/vendors/GoogleGemini/GoogleGemini.node.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/audio/analyze.operation.js +125 -0
- package/dist/nodes/vendors/GoogleGemini/actions/audio/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/audio/index.js +74 -0
- package/dist/nodes/vendors/GoogleGemini/actions/audio/index.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/audio/transcribe.operation.js +184 -0
- package/dist/nodes/vendors/GoogleGemini/actions/audio/transcribe.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/descriptions.js +52 -0
- package/dist/nodes/vendors/GoogleGemini/actions/descriptions.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/document/analyze.operation.js +125 -0
- package/dist/nodes/vendors/GoogleGemini/actions/document/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/document/index.js +64 -0
- package/dist/nodes/vendors/GoogleGemini/actions/document/index.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/file/index.js +64 -0
- package/dist/nodes/vendors/GoogleGemini/actions/file/index.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/file/upload.operation.js +119 -0
- package/dist/nodes/vendors/GoogleGemini/actions/file/upload.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/image/analyze.operation.js +125 -0
- package/dist/nodes/vendors/GoogleGemini/actions/image/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/image/generate.operation.js +167 -0
- package/dist/nodes/vendors/GoogleGemini/actions/image/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/image/index.js +74 -0
- package/dist/nodes/vendors/GoogleGemini/actions/image/index.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/node.type.js +17 -0
- package/dist/nodes/vendors/GoogleGemini/actions/node.type.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/router.js +97 -0
- package/dist/nodes/vendors/GoogleGemini/actions/router.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/text/index.js +64 -0
- package/dist/nodes/vendors/GoogleGemini/actions/text/index.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/text/message.operation.js +339 -0
- package/dist/nodes/vendors/GoogleGemini/actions/text/message.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/versionDescription.js +131 -0
- package/dist/nodes/vendors/GoogleGemini/actions/versionDescription.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/video/analyze.operation.js +125 -0
- package/dist/nodes/vendors/GoogleGemini/actions/video/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/video/download.operation.js +88 -0
- package/dist/nodes/vendors/GoogleGemini/actions/video/download.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/video/generate.operation.js +228 -0
- package/dist/nodes/vendors/GoogleGemini/actions/video/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/actions/video/index.js +84 -0
- package/dist/nodes/vendors/GoogleGemini/actions/video/index.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/gemini.svg +1 -0
- package/dist/nodes/vendors/GoogleGemini/helpers/baseAnalyze.js +100 -0
- package/dist/nodes/vendors/GoogleGemini/helpers/baseAnalyze.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/helpers/interfaces.js +17 -0
- package/dist/nodes/vendors/GoogleGemini/helpers/interfaces.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/helpers/utils.js +91 -0
- package/dist/nodes/vendors/GoogleGemini/helpers/utils.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/methods/index.js +39 -0
- package/dist/nodes/vendors/GoogleGemini/methods/index.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/methods/listSearch.js +74 -0
- package/dist/nodes/vendors/GoogleGemini/methods/listSearch.js.map +1 -0
- package/dist/nodes/vendors/GoogleGemini/transport/index.js +48 -0
- package/dist/nodes/vendors/GoogleGemini/transport/index.js.map +1 -0
- package/dist/types/credentials.json +2 -2
- package/dist/types/nodes.json +4 -1
- package/dist/utils/descriptions.js +13 -2
- package/dist/utils/descriptions.js.map +1 -1
- package/dist/utils/helpers.js +2 -7
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/output_parsers/N8nOutputParser.js.map +1 -1
- package/dist/utils/tokenizer/tiktoken.js +27 -30
- package/dist/utils/tokenizer/tiktoken.js.map +1 -1
- package/dist/utils/tokenizer/token-estimator.js +1 -1
- package/dist/utils/tokenizer/token-estimator.js.map +1 -1
- package/package.json +9 -5
|
@@ -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 responseModeOptions = [\n\t{\n\t\tname: 'When Last Node Finishes',\n\t\tvalue: 'lastNode',\n\t\tdescription: 'Returns data of the last-executed node',\n\t},\n\t{\n\t\tname: \"Using 'Respond to Webhook' Node\",\n\t\tvalue: 'responseNode',\n\t\tdescription: 'Response defined in that node',\n\t},\n];\n\nconst responseModeWithStreamingOptions = [\n\t...responseModeOptions,\n\t{\n\t\tname: 'Streaming Response',\n\t\tvalue: 'streaming',\n\t\tdescription: 'Streaming response from specified nodes (e.g. Agents)',\n\t},\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],\n\t\t// Keep the default version as 1.1 to avoid releasing streaming in broken state\n\t\tdefaultVersion: 1.1,\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': [{ _cnd: { gte: 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: responseModeOptions,\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': [{ _cnd: { gte: 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: responseModeWithStreamingOptions,\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],\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};\n\n\t\tconst responseMode = ctx.getNodeParameter('options.responseMode', 'lastNode') as string;\n\t\tconst enableStreaming = 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});\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: [ct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AAA,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 { 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 responseModeOptions = [\n\t{\n\t\tname: 'When Last Node Finishes',\n\t\tvalue: 'lastNode',\n\t\tdescription: 'Returns data of the last-executed node',\n\t},\n\t{\n\t\tname: \"Using 'Respond to Webhook' Node\",\n\t\tvalue: 'responseNode',\n\t\tdescription: 'Response defined in that node',\n\t},\n];\n\nconst responseModeWithStreamingOptions = [\n\t...responseModeOptions,\n\t{\n\t\tname: 'Streaming Response',\n\t\tvalue: 'streaming',\n\t\tdescription: 'Streaming response from specified nodes (e.g. Agents)',\n\t},\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],\n\t\t// Keep the default version as 1.1 to avoid releasing streaming in broken state\n\t\tdefaultVersion: 1.1,\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': [{ _cnd: { gte: 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: responseModeOptions,\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': [{ _cnd: { gte: 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: responseModeWithStreamingOptions,\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],\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};\n\n\t\tconst responseMode = ctx.getNodeParameter('options.responseMode', 'lastNode') as string;\n\t\tconst enableStreaming = 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)],\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c,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"]}
|
|
@@ -42,7 +42,8 @@ function createPage({
|
|
|
42
42
|
authentication,
|
|
43
43
|
allowFileUploads,
|
|
44
44
|
allowedFilesMimeTypes,
|
|
45
|
-
customCss
|
|
45
|
+
customCss,
|
|
46
|
+
enableStreaming
|
|
46
47
|
}) {
|
|
47
48
|
const validAuthenticationOptions = [
|
|
48
49
|
"none",
|
|
@@ -134,6 +135,7 @@ function createPage({
|
|
|
134
135
|
${en ? `en: ${JSON.stringify(en)},` : ""}
|
|
135
136
|
},
|
|
136
137
|
${initialMessages.length ? `initialMessages: ${JSON.stringify(initialMessages)},` : ""}
|
|
138
|
+
enableStreaming: ${!!enableStreaming},
|
|
137
139
|
});
|
|
138
140
|
})();
|
|
139
141
|
</script>
|
|
@@ -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}: {\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}) {\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});\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;AACD,
|
|
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,EACD;AACA,QAAM,kCAAmE;AAAA,IACxE;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,0BAA0B,2BAA2B,SAAS,cAAc,IAC/E,iBACA;AACH,QAAM,6BAA6B,CAAC,CAAC;AACrC,QAAM,4BAA4B,CAAC,CAAC;AACpC,QAAM,iCAAiC,uBAAuB,SAAS,KAAK;AAC5E,QAAM,yBAAqB,qBAAAA,SAAa,UAAU,WAAW,SAAS,KAAK,EAAE,YAAY;AAAA,IACxF,aAAa,CAAC,OAAO;AAAA,IACrB,mBAAmB;AAAA,EACpB,CAAC;AAED,QAAM,+BAA+B,gCAAgC;AAAA,IACpE;AAAA,EACD,IACG,sBACA;AAEH,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAgBH,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAOQ,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBA8BjC,UAAU;AAAA,2BACJ,0BAA0B;AAAA,6BACxB,iCAAiC,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,4BAKhD,UAAU;AAAA;AAAA;AAAA,0BAGZ,yBAAyB;AAAA,gCACnB,8BAA8B;AAAA;AAAA,SAErD,KAAK,OAAO,KAAK,UAAU,EAAE,CAAC,MAAM,EAAE;AAAA;AAAA,QAEvC,gBAAgB,SAAS,oBAAoB,KAAK,UAAU,eAAe,CAAC,MAAM,EAAE;AAAA,yBACnE,CAAC,CAAC,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAM1C;","names":["sanitizeHtml"]}
|
package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js
CHANGED
|
@@ -24,12 +24,13 @@ module.exports = __toCommonJS(retrieveAsToolOperation_exports);
|
|
|
24
24
|
var import_tools = require("langchain/tools");
|
|
25
25
|
var import_n8n_workflow = require("n8n-workflow");
|
|
26
26
|
var import_helpers = require("../../../../../utils/helpers");
|
|
27
|
+
var import_n8n_workflow2 = require("n8n-workflow");
|
|
27
28
|
var import_logWrapper = require("../../../../../utils/logWrapper");
|
|
28
29
|
async function handleRetrieveAsToolOperation(context, args, embeddings, itemIndex) {
|
|
29
30
|
const toolDescription = context.getNodeParameter("toolDescription", itemIndex);
|
|
30
31
|
const node = context.getNode();
|
|
31
32
|
const { typeVersion } = node;
|
|
32
|
-
const toolName = typeVersion < 1.3 ? context.getNodeParameter("toolName", itemIndex) : (0,
|
|
33
|
+
const toolName = typeVersion < 1.3 ? context.getNodeParameter("toolName", itemIndex) : (0, import_n8n_workflow2.nodeNameToToolName)(node);
|
|
33
34
|
const topK = context.getNodeParameter("topK", itemIndex, 4);
|
|
34
35
|
const useReranker = context.getNodeParameter("useReranker", itemIndex, false);
|
|
35
36
|
const includeDocumentMetadata = context.getNodeParameter(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { BaseDocumentCompressor } from '@langchain/core/retrievers/document_compressors';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { DynamicTool } from 'langchain/tools';\nimport { NodeConnectionTypes, type ISupplyDataFunctions, type SupplyData } from 'n8n-workflow';\n\nimport { getMetadataFiltersValues
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { BaseDocumentCompressor } from '@langchain/core/retrievers/document_compressors';\nimport type { VectorStore } from '@langchain/core/vectorstores';\nimport { DynamicTool } from 'langchain/tools';\nimport { NodeConnectionTypes, type ISupplyDataFunctions, type SupplyData } from 'n8n-workflow';\n\nimport { getMetadataFiltersValues } from '@utils/helpers';\nimport { nodeNameToToolName } from 'n8n-workflow';\nimport { logWrapper } from '@utils/logWrapper';\n\nimport type { VectorStoreNodeConstructorArgs } from '../types';\n\n/**\n * Handles the 'retrieve-as-tool' operation mode\n * Returns a tool that can be used with AI Agent nodes\n */\nexport async function handleRetrieveAsToolOperation<T extends VectorStore = VectorStore>(\n\tcontext: ISupplyDataFunctions,\n\targs: VectorStoreNodeConstructorArgs<T>,\n\tembeddings: Embeddings,\n\titemIndex: number,\n): Promise<SupplyData> {\n\t// Get the tool configuration parameters\n\tconst toolDescription = context.getNodeParameter('toolDescription', itemIndex) as string;\n\n\tconst node = context.getNode();\n\tconst { typeVersion } = node;\n\tconst toolName =\n\t\ttypeVersion < 1.3\n\t\t\t? (context.getNodeParameter('toolName', itemIndex) as string)\n\t\t\t: nodeNameToToolName(node);\n\n\tconst topK = context.getNodeParameter('topK', itemIndex, 4) as number;\n\tconst useReranker = context.getNodeParameter('useReranker', itemIndex, false) as boolean;\n\tconst includeDocumentMetadata = context.getNodeParameter(\n\t\t'includeDocumentMetadata',\n\t\titemIndex,\n\t\ttrue,\n\t) as boolean;\n\n\t// Get metadata filters\n\tconst filter = getMetadataFiltersValues(context, itemIndex);\n\n\t// Create a Dynamic Tool that wraps vector store search functionality\n\tconst vectorStoreTool = new DynamicTool({\n\t\tname: toolName,\n\t\tdescription: toolDescription,\n\t\tfunc: async (input) => {\n\t\t\t// For each tool use, get a fresh vector store client.\n\t\t\t// We don't pass in a filter here only later in the similaritySearchVectorWithScore\n\t\t\t// method to avoid an exception with some vector stores like Supabase or Pinecone(#AI-740)\n\t\t\tconst vectorStore = await args.getVectorStoreClient(\n\t\t\t\tcontext,\n\t\t\t\tundefined,\n\t\t\t\tembeddings,\n\t\t\t\titemIndex,\n\t\t\t);\n\n\t\t\ttry {\n\t\t\t\t// Embed the input query\n\t\t\t\tconst embeddedPrompt = await embeddings.embedQuery(input);\n\n\t\t\t\t// Search for similar documents\n\t\t\t\tlet documents = await vectorStore.similaritySearchVectorWithScore(\n\t\t\t\t\tembeddedPrompt,\n\t\t\t\t\ttopK,\n\t\t\t\t\tfilter,\n\t\t\t\t);\n\n\t\t\t\t// If reranker is used, rerank the documents\n\t\t\t\tif (useReranker && documents.length > 0) {\n\t\t\t\t\tconst reranker = (await context.getInputConnectionData(\n\t\t\t\t\t\tNodeConnectionTypes.AiReranker,\n\t\t\t\t\t\t0,\n\t\t\t\t\t)) as BaseDocumentCompressor;\n\n\t\t\t\t\tconst docs = documents.map(([doc]) => doc);\n\t\t\t\t\tconst rerankedDocuments = await reranker.compressDocuments(docs, input);\n\t\t\t\t\tdocuments = rerankedDocuments.map((doc) => {\n\t\t\t\t\t\tconst { relevanceScore, ...metadata } = doc.metadata;\n\t\t\t\t\t\treturn [{ ...doc, metadata }, relevanceScore];\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Format the documents for the tool output\n\t\t\t\treturn documents\n\t\t\t\t\t.map((document) => {\n\t\t\t\t\t\tif (includeDocumentMetadata) {\n\t\t\t\t\t\t\treturn { type: 'text', text: JSON.stringify(document[0]) };\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext: JSON.stringify({ pageContent: document[0].pageContent }),\n\t\t\t\t\t\t};\n\t\t\t\t\t})\n\t\t\t\t\t.filter((document) => !!document);\n\t\t\t} finally {\n\t\t\t\t// Release the vector store client if a release method was provided\n\t\t\t\targs.releaseVectorStoreClient?.(vectorStore);\n\t\t\t}\n\t\t},\n\t});\n\n\t// Return the vector store tool with logging wrapper\n\treturn {\n\t\tresponse: logWrapper(vectorStoreTool, context),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA4B;AAC5B,0BAAgF;AAEhF,qBAAyC;AACzC,IAAAA,uBAAmC;AACnC,wBAA2B;AAQ3B,eAAsB,8BACrB,SACA,MACA,YACA,WACsB;AAEtB,QAAM,kBAAkB,QAAQ,iBAAiB,mBAAmB,SAAS;AAE7E,QAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAM,EAAE,YAAY,IAAI;AACxB,QAAM,WACL,cAAc,MACV,QAAQ,iBAAiB,YAAY,SAAS,QAC/C,yCAAmB,IAAI;AAE3B,QAAM,OAAO,QAAQ,iBAAiB,QAAQ,WAAW,CAAC;AAC1D,QAAM,cAAc,QAAQ,iBAAiB,eAAe,WAAW,KAAK;AAC5E,QAAM,0BAA0B,QAAQ;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAGA,QAAM,aAAS,yCAAyB,SAAS,SAAS;AAG1D,QAAM,kBAAkB,IAAI,yBAAY;AAAA,IACvC,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM,OAAO,UAAU;AAItB,YAAM,cAAc,MAAM,KAAK;AAAA,QAC9B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAEA,UAAI;AAEH,cAAM,iBAAiB,MAAM,WAAW,WAAW,KAAK;AAGxD,YAAI,YAAY,MAAM,YAAY;AAAA,UACjC;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAGA,YAAI,eAAe,UAAU,SAAS,GAAG;AACxC,gBAAM,WAAY,MAAM,QAAQ;AAAA,YAC/B,wCAAoB;AAAA,YACpB;AAAA,UACD;AAEA,gBAAM,OAAO,UAAU,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG;AACzC,gBAAM,oBAAoB,MAAM,SAAS,kBAAkB,MAAM,KAAK;AACtE,sBAAY,kBAAkB,IAAI,CAAC,QAAQ;AAC1C,kBAAM,EAAE,gBAAgB,GAAG,SAAS,IAAI,IAAI;AAC5C,mBAAO,CAAC,EAAE,GAAG,KAAK,SAAS,GAAG,cAAc;AAAA,UAC7C,CAAC;AAAA,QACF;AAGA,eAAO,UACL,IAAI,CAAC,aAAa;AAClB,cAAI,yBAAyB;AAC5B,mBAAO,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,SAAS,CAAC,CAAC,EAAE;AAAA,UAC1D;AACA,iBAAO;AAAA,YACN,MAAM;AAAA,YACN,MAAM,KAAK,UAAU,EAAE,aAAa,SAAS,CAAC,EAAE,YAAY,CAAC;AAAA,UAC9D;AAAA,QACD,CAAC,EACA,OAAO,CAAC,aAAa,CAAC,CAAC,QAAQ;AAAA,MAClC,UAAE;AAED,aAAK,2BAA2B,WAAW;AAAA,MAC5C;AAAA,IACD;AAAA,EACD,CAAC;AAGD,SAAO;AAAA,IACN,cAAU,8BAAW,iBAAiB,OAAO;AAAA,EAC9C;AACD;","names":["import_n8n_workflow"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var GoogleGemini_node_exports = {};
|
|
20
|
+
__export(GoogleGemini_node_exports, {
|
|
21
|
+
GoogleGemini: () => GoogleGemini
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(GoogleGemini_node_exports);
|
|
24
|
+
var import_router = require("./actions/router");
|
|
25
|
+
var import_versionDescription = require("./actions/versionDescription");
|
|
26
|
+
var import_methods = require("./methods");
|
|
27
|
+
class GoogleGemini {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.description = import_versionDescription.versionDescription;
|
|
30
|
+
this.methods = {
|
|
31
|
+
listSearch: import_methods.listSearch
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async execute() {
|
|
35
|
+
return await import_router.router.call(this);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
GoogleGemini
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=GoogleGemini.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vendors/GoogleGemini/GoogleGemini.node.ts"],"sourcesContent":["import type { IExecuteFunctions, INodeType } from 'n8n-workflow';\n\nimport { router } from './actions/router';\nimport { versionDescription } from './actions/versionDescription';\nimport { listSearch } from './methods';\n\nexport class GoogleGemini implements INodeType {\n\tdescription = versionDescription;\n\n\tmethods = {\n\t\tlistSearch,\n\t};\n\n\tasync execute(this: IExecuteFunctions) {\n\t\treturn await router.call(this);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAuB;AACvB,gCAAmC;AACnC,qBAA2B;AAEpB,MAAM,aAAkC;AAAA,EAAxC;AACN,uBAAc;AAEd,mBAAU;AAAA,MACT;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,UAAiC;AACtC,WAAO,MAAM,qBAAO,KAAK,IAAI;AAAA,EAC9B;AACD;","names":[]}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var analyze_operation_exports = {};
|
|
20
|
+
__export(analyze_operation_exports, {
|
|
21
|
+
description: () => description,
|
|
22
|
+
execute: () => execute
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(analyze_operation_exports);
|
|
25
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
+
var import_baseAnalyze = require("../../helpers/baseAnalyze");
|
|
27
|
+
var import_descriptions = require("../descriptions");
|
|
28
|
+
const properties = [
|
|
29
|
+
(0, import_descriptions.modelRLC)("audioModelSearch"),
|
|
30
|
+
{
|
|
31
|
+
displayName: "Text Input",
|
|
32
|
+
name: "text",
|
|
33
|
+
type: "string",
|
|
34
|
+
placeholder: "e.g. What's in this audio?",
|
|
35
|
+
default: "What's in this audio?",
|
|
36
|
+
typeOptions: {
|
|
37
|
+
rows: 2
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
displayName: "Input Type",
|
|
42
|
+
name: "inputType",
|
|
43
|
+
type: "options",
|
|
44
|
+
default: "url",
|
|
45
|
+
options: [
|
|
46
|
+
{
|
|
47
|
+
name: "Audio URL(s)",
|
|
48
|
+
value: "url"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "Binary File(s)",
|
|
52
|
+
value: "binary"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
displayName: "URL(s)",
|
|
58
|
+
name: "audioUrls",
|
|
59
|
+
type: "string",
|
|
60
|
+
placeholder: "e.g. https://example.com/audio.mp3",
|
|
61
|
+
description: "URL(s) of the audio(s) to analyze, multiple URLs can be added separated by comma",
|
|
62
|
+
default: "",
|
|
63
|
+
displayOptions: {
|
|
64
|
+
show: {
|
|
65
|
+
inputType: ["url"]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
displayName: "Input Data Field Name(s)",
|
|
71
|
+
name: "binaryPropertyName",
|
|
72
|
+
type: "string",
|
|
73
|
+
default: "data",
|
|
74
|
+
placeholder: "e.g. data",
|
|
75
|
+
hint: "The name of the input field containing the binary file data to be processed",
|
|
76
|
+
description: "Name of the binary field(s) which contains the audio(s), seperate multiple field names with commas",
|
|
77
|
+
displayOptions: {
|
|
78
|
+
show: {
|
|
79
|
+
inputType: ["binary"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
displayName: "Simplify Output",
|
|
85
|
+
name: "simplify",
|
|
86
|
+
type: "boolean",
|
|
87
|
+
default: true,
|
|
88
|
+
description: "Whether to simplify the response or not"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
displayName: "Options",
|
|
92
|
+
name: "options",
|
|
93
|
+
placeholder: "Add Option",
|
|
94
|
+
type: "collection",
|
|
95
|
+
default: {},
|
|
96
|
+
options: [
|
|
97
|
+
{
|
|
98
|
+
displayName: "Length of Description (Max Tokens)",
|
|
99
|
+
description: "Fewer tokens will result in shorter, less detailed audio description",
|
|
100
|
+
name: "maxOutputTokens",
|
|
101
|
+
type: "number",
|
|
102
|
+
default: 300,
|
|
103
|
+
typeOptions: {
|
|
104
|
+
minValue: 1
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
const displayOptions = {
|
|
111
|
+
show: {
|
|
112
|
+
operation: ["analyze"],
|
|
113
|
+
resource: ["audio"]
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const description = (0, import_n8n_workflow.updateDisplayOptions)(displayOptions, properties);
|
|
117
|
+
async function execute(i) {
|
|
118
|
+
return await import_baseAnalyze.baseAnalyze.call(this, i, "audioUrls", "audio/mpeg");
|
|
119
|
+
}
|
|
120
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
+
0 && (module.exports = {
|
|
122
|
+
description,
|
|
123
|
+
execute
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=analyze.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vendors/GoogleGemini/actions/audio/analyze.operation.ts"],"sourcesContent":["import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport { baseAnalyze } from '../../helpers/baseAnalyze';\nimport { modelRLC } from '../descriptions';\n\nconst properties: INodeProperties[] = [\n\tmodelRLC('audioModelSearch'),\n\t{\n\t\tdisplayName: 'Text Input',\n\t\tname: 'text',\n\t\ttype: 'string',\n\t\tplaceholder: \"e.g. What's in this audio?\",\n\t\tdefault: \"What's in this audio?\",\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Input Type',\n\t\tname: 'inputType',\n\t\ttype: 'options',\n\t\tdefault: 'url',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Audio URL(s)',\n\t\t\t\tvalue: 'url',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Binary File(s)',\n\t\t\t\tvalue: 'binary',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'URL(s)',\n\t\tname: 'audioUrls',\n\t\ttype: 'string',\n\t\tplaceholder: 'e.g. https://example.com/audio.mp3',\n\t\tdescription: 'URL(s) of the audio(s) to analyze, multiple URLs can be added separated by comma',\n\t\tdefault: '',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tinputType: ['url'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Input Data Field Name(s)',\n\t\tname: 'binaryPropertyName',\n\t\ttype: 'string',\n\t\tdefault: 'data',\n\t\tplaceholder: 'e.g. data',\n\t\thint: 'The name of the input field containing the binary file data to be processed',\n\t\tdescription:\n\t\t\t'Name of the binary field(s) which contains the audio(s), seperate multiple field names with commas',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tinputType: ['binary'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Simplify Output',\n\t\tname: 'simplify',\n\t\ttype: 'boolean',\n\t\tdefault: true,\n\t\tdescription: 'Whether to simplify the response or not',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Length of Description (Max Tokens)',\n\t\t\t\tdescription: 'Fewer tokens will result in shorter, less detailed audio description',\n\t\t\t\tname: 'maxOutputTokens',\n\t\t\t\ttype: 'number',\n\t\t\t\tdefault: 300,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['analyze'],\n\t\tresource: ['audio'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\treturn await baseAnalyze.call(this, i, 'audioUrls', 'audio/mpeg');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAErC,yBAA4B;AAC5B,0BAAyB;AAEzB,MAAM,aAAgC;AAAA,MACrC,8BAAS,kBAAkB;AAAA,EAC3B;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS;AAAA,IACT,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,WAAW,CAAC,KAAK;AAAA,MAClB;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aACC;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,WAAW,CAAC,QAAQ;AAAA,MACrB;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,UACZ,UAAU;AAAA,QACX;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,SAAS;AAAA,IACrB,UAAU,CAAC,OAAO;AAAA,EACnB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,SAAO,MAAM,+BAAY,KAAK,MAAM,GAAG,aAAa,YAAY;AACjE;","names":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var audio_exports = {};
|
|
30
|
+
__export(audio_exports, {
|
|
31
|
+
analyze: () => analyze,
|
|
32
|
+
description: () => description,
|
|
33
|
+
transcribe: () => transcribe
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(audio_exports);
|
|
36
|
+
var analyze = __toESM(require("./analyze.operation"));
|
|
37
|
+
var transcribe = __toESM(require("./transcribe.operation"));
|
|
38
|
+
const description = [
|
|
39
|
+
{
|
|
40
|
+
displayName: "Operation",
|
|
41
|
+
name: "operation",
|
|
42
|
+
type: "options",
|
|
43
|
+
noDataExpression: true,
|
|
44
|
+
options: [
|
|
45
|
+
{
|
|
46
|
+
name: "Analyze Audio",
|
|
47
|
+
value: "analyze",
|
|
48
|
+
action: "Analyze audio",
|
|
49
|
+
description: "Take in audio and answer questions about it"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "Transcribe a Recording",
|
|
53
|
+
value: "transcribe",
|
|
54
|
+
action: "Transcribe a recording",
|
|
55
|
+
description: "Transcribes audio into the text"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
default: "transcribe",
|
|
59
|
+
displayOptions: {
|
|
60
|
+
show: {
|
|
61
|
+
resource: ["audio"]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
...analyze.description,
|
|
66
|
+
...transcribe.description
|
|
67
|
+
];
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
analyze,
|
|
71
|
+
description,
|
|
72
|
+
transcribe
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vendors/GoogleGemini/actions/audio/index.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nimport * as analyze from './analyze.operation';\nimport * as transcribe from './transcribe.operation';\n\nexport { analyze, transcribe };\n\nexport const description: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Operation',\n\t\tname: 'operation',\n\t\ttype: 'options',\n\t\tnoDataExpression: true,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Analyze Audio',\n\t\t\t\tvalue: 'analyze',\n\t\t\t\taction: 'Analyze audio',\n\t\t\t\tdescription: 'Take in audio and answer questions about it',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Transcribe a Recording',\n\t\t\t\tvalue: 'transcribe',\n\t\t\t\taction: 'Transcribe a recording',\n\t\t\t\tdescription: 'Transcribes audio into the text',\n\t\t\t},\n\t\t],\n\t\tdefault: 'transcribe',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['audio'],\n\t\t\t},\n\t\t},\n\t},\n\t...analyze.description,\n\t...transcribe.description,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,cAAyB;AACzB,iBAA4B;AAIrB,MAAM,cAAiC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,OAAO;AAAA,MACnB;AAAA,IACD;AAAA,EACD;AAAA,EACA,GAAG,QAAQ;AAAA,EACX,GAAG,WAAW;AACf;","names":[]}
|