@n8n/n8n-nodes-langchain 1.100.0 → 1.101.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/WeaviateApi.credentials.js +164 -0
- package/dist/credentials/WeaviateApi.credentials.js.map +1 -0
- package/dist/known/credentials.json +7 -0
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/agents/Agent/Agent.node.js +5 -2
- package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js +1 -4
- package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -1
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js +23 -6
- package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/description.js +0 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/description.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js +29 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/description.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V2/execute.js +94 -4
- 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/agents/OpenAiAssistant/OpenAiAssistant.node.js +0 -1
- package/dist/nodes/agents/OpenAiAssistant/OpenAiAssistant.node.js.map +1 -1
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +0 -1
- package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
- package/dist/nodes/chains/ChainSummarization/V1/ChainSummarizationV1.node.js +0 -1
- package/dist/nodes/chains/ChainSummarization/V1/ChainSummarizationV1.node.js.map +1 -1
- package/dist/nodes/chains/ChainSummarization/V2/ChainSummarizationV2.node.js +0 -1
- package/dist/nodes/chains/ChainSummarization/V2/ChainSummarizationV2.node.js.map +1 -1
- package/dist/nodes/code/Code.node.js.map +1 -1
- package/dist/nodes/document_loaders/DocumentBinaryInputLoader/DocumentBinaryInputLoader.node.js +0 -2
- package/dist/nodes/document_loaders/DocumentBinaryInputLoader/DocumentBinaryInputLoader.node.js.map +1 -1
- package/dist/nodes/document_loaders/DocumentDefaultDataLoader/DocumentDefaultDataLoader.node.js +0 -2
- package/dist/nodes/document_loaders/DocumentDefaultDataLoader/DocumentDefaultDataLoader.node.js.map +1 -1
- package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js +0 -2
- package/dist/nodes/document_loaders/DocumentGithubLoader/DocumentGithubLoader.node.js.map +1 -1
- package/dist/nodes/document_loaders/DocumentJSONInputLoader/DocumentJsonInputLoader.node.js +0 -2
- package/dist/nodes/document_loaders/DocumentJSONInputLoader/DocumentJsonInputLoader.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsCohere/EmbeddingsCohere.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsCohere/EmbeddingsCohere.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsGoogleGemini/EmbeddingsGoogleGemini.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsGoogleGemini/EmbeddingsGoogleGemini.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsGoogleVertex/EmbeddingsGoogleVertex.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsGoogleVertex/EmbeddingsGoogleVertex.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/EmbeddingsHuggingFaceInference.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsMistralCloud/EmbeddingsMistralCloud.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsMistralCloud/EmbeddingsMistralCloud.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsOllama/EmbeddingsOllama.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js +0 -2
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js +4 -5
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js +0 -3
- package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +6 -6
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +3 -1
- package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
- package/dist/nodes/llms/LMCohere/LmCohere.node.js +0 -3
- package/dist/nodes/llms/LMCohere/LmCohere.node.js.map +1 -1
- package/dist/nodes/llms/LMOllama/LmOllama.node.js +0 -3
- package/dist/nodes/llms/LMOllama/LmOllama.node.js.map +1 -1
- package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js +3 -4
- package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js +0 -3
- package/dist/nodes/llms/LMOpenHuggingFaceInference/LmOpenHuggingFaceInference.node.js.map +1 -1
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js +1 -5
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js.map +1 -1
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +3 -4
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js +3 -4
- package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js.map +1 -1
- package/dist/nodes/llms/LmChatGoogleGemini/LmChatGoogleGemini.node.js +0 -3
- package/dist/nodes/llms/LmChatGoogleGemini/LmChatGoogleGemini.node.js.map +1 -1
- package/dist/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.js +0 -3
- package/dist/nodes/llms/LmChatGoogleVertex/LmChatGoogleVertex.node.js.map +1 -1
- package/dist/nodes/llms/LmChatGroq/LmChatGroq.node.js +1 -4
- package/dist/nodes/llms/LmChatGroq/LmChatGroq.node.js.map +1 -1
- package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js +0 -3
- package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js.map +1 -1
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js +3 -3
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js.map +1 -1
- package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js +3 -4
- package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js.map +1 -1
- package/dist/nodes/llms/N8nLlmTracing.js.map +1 -1
- package/dist/nodes/llms/N8nNonEstimatingTracing.js.map +1 -1
- package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.js +1 -1
- package/dist/nodes/llms/n8nDefaultFailedAttemptHandler.js.map +1 -1
- package/dist/nodes/memory/MemoryBufferWindow/MemoryBufferWindow.node.js +0 -2
- package/dist/nodes/memory/MemoryBufferWindow/MemoryBufferWindow.node.js.map +1 -1
- package/dist/nodes/memory/MemoryChatRetriever/MemoryChatRetriever.node.js +0 -2
- package/dist/nodes/memory/MemoryChatRetriever/MemoryChatRetriever.node.js.map +1 -1
- package/dist/nodes/memory/MemoryManager/MemoryManager.node.js +0 -2
- package/dist/nodes/memory/MemoryManager/MemoryManager.node.js.map +1 -1
- package/dist/nodes/memory/MemoryMotorhead/MemoryMotorhead.node.js +0 -2
- package/dist/nodes/memory/MemoryMotorhead/MemoryMotorhead.node.js.map +1 -1
- package/dist/nodes/memory/MemoryPostgresChat/MemoryPostgresChat.node.js +0 -2
- package/dist/nodes/memory/MemoryPostgresChat/MemoryPostgresChat.node.js.map +1 -1
- package/dist/nodes/memory/MemoryRedisChat/MemoryRedisChat.node.js +0 -2
- package/dist/nodes/memory/MemoryRedisChat/MemoryRedisChat.node.js.map +1 -1
- package/dist/nodes/memory/MemoryXata/MemoryXata.node.js +0 -2
- package/dist/nodes/memory/MemoryXata/MemoryXata.node.js.map +1 -1
- package/dist/nodes/memory/MemoryZep/MemoryZep.node.js +0 -2
- package/dist/nodes/memory/MemoryZep/MemoryZep.node.js.map +1 -1
- package/dist/nodes/output_parser/OutputParserAutofixing/OutputParserAutofixing.node.js +0 -2
- package/dist/nodes/output_parser/OutputParserAutofixing/OutputParserAutofixing.node.js.map +1 -1
- package/dist/nodes/output_parser/OutputParserItemList/OutputParserItemList.node.js +0 -2
- package/dist/nodes/output_parser/OutputParserItemList/OutputParserItemList.node.js.map +1 -1
- package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js +0 -1
- package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js.map +1 -1
- package/dist/nodes/rerankers/RerankerCohere/RerankerCohere.node.js.map +1 -1
- package/dist/nodes/retrievers/RetrieverContextualCompression/RetrieverContextualCompression.node.js +0 -1
- package/dist/nodes/retrievers/RetrieverContextualCompression/RetrieverContextualCompression.node.js.map +1 -1
- package/dist/nodes/retrievers/RetrieverMultiQuery/RetrieverMultiQuery.node.js +0 -1
- package/dist/nodes/retrievers/RetrieverMultiQuery/RetrieverMultiQuery.node.js.map +1 -1
- package/dist/nodes/retrievers/RetrieverVectorStore/RetrieverVectorStore.node.js +0 -2
- package/dist/nodes/retrievers/RetrieverVectorStore/RetrieverVectorStore.node.js.map +1 -1
- package/dist/nodes/retrievers/RetrieverWorkflow/RetrieverWorkflow.node.js.map +1 -1
- package/dist/nodes/text_splitters/TextSplitterCharacterTextSplitter/TextSplitterCharacterTextSplitter.node.js +0 -2
- package/dist/nodes/text_splitters/TextSplitterCharacterTextSplitter/TextSplitterCharacterTextSplitter.node.js.map +1 -1
- package/dist/nodes/text_splitters/TextSplitterRecursiveCharacterTextSplitter/TextSplitterRecursiveCharacterTextSplitter.node.js +0 -2
- package/dist/nodes/text_splitters/TextSplitterRecursiveCharacterTextSplitter/TextSplitterRecursiveCharacterTextSplitter.node.js.map +1 -1
- package/dist/nodes/text_splitters/TextSplitterTokenSplitter/TextSplitterTokenSplitter.node.js +0 -2
- package/dist/nodes/text_splitters/TextSplitterTokenSplitter/TextSplitterTokenSplitter.node.js.map +1 -1
- package/dist/nodes/text_splitters/TextSplitterTokenSplitter/TokenTextSplitter.js.map +1 -1
- package/dist/nodes/tools/ToolCalculator/ToolCalculator.node.js +0 -2
- package/dist/nodes/tools/ToolCalculator/ToolCalculator.node.js.map +1 -1
- package/dist/nodes/tools/ToolCode/ToolCode.node.js +0 -2
- package/dist/nodes/tools/ToolCode/ToolCode.node.js.map +1 -1
- package/dist/nodes/tools/ToolHttpRequest/ToolHttpRequest.node.js +0 -2
- package/dist/nodes/tools/ToolHttpRequest/ToolHttpRequest.node.js.map +1 -1
- package/dist/nodes/tools/ToolHttpRequest/utils.js.map +1 -1
- package/dist/nodes/tools/ToolSerpApi/ToolSerpApi.node.js +0 -2
- package/dist/nodes/tools/ToolSerpApi/ToolSerpApi.node.js.map +1 -1
- package/dist/nodes/tools/ToolThink/ToolThink.node.js.map +1 -1
- package/dist/nodes/tools/ToolVectorStore/ToolVectorStore.node.js +0 -2
- package/dist/nodes/tools/ToolVectorStore/ToolVectorStore.node.js.map +1 -1
- package/dist/nodes/tools/ToolWikipedia/ToolWikipedia.node.js +0 -2
- package/dist/nodes/tools/ToolWikipedia/ToolWikipedia.node.js.map +1 -1
- package/dist/nodes/tools/ToolWolframAlpha/ToolWolframAlpha.node.js +0 -2
- package/dist/nodes/tools/ToolWolframAlpha/ToolWolframAlpha.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v1/versionDescription.js +0 -2
- package/dist/nodes/tools/ToolWorkflow/v1/versionDescription.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/v2/versionDescription.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +215 -153
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js +1 -1
- package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreInMemoryInsert/VectorStoreInMemoryInsert.node.js +0 -1
- package/dist/nodes/vector_store/VectorStoreInMemoryInsert/VectorStoreInMemoryInsert.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreInMemoryLoad/VectorStoreInMemoryLoad.node.js +0 -1
- package/dist/nodes/vector_store/VectorStoreInMemoryLoad/VectorStoreInMemoryLoad.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js +2 -2
- package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.js +242 -0
- package/dist/nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.js.map +1 -0
- package/dist/nodes/vector_store/VectorStoreWeaviate/Weaviate.utils.js +127 -0
- package/dist/nodes/vector_store/VectorStoreWeaviate/Weaviate.utils.js.map +1 -0
- package/dist/nodes/vector_store/VectorStoreWeaviate/weaviate.svg +2 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +0 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js +15 -2
- package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js.map +1 -1
- package/dist/nodes/vector_store/shared/descriptions.js +26 -2
- package/dist/nodes/vector_store/shared/descriptions.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js +0 -1
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.js.map +1 -1
- package/dist/types/credentials.json +1 -0
- package/dist/types/nodes.json +4 -3
- package/dist/utils/httpProxyAgent.js +20 -6
- package/dist/utils/httpProxyAgent.js.map +1 -1
- package/dist/utils/logWrapper.js.map +1 -1
- package/package.json +21 -15
|
@@ -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\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],\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{\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},\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// CORS parameters are only valid for when chat is used in hosted or webhook mode\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Allowed Origins (CORS)',\n\t\t\t\t\t\tname: 'allowedOrigins',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdefault: '*',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Comma-separated list of URLs allowed for cross-origin non-preflight requests. Use * (default) to allow all origins.',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat', 'webhook'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t...allowFileUploadsOption,\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t...allowedFileMimeTypeOption,\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Input Placeholder',\n\t\t\t\t\t\tname: 'inputPlaceholder',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: 'Type your question..',\n\t\t\t\t\t\tplaceholder: 'e.g. Type your message here',\n\t\t\t\t\t\tdescription: 'Shown as placeholder text in the chat input field',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Load Previous Session',\n\t\t\t\t\t\tname: 'loadPreviousSession',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Off',\n\t\t\t\t\t\t\t\tvalue: 'notSupported',\n\t\t\t\t\t\t\t\tdescription: 'Loading messages of previous session is turned off',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'From Memory',\n\t\t\t\t\t\t\t\tvalue: 'memory',\n\t\t\t\t\t\t\t\tdescription: 'Load session messages from memory',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Manually',\n\t\t\t\t\t\t\t\tvalue: 'manually',\n\t\t\t\t\t\t\t\tdescription: 'Manually return messages of session',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'notSupported',\n\t\t\t\t\t\tdescription: 'If loading messages of a previous session should be enabled',\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: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'When Last Node Finishes',\n\t\t\t\t\t\t\t\tvalue: 'lastNode',\n\t\t\t\t\t\t\t\tdescription: 'Returns data of the last-executed node',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"Using 'Respond to Webhook' Node\",\n\t\t\t\t\t\t\t\tvalue: 'responseNode',\n\t\t\t\t\t\t\t\tdescription: 'Response defined in that node',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\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\t{\n\t\t\t\t\t\tdisplayName: 'Require Button Click to Start Chat',\n\t\t\t\t\t\tname: 'showWelcomeScreen',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tdescription: 'Whether to show the welcome screen at the start of the chat',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Start Conversation Button Text',\n\t\t\t\t\t\tname: 'getStarted',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\tshowWelcomeScreen: [true],\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: 'New Conversation',\n\t\t\t\t\t\tplaceholder: 'e.g. New Conversation',\n\t\t\t\t\t\tdescription: 'Shown as part of the welcome screen, in the middle of the chat window',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Subtitle',\n\t\t\t\t\t\tname: 'subtitle',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: \"Start a chat. We're here to help you 24/7.\",\n\t\t\t\t\t\tplaceholder: \"e.g. We're here for you\",\n\t\t\t\t\t\tdescription: 'Shown at the top of the chat, under the title',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Title',\n\t\t\t\t\t\tname: 'title',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: 'Hi there! 👋',\n\t\t\t\t\t\tplaceholder: 'e.g. Welcome',\n\t\t\t\t\t\tdescription: 'Shown at the top of the chat',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Custom Chat Styling',\n\t\t\t\t\t\tname: 'customCss',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\trows: 10,\n\t\t\t\t\t\t\teditor: 'cssEditor',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/mode': ['hostedChat'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\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\t\t\t\t\tdescription: 'Override default styling of the public chat interface with CSS',\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 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\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;AAEO,MAAM,oBAAoB,yBAAK;AAAA,EAA/B;AAAA;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,SAAS;AAAA,MACjB,SAAS,CAAC,GAAG,GAAG;AAAA,MAChB,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,YAAY;AAAA,QACzB,WAAW;AAAA,UACV,sBAAsB;A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AQ,YAAY,YAAY,KAAM,CAAC,GAC9D,OAAO,CAAC,YAAY,CAAC,SAAS,mBAAmB,UAAU,EAC3D,IAAI,CAAC,YAAY,SAAS,OAAO,CAAC;AACpC,eAAO;AAAA,UACN,iBAAiB,EAAE,MAAM,SAAS;AAAA,QACnC;AAAA,MACD,WAAW,CAAC,SAAS,uBAAuB,SAAS,wBAAwB,gBAAgB;AAE5F,eAAO;AAAA,UACN,iBAAiB,EAAE,MAAM,CAAC,EAAE;AAAA,QAC7B;AAAA,MACD;AAAA,IACD;AAEA,QAAI;AACJ,UAAM,kBAA+B,EAAE,QAAQ,IAAI;AACnD,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 { 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: [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,sBAAsB;AAAA,EAC3B;AAAA,IACC,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AACD;AAEA,MAAM,mCAAmC;AAAA,EACxC,GAAG;AAAA,EACH;AAAA,IACC,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,EACd;AACD;AAEA,MAAM,sBAAyC;AAAA;AAAA,EAE9C;AAA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A,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"]}
|
|
@@ -150,7 +150,7 @@ class VectorStoreInMemory extends (0, import_createVectorStoreNode.createVectorS
|
|
|
150
150
|
// Real Embeddings are provided when executing the node
|
|
151
151
|
this.logger
|
|
152
152
|
);
|
|
153
|
-
const memoryKey =
|
|
153
|
+
const memoryKey = name ? name : DEFAULT_MEMORY_KEY;
|
|
154
154
|
await vectorStoreSingleton.getVectorStore(memoryKey);
|
|
155
155
|
return memoryKey;
|
|
156
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { MemoryVectorStore } from 'langchain/vectorstores/memory';\nimport {\n\ttype INodeProperties,\n\ttype ILoadOptionsFunctions,\n\ttype INodeListSearchResult,\n\ttype IDataObject,\n\ttype NodeParameterValueType,\n\ttype IExecuteFunctions,\n\ttype ISupplyDataFunctions,\n\tApplicationError,\n} from 'n8n-workflow';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\nimport { MemoryVectorStoreManager } from '../shared/MemoryManager/MemoryVectorStoreManager';\n\nconst warningBanner: INodeProperties = {\n\tdisplayName:\n\t\t'<strong>For experimental use only</strong>: Data is stored in memory and will be lost if n8n restarts. Data may also be cleared if available memory gets low, and is accessible to all users of this instance. <a href=\"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/\">More info</a>',\n\tname: 'notice',\n\ttype: 'notice',\n\tdefault: '',\n};\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Clear Store',\n\t\tname: 'clearStore',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription: 'Whether to clear the store before inserting new data',\n\t},\n\twarningBanner,\n];\n\nconst DEFAULT_MEMORY_KEY = 'vector_store_key';\n\nfunction getMemoryKey(context: IExecuteFunctions | ISupplyDataFunctions, itemIndex: number) {\n\tconst node = context.getNode();\n\tif (node.typeVersion <= 1.1) {\n\t\tconst memoryKeyParam = context.getNodeParameter('memoryKey', itemIndex) as string;\n\t\tconst workflowId = context.getWorkflow().id;\n\n\t\treturn `${workflowId}__${memoryKeyParam}`;\n\t} else {\n\t\tconst memoryKeyParam = context.getNodeParameter('memoryKey', itemIndex) as {\n\t\t\tmode: string;\n\t\t\tvalue: string;\n\t\t};\n\n\t\treturn memoryKeyParam.value;\n\t}\n}\n\nexport class VectorStoreInMemory extends createVectorStoreNode<MemoryVectorStore>({\n\tmeta: {\n\t\tdisplayName: 'Simple Vector Store',\n\t\tname: 'vectorStoreInMemory',\n\t\tdescription: 'The easiest way to experiment with vector stores, without external setup.',\n\t\ticon: 'fa:database',\n\t\ticonColor: 'black',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/',\n\t\tcategories: ['AI'],\n\t\tsubcategories: {\n\t\t\tAI: ['Vector Stores', 'Tools', 'Root Nodes'],\n\t\t\t'Vector Stores': ['For Beginners'],\n\t\t\tTools: ['Other Tools'],\n\t\t},\n\t},\n\tsharedFields: [\n\t\t{\n\t\t\tdisplayName: 'Memory Key',\n\t\t\tname: 'memoryKey',\n\t\t\ttype: 'string',\n\t\t\tdefault: DEFAULT_MEMORY_KEY,\n\t\t\tdescription:\n\t\t\t\t'The key to use to store the vector memory in the workflow data. The key will be prefixed with the workflow ID to avoid collisions.',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\t'@version': [{ _cnd: { lte: 1.1 } }],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Memory Key',\n\t\t\tname: 'memoryKey',\n\t\t\ttype: 'resourceLocator',\n\t\t\trequired: true,\n\t\t\tdefault: { mode: 'list', value: DEFAULT_MEMORY_KEY },\n\t\t\tdescription:\n\t\t\t\t'The key to use to store the vector memory in the workflow data. These keys are shared between workflows.',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t},\n\t\t\t},\n\t\t\tmodes: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\tname: 'list',\n\t\t\t\t\ttype: 'list',\n\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\tsearchListMethod: 'vectorStoresSearch',\n\t\t\t\t\t\tsearchable: true,\n\t\t\t\t\t\tallowNewResource: {\n\t\t\t\t\t\t\tlabel: 'resourceLocator.mode.list.addNewResource.vectorStoreInMemory',\n\t\t\t\t\t\t\tdefaultName: DEFAULT_MEMORY_KEY,\n\t\t\t\t\t\t\tmethod: 'createVectorStore',\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: 'Manual',\n\t\t\t\t\tname: 'id',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tplaceholder: DEFAULT_MEMORY_KEY,\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n\tmethods: {\n\t\tlistSearch: {\n\t\t\tasync vectorStoresSearch(\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tfilter?: string,\n\t\t\t): Promise<INodeListSearchResult> {\n\t\t\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(\n\t\t\t\t\t{} as Embeddings, // Real Embeddings are provided when executing the node\n\t\t\t\t\tthis.logger,\n\t\t\t\t);\n\n\t\t\t\tconst searchOptions: INodeListSearchResult['results'] = vectorStoreSingleton\n\t\t\t\t\t.getMemoryKeysList()\n\t\t\t\t\t.map((key) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tname: key,\n\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\tlet results = searchOptions;\n\t\t\t\tif (filter) {\n\t\t\t\t\tresults = results.filter((option) => option.name.includes(filter));\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tresults,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\tactionHandler: {\n\t\t\tasync createVectorStore(\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tpayload: string | IDataObject | undefined,\n\t\t\t): Promise<NodeParameterValueType> {\n\t\t\t\tif (!payload || typeof payload === 'string') {\n\t\t\t\t\tthrow new ApplicationError('Invalid payload type');\n\t\t\t\t}\n\n\t\t\t\tconst { name } = payload;\n\n\t\t\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(\n\t\t\t\t\t{} as Embeddings, // Real Embeddings are provided when executing the node\n\t\t\t\t\tthis.logger,\n\t\t\t\t);\n\n\t\t\t\tconst memoryKey =
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { MemoryVectorStore } from 'langchain/vectorstores/memory';\nimport {\n\ttype INodeProperties,\n\ttype ILoadOptionsFunctions,\n\ttype INodeListSearchResult,\n\ttype IDataObject,\n\ttype NodeParameterValueType,\n\ttype IExecuteFunctions,\n\ttype ISupplyDataFunctions,\n\tApplicationError,\n} from 'n8n-workflow';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\nimport { MemoryVectorStoreManager } from '../shared/MemoryManager/MemoryVectorStoreManager';\n\nconst warningBanner: INodeProperties = {\n\tdisplayName:\n\t\t'<strong>For experimental use only</strong>: Data is stored in memory and will be lost if n8n restarts. Data may also be cleared if available memory gets low, and is accessible to all users of this instance. <a href=\"https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/\">More info</a>',\n\tname: 'notice',\n\ttype: 'notice',\n\tdefault: '',\n};\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Clear Store',\n\t\tname: 'clearStore',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription: 'Whether to clear the store before inserting new data',\n\t},\n\twarningBanner,\n];\n\nconst DEFAULT_MEMORY_KEY = 'vector_store_key';\n\nfunction getMemoryKey(context: IExecuteFunctions | ISupplyDataFunctions, itemIndex: number) {\n\tconst node = context.getNode();\n\tif (node.typeVersion <= 1.1) {\n\t\tconst memoryKeyParam = context.getNodeParameter('memoryKey', itemIndex) as string;\n\t\tconst workflowId = context.getWorkflow().id;\n\n\t\treturn `${workflowId}__${memoryKeyParam}`;\n\t} else {\n\t\tconst memoryKeyParam = context.getNodeParameter('memoryKey', itemIndex) as {\n\t\t\tmode: string;\n\t\t\tvalue: string;\n\t\t};\n\n\t\treturn memoryKeyParam.value;\n\t}\n}\n\nexport class VectorStoreInMemory extends createVectorStoreNode<MemoryVectorStore>({\n\tmeta: {\n\t\tdisplayName: 'Simple Vector Store',\n\t\tname: 'vectorStoreInMemory',\n\t\tdescription: 'The easiest way to experiment with vector stores, without external setup.',\n\t\ticon: 'fa:database',\n\t\ticonColor: 'black',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/',\n\t\tcategories: ['AI'],\n\t\tsubcategories: {\n\t\t\tAI: ['Vector Stores', 'Tools', 'Root Nodes'],\n\t\t\t'Vector Stores': ['For Beginners'],\n\t\t\tTools: ['Other Tools'],\n\t\t},\n\t},\n\tsharedFields: [\n\t\t{\n\t\t\tdisplayName: 'Memory Key',\n\t\t\tname: 'memoryKey',\n\t\t\ttype: 'string',\n\t\t\tdefault: DEFAULT_MEMORY_KEY,\n\t\t\tdescription:\n\t\t\t\t'The key to use to store the vector memory in the workflow data. The key will be prefixed with the workflow ID to avoid collisions.',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\t'@version': [{ _cnd: { lte: 1.1 } }],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Memory Key',\n\t\t\tname: 'memoryKey',\n\t\t\ttype: 'resourceLocator',\n\t\t\trequired: true,\n\t\t\tdefault: { mode: 'list', value: DEFAULT_MEMORY_KEY },\n\t\t\tdescription:\n\t\t\t\t'The key to use to store the vector memory in the workflow data. These keys are shared between workflows.',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t},\n\t\t\t},\n\t\t\tmodes: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\tname: 'list',\n\t\t\t\t\ttype: 'list',\n\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\tsearchListMethod: 'vectorStoresSearch',\n\t\t\t\t\t\tsearchable: true,\n\t\t\t\t\t\tallowNewResource: {\n\t\t\t\t\t\t\tlabel: 'resourceLocator.mode.list.addNewResource.vectorStoreInMemory',\n\t\t\t\t\t\t\tdefaultName: DEFAULT_MEMORY_KEY,\n\t\t\t\t\t\t\tmethod: 'createVectorStore',\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: 'Manual',\n\t\t\t\t\tname: 'id',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tplaceholder: DEFAULT_MEMORY_KEY,\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n\tmethods: {\n\t\tlistSearch: {\n\t\t\tasync vectorStoresSearch(\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tfilter?: string,\n\t\t\t): Promise<INodeListSearchResult> {\n\t\t\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(\n\t\t\t\t\t{} as Embeddings, // Real Embeddings are provided when executing the node\n\t\t\t\t\tthis.logger,\n\t\t\t\t);\n\n\t\t\t\tconst searchOptions: INodeListSearchResult['results'] = vectorStoreSingleton\n\t\t\t\t\t.getMemoryKeysList()\n\t\t\t\t\t.map((key) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tname: key,\n\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\tlet results = searchOptions;\n\t\t\t\tif (filter) {\n\t\t\t\t\tresults = results.filter((option) => option.name.includes(filter));\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tresults,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\tactionHandler: {\n\t\t\tasync createVectorStore(\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tpayload: string | IDataObject | undefined,\n\t\t\t): Promise<NodeParameterValueType> {\n\t\t\t\tif (!payload || typeof payload === 'string') {\n\t\t\t\t\tthrow new ApplicationError('Invalid payload type');\n\t\t\t\t}\n\n\t\t\t\tconst { name } = payload;\n\n\t\t\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(\n\t\t\t\t\t{} as Embeddings, // Real Embeddings are provided when executing the node\n\t\t\t\t\tthis.logger,\n\t\t\t\t);\n\n\t\t\t\tconst memoryKey = name ? (name as string) : DEFAULT_MEMORY_KEY;\n\t\t\t\tawait vectorStoreSingleton.getVectorStore(memoryKey);\n\n\t\t\t\treturn memoryKey;\n\t\t\t},\n\t\t},\n\t},\n\tinsertFields,\n\tloadFields: [warningBanner],\n\tretrieveFields: [warningBanner],\n\tasync getVectorStoreClient(context, _filter, embeddings, itemIndex) {\n\t\tconst memoryKey = getMemoryKey(context, itemIndex);\n\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(embeddings, context.logger);\n\n\t\treturn await vectorStoreSingleton.getVectorStore(memoryKey);\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\tconst memoryKey = getMemoryKey(context, itemIndex);\n\t\tconst clearStore = context.getNodeParameter('clearStore', itemIndex) as boolean;\n\t\tconst vectorStoreInstance = MemoryVectorStoreManager.getInstance(embeddings, context.logger);\n\n\t\tawait vectorStoreInstance.addDocuments(memoryKey, documents, clearStore);\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BASO;AAEP,mCAAsC;AACtC,sCAAyC;AAEzC,MAAM,gBAAiC;AAAA,EACtC,aACC;AAAA,EACD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AACV;AAEA,MAAM,eAAkC;AAAA,EACvC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA;AACD;AAEA,MAAM,qBAAqB;AAE3B,SAAS,aAAa,SAAmD,WAAmB;AAC3F,QAAM,OAAO,QAAQ,QAAQ;AAC7B,MAAI,KAAK,eAAe,KAAK;AAC5B,UAAM,iBAAiB,QAAQ,iBAAiB,aAAa,SAAS;AACtE,U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,oBAAoB,SAAS,YAAY,WAAW,WAAW;AACpE,UAAM,YAAY,aAAa,SAAS,SAAS;AACjD,UAAM,aAAa,QAAQ,iBAAiB,cAAc,SAAS;AACnE,UAAM,sBAAsB,yDAAyB,YAAY,YAAY,QAAQ,MAAM;AAE3F,UAAM,oBAAoB,aAAa,WAAW,WAAW,UAAU;AAAA,EACxE;AACD,CAAC,EAAE;AAAC;","names":[]}
|
package/dist/nodes/vector_store/VectorStoreInMemoryInsert/VectorStoreInMemoryInsert.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreInMemoryInsert/VectorStoreInMemoryInsert.node.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreInMemoryInsert/VectorStoreInMemoryInsert.node.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport type { Document } from 'langchain/document';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeExecutionData,\n\ttype IExecuteFunctions,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n} from 'n8n-workflow';\n\nimport type { N8nJsonLoader } from '@utils/N8nJsonLoader';\n\nimport { MemoryVectorStoreManager } from '../shared/MemoryManager/MemoryVectorStoreManager';\nimport { processDocuments } from '../shared/processDocuments';\n\n// This node is deprecated. Use VectorStoreInMemory instead.\nexport class VectorStoreInMemoryInsert implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'In Memory Vector Store Insert',\n\t\tname: 'vectorStoreInMemoryInsert',\n\t\ticon: 'fa:database',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\thidden: true,\n\t\tdescription: 'Insert data into an in-memory vector store',\n\t\tdefaults: {\n\t\t\tname: 'In Memory Vector Store Insert',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Vector Stores'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [\n\t\t\tNodeConnectionTypes.Main,\n\t\t\t{\n\t\t\t\tdisplayName: 'Document',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiDocument,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Embedding',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiEmbedding,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'The embbded data are stored in the server memory, so they will be lost when the server is restarted. Additionally, if the amount of data is too large, it may cause the server to crash due to insufficient memory.',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Clear Store',\n\t\t\t\tname: 'clearStore',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: false,\n\t\t\t\tdescription: 'Whether to clear the store before inserting new data',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Memory Key',\n\t\t\t\tname: 'memoryKey',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'vector_store_key',\n\t\t\t\tdescription:\n\t\t\t\t\t'The key to use to store the vector memory in the workflow data. The key will be prefixed with the workflow ID to avoid collisions.',\n\t\t\t},\n\t\t],\n\t};\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst items = this.getInputData(0);\n\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t0,\n\t\t)) as Embeddings;\n\n\t\tconst memoryKey = this.getNodeParameter('memoryKey', 0) as string;\n\t\tconst clearStore = this.getNodeParameter('clearStore', 0) as boolean;\n\t\tconst documentInput = (await this.getInputConnectionData(NodeConnectionTypes.AiDocument, 0)) as\n\t\t\t| N8nJsonLoader\n\t\t\t| Array<Document<Record<string, unknown>>>;\n\n\t\tconst { processedDocuments, serializedDocuments } = await processDocuments(\n\t\t\tdocumentInput,\n\t\t\titems,\n\t\t);\n\n\t\tconst workflowId = this.getWorkflow().id;\n\n\t\tconst vectorStoreInstance = MemoryVectorStoreManager.getInstance(embeddings, this.logger);\n\t\tawait vectorStoreInstance.addDocuments(\n\t\t\t`${workflowId}__${memoryKey}`,\n\t\t\tprocessedDocuments,\n\t\t\tclearStore,\n\t\t);\n\n\t\treturn [serializedDocuments];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAMO;AAIP,sCAAyC;AACzC,8BAAiC;AAG1B,MAAM,0BAA+C;AAAA,EAArD;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,eAAe;AAAA,QACrB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ;AAAA,QACP,wCAAoB;AAAA,QACpB;AAAA,UACC,aAAa;AAAA,UACb,gBAAgB;AAAA,UAChB,MAAM,wCAAoB;AAAA,UAC1B,UAAU;AAAA,QACX;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,gBAAgB;AAAA,UAChB,MAAM,wCAAoB;AAAA,UAC1B,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,SAAS,CAAC,wCAAoB,IAAI;AAAA,MAClC,YAAY;AAAA,QACX;AAAA,UACC,aACC;AAAA,UACD,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,QACV;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,QACd;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aACC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,UAAkE;AACvE,UAAM,QAAQ,KAAK,aAAa,CAAC;AACjC,UAAM,aAAc,MAAM,KAAK;AAAA,MAC9B,wCAAoB;AAAA,MACpB;AAAA,IACD;AAEA,UAAM,YAAY,KAAK,iBAAiB,aAAa,CAAC;AACtD,UAAM,aAAa,KAAK,iBAAiB,cAAc,CAAC;AACxD,UAAM,gBAAiB,MAAM,KAAK,uBAAuB,wCAAoB,YAAY,CAAC;AAI1F,UAAM,EAAE,oBAAoB,oBAAoB,IAAI,UAAM;AAAA,MACzD;AAAA,MACA;AAAA,IACD;AAEA,UAAM,aAAa,KAAK,YAAY,EAAE;AAEtC,UAAM,sBAAsB,yDAAyB,YAAY,YAAY,KAAK,MAAM;AACxF,UAAM,oBAAoB;AAAA,MACzB,GAAG,UAAU,KAAK,SAAS;AAAA,MAC3B;AAAA,MACA;AAAA,IACD;AAEA,WAAO,CAAC,mBAAmB;AAAA,EAC5B;AACD;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreInMemoryLoad/VectorStoreInMemoryLoad.node.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreInMemoryLoad/VectorStoreInMemoryLoad.node.ts"],"sourcesContent":["import type { Embeddings } from '@langchain/core/embeddings';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { logWrapper } from '@utils/logWrapper';\n\nimport { MemoryVectorStoreManager } from '../shared/MemoryManager/MemoryVectorStoreManager';\n\n// This node is deprecated. Use VectorStoreInMemory instead.\nexport class VectorStoreInMemoryLoad implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'In Memory Vector Store Load',\n\t\tname: 'vectorStoreInMemoryLoad',\n\t\ticon: 'fa:database',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\thidden: true,\n\t\tdescription: 'Load embedded data from an in-memory vector store',\n\t\tdefaults: {\n\t\t\tname: 'In Memory Vector Store Load',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Vector Stores'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreinmemory/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Embedding',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiEmbedding,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\toutputs: [NodeConnectionTypes.AiVectorStore],\n\t\toutputNames: ['Vector Store'],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Memory Key',\n\t\t\t\tname: 'memoryKey',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'vector_store_key',\n\t\t\t\tdescription:\n\t\t\t\t\t'The key to use to store the vector memory in the workflow data. The key will be prefixed with the workflow ID to avoid collisions.',\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\titemIndex,\n\t\t)) as Embeddings;\n\n\t\tconst workflowId = this.getWorkflow().id;\n\t\tconst memoryKey = this.getNodeParameter('memoryKey', 0) as string;\n\n\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(embeddings, this.logger);\n\t\tconst vectorStoreInstance = await vectorStoreSingleton.getVectorStore(\n\t\t\t`${workflowId}__${memoryKey}`,\n\t\t);\n\n\t\treturn {\n\t\t\tresponse: logWrapper(vectorStoreInstance, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAMO;AAEP,wBAA2B;AAE3B,sCAAyC;AAGlC,MAAM,wBAA6C;AAAA,EAAnD;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,eAAe;AAAA,QACrB;AAAA,QACA,WAAW;AAAA,UACV,sBAAsB;AAAA,YACrB;AAAA,cACC,KAAK;AAAA,YACN;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MAEA,QAAQ;AAAA,QACP;AAAA,UACC,aAAa;AAAA,UACb,gBAAgB;AAAA,UAChB,MAAM,wCAAoB;AAAA,UAC1B,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,SAAS,CAAC,wCAAoB,aAAa;AAAA,MAC3C,aAAa,CAAC,cAAc;AAAA,MAC5B,YAAY;AAAA,QACX;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aACC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,aAAc,MAAM,KAAK;AAAA,MAC9B,wCAAoB;AAAA,MACpB;AAAA,IACD;AAEA,UAAM,aAAa,KAAK,YAAY,EAAE;AACtC,UAAM,YAAY,KAAK,iBAAiB,aAAa,CAAC;AAEtD,UAAM,uBAAuB,yDAAyB,YAAY,YAAY,KAAK,MAAM;AACzF,UAAM,sBAAsB,MAAM,qBAAqB;AAAA,MACtD,GAAG,UAAU,KAAK,SAAS;AAAA,IAC5B;AAEA,WAAO;AAAA,MACN,cAAU,8BAAW,qBAAqB,IAAI;AAAA,IAC/C;AAAA,EACD;AACD;","names":[]}
|
|
@@ -225,7 +225,7 @@ class VectorStorePGVector extends (0, import_createVectorStoreNode.createVectorS
|
|
|
225
225
|
0,
|
|
226
226
|
{}
|
|
227
227
|
);
|
|
228
|
-
if (collectionOptions
|
|
228
|
+
if (collectionOptions?.useCollection) {
|
|
229
229
|
config.collectionName = collectionOptions.collectionName;
|
|
230
230
|
config.collectionTableName = collectionOptions.collectionTableName;
|
|
231
231
|
}
|
|
@@ -258,7 +258,7 @@ class VectorStorePGVector extends (0, import_createVectorStoreNode.createVectorS
|
|
|
258
258
|
0,
|
|
259
259
|
{}
|
|
260
260
|
);
|
|
261
|
-
if (collectionOptions
|
|
261
|
+
if (collectionOptions?.useCollection) {
|
|
262
262
|
config.collectionName = collectionOptions.collectionName;
|
|
263
263
|
config.collectionTableName = collectionOptions.collectionTableName;
|
|
264
264
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.ts"],"sourcesContent":["import {\n\tPGVectorStore,\n\ttype DistanceStrategy,\n\ttype PGVectorStoreArgs,\n} from '@langchain/community/vectorstores/pgvector';\nimport type { EmbeddingsInterface } from '@langchain/core/embeddings';\nimport { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/transport/index';\nimport type { PostgresNodeCredentials } from 'n8n-nodes-base/dist/nodes/Postgres/v2/helpers/interfaces';\nimport type { INodeProperties } from 'n8n-workflow';\nimport type pg from 'pg';\n\nimport { metadataFilterField } from '@utils/sharedFields';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\n\ntype CollectionOptions = {\n\tuseCollection?: boolean;\n\tcollectionName?: string;\n\tcollectionTableName?: string;\n};\n\ntype ColumnOptions = {\n\tidColumnName: string;\n\tvectorColumnName: string;\n\tcontentColumnName: string;\n\tmetadataColumnName: string;\n};\n\nconst sharedFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Table Name',\n\t\tname: 'tableName',\n\t\ttype: 'string',\n\t\tdefault: 'n8n_vectors',\n\t\tdescription:\n\t\t\t'The table name to store the vectors in. If table does not exist, it will be created.',\n\t},\n];\n\nconst collectionField: INodeProperties = {\n\tdisplayName: 'Collection',\n\tname: 'collection',\n\ttype: 'fixedCollection',\n\tdescription: 'Collection of vectors',\n\tdefault: {\n\t\tvalues: {\n\t\t\tuseCollection: false,\n\t\t\tcollectionName: 'n8n',\n\t\t\tcollectionTable: 'n8n_vector_collections',\n\t\t},\n\t},\n\ttypeOptions: {},\n\tplaceholder: 'Add Collection Settings',\n\toptions: [\n\t\t{\n\t\t\tname: 'values',\n\t\t\tdisplayName: 'Collection Settings',\n\t\t\tvalues: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Use Collection',\n\t\t\t\t\tname: 'useCollection',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Collection Name',\n\t\t\t\t\tname: 'collectionName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'n8n',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdisplayOptions: { show: { useCollection: [true] } },\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Collection Table Name',\n\t\t\t\t\tname: 'collectionTableName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'n8n_vector_collections',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdisplayOptions: { show: { useCollection: [true] } },\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n};\n\nconst columnNamesField: INodeProperties = {\n\tdisplayName: 'Column Names',\n\tname: 'columnNames',\n\ttype: 'fixedCollection',\n\tdescription: 'The names of the columns in the PGVector table',\n\tdefault: {\n\t\tvalues: {\n\t\t\tidColumnName: 'id',\n\t\t\tvectorColumnName: 'embedding',\n\t\t\tcontentColumnName: 'text',\n\t\t\tmetadataColumnName: 'metadata',\n\t\t},\n\t},\n\ttypeOptions: {},\n\tplaceholder: 'Set Column Names',\n\toptions: [\n\t\t{\n\t\t\tname: 'values',\n\t\t\tdisplayName: 'Column Name Settings',\n\t\t\tvalues: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'ID Column Name',\n\t\t\t\t\tname: 'idColumnName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'id',\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Vector Column Name',\n\t\t\t\t\tname: 'vectorColumnName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'embedding',\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Content Column Name',\n\t\t\t\t\tname: 'contentColumnName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'text',\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Metadata Column Name',\n\t\t\t\t\tname: 'metadataColumnName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'metadata',\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n};\n\nconst distanceStrategyField: INodeProperties = {\n\tdisplayName: 'Distance Strategy',\n\tname: 'distanceStrategy',\n\ttype: 'options',\n\tdefault: 'cosine',\n\tdescription: 'The method to calculate the distance between two vectors',\n\toptions: [\n\t\t{\n\t\t\tname: 'Cosine',\n\t\t\tvalue: 'cosine',\n\t\t},\n\t\t{\n\t\t\tname: 'Inner Product',\n\t\t\tvalue: 'innerProduct',\n\t\t},\n\t\t{\n\t\t\tname: 'Euclidean',\n\t\t\tvalue: 'euclidean',\n\t\t},\n\t],\n};\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [collectionField, columnNamesField],\n\t},\n];\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [distanceStrategyField, collectionField, columnNamesField, metadataFilterField],\n\t},\n];\n\n/**\n * Extended PGVectorStore class to handle custom filtering.\n * This wrapper is necessary because when used as a retriever,\n * similaritySearchVectorWithScore should use this.filter instead of\n * expecting it from the parameter\n */\nclass ExtendedPGVectorStore extends PGVectorStore {\n\tstatic async initialize(\n\t\tembeddings: EmbeddingsInterface,\n\t\targs: PGVectorStoreArgs & { dimensions?: number },\n\t): Promise<ExtendedPGVectorStore> {\n\t\tconst { dimensions, ...rest } = args;\n\t\tconst postgresqlVectorStore = new this(embeddings, rest);\n\n\t\tawait postgresqlVectorStore._initializeClient();\n\t\tawait postgresqlVectorStore.ensureTableInDatabase(dimensions);\n\t\tif (postgresqlVectorStore.collectionTableName) {\n\t\t\tawait postgresqlVectorStore.ensureCollectionTableInDatabase();\n\t\t}\n\n\t\treturn postgresqlVectorStore;\n\t}\n\n\tasync similaritySearchVectorWithScore(\n\t\tquery: number[],\n\t\tk: number,\n\t\tfilter?: PGVectorStore['FilterType'],\n\t) {\n\t\tconst mergedFilter = { ...this.filter, ...filter };\n\t\treturn await super.similaritySearchVectorWithScore(query, k, mergedFilter);\n\t}\n}\n\nexport class VectorStorePGVector extends createVectorStoreNode<ExtendedPGVectorStore>({\n\tmeta: {\n\t\tdescription: 'Work with your data in Postgresql with the PGVector extension',\n\t\ticon: 'file:postgres.svg',\n\t\tdisplayName: 'Postgres PGVector Store',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstorepgvector/',\n\t\tname: 'vectorStorePGVector',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'postgres',\n\t\t\t\trequired: true,\n\t\t\t\ttestedBy: 'postgresConnectionTest',\n\t\t\t},\n\t\t],\n\t\toperationModes: ['load', 'insert', 'retrieve', 'retrieve-as-tool'],\n\t},\n\tsharedFields,\n\tinsertFields,\n\tloadFields: retrieveFields,\n\tretrieveFields,\n\tasync getVectorStoreClient(context, filter, embeddings, itemIndex) {\n\t\tconst tableName = context.getNodeParameter('tableName', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\t\tconst credentials = await context.getCredentials('postgres');\n\t\tconst pgConf = await configurePostgres.call(context, credentials as PostgresNodeCredentials);\n\t\tconst pool = pgConf.db.$pool as unknown as pg.Pool;\n\n\t\tconst config: PGVectorStoreArgs = {\n\t\t\tpool,\n\t\t\ttableName,\n\t\t\tfilter,\n\t\t};\n\n\t\tconst collectionOptions = context.getNodeParameter(\n\t\t\t'options.collection.values',\n\t\t\t0,\n\t\t\t{},\n\t\t) as CollectionOptions;\n\n\t\tif (collectionOptions && collectionOptions.useCollection) {\n\t\t\tconfig.collectionName = collectionOptions.collectionName;\n\t\t\tconfig.collectionTableName = collectionOptions.collectionTableName;\n\t\t}\n\n\t\tconfig.columns = context.getNodeParameter('options.columnNames.values', 0, {\n\t\t\tidColumnName: 'id',\n\t\t\tvectorColumnName: 'embedding',\n\t\t\tcontentColumnName: 'text',\n\t\t\tmetadataColumnName: 'metadata',\n\t\t}) as ColumnOptions;\n\n\t\tconfig.distanceStrategy = context.getNodeParameter(\n\t\t\t'options.distanceStrategy',\n\t\t\t0,\n\t\t\t'cosine',\n\t\t) as DistanceStrategy;\n\n\t\treturn await ExtendedPGVectorStore.initialize(embeddings, config);\n\t},\n\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\t// NOTE: if you are to create the HNSW index before use, you need to consider moving the distanceStrategy field to\n\t\t// shared fields, because you need that strategy when creating the index.\n\t\tconst tableName = context.getNodeParameter('tableName', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\t\tconst credentials = await context.getCredentials('postgres');\n\t\tconst pgConf = await configurePostgres.call(context, credentials as PostgresNodeCredentials);\n\t\tconst pool = pgConf.db.$pool as unknown as pg.Pool;\n\n\t\tconst config: PGVectorStoreArgs = {\n\t\t\tpool,\n\t\t\ttableName,\n\t\t};\n\n\t\tconst collectionOptions = context.getNodeParameter(\n\t\t\t'options.collection.values',\n\t\t\t0,\n\t\t\t{},\n\t\t) as CollectionOptions;\n\n\t\tif (collectionOptions && collectionOptions.useCollection) {\n\t\t\tconfig.collectionName = collectionOptions.collectionName;\n\t\t\tconfig.collectionTableName = collectionOptions.collectionTableName;\n\t\t}\n\n\t\tconfig.columns = context.getNodeParameter('options.columnNames.values', 0, {\n\t\t\tidColumnName: 'id',\n\t\t\tvectorColumnName: 'embedding',\n\t\t\tcontentColumnName: 'text',\n\t\t\tmetadataColumnName: 'metadata',\n\t\t}) as ColumnOptions;\n\n\t\tconst vectorStore = await PGVectorStore.fromDocuments(documents, embeddings, config);\n\t\tvectorStore.client?.release();\n\t},\n\n\treleaseVectorStoreClient(vectorStore) {\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BAAyB,aAAa;AACrC,gBAAY,QAAQ,QAAQ;AAAA,EAC7B;AACD,CAAC,EAAE;AAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.ts"],"sourcesContent":["import {\n\tPGVectorStore,\n\ttype DistanceStrategy,\n\ttype PGVectorStoreArgs,\n} from '@langchain/community/vectorstores/pgvector';\nimport type { EmbeddingsInterface } from '@langchain/core/embeddings';\nimport { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/transport/index';\nimport type { PostgresNodeCredentials } from 'n8n-nodes-base/dist/nodes/Postgres/v2/helpers/interfaces';\nimport type { INodeProperties } from 'n8n-workflow';\nimport type pg from 'pg';\n\nimport { metadataFilterField } from '@utils/sharedFields';\n\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\n\ntype CollectionOptions = {\n\tuseCollection?: boolean;\n\tcollectionName?: string;\n\tcollectionTableName?: string;\n};\n\ntype ColumnOptions = {\n\tidColumnName: string;\n\tvectorColumnName: string;\n\tcontentColumnName: string;\n\tmetadataColumnName: string;\n};\n\nconst sharedFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Table Name',\n\t\tname: 'tableName',\n\t\ttype: 'string',\n\t\tdefault: 'n8n_vectors',\n\t\tdescription:\n\t\t\t'The table name to store the vectors in. If table does not exist, it will be created.',\n\t},\n];\n\nconst collectionField: INodeProperties = {\n\tdisplayName: 'Collection',\n\tname: 'collection',\n\ttype: 'fixedCollection',\n\tdescription: 'Collection of vectors',\n\tdefault: {\n\t\tvalues: {\n\t\t\tuseCollection: false,\n\t\t\tcollectionName: 'n8n',\n\t\t\tcollectionTable: 'n8n_vector_collections',\n\t\t},\n\t},\n\ttypeOptions: {},\n\tplaceholder: 'Add Collection Settings',\n\toptions: [\n\t\t{\n\t\t\tname: 'values',\n\t\t\tdisplayName: 'Collection Settings',\n\t\t\tvalues: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Use Collection',\n\t\t\t\t\tname: 'useCollection',\n\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\tdefault: false,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Collection Name',\n\t\t\t\t\tname: 'collectionName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'n8n',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdisplayOptions: { show: { useCollection: [true] } },\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Collection Table Name',\n\t\t\t\t\tname: 'collectionTableName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'n8n_vector_collections',\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdisplayOptions: { show: { useCollection: [true] } },\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n};\n\nconst columnNamesField: INodeProperties = {\n\tdisplayName: 'Column Names',\n\tname: 'columnNames',\n\ttype: 'fixedCollection',\n\tdescription: 'The names of the columns in the PGVector table',\n\tdefault: {\n\t\tvalues: {\n\t\t\tidColumnName: 'id',\n\t\t\tvectorColumnName: 'embedding',\n\t\t\tcontentColumnName: 'text',\n\t\t\tmetadataColumnName: 'metadata',\n\t\t},\n\t},\n\ttypeOptions: {},\n\tplaceholder: 'Set Column Names',\n\toptions: [\n\t\t{\n\t\t\tname: 'values',\n\t\t\tdisplayName: 'Column Name Settings',\n\t\t\tvalues: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'ID Column Name',\n\t\t\t\t\tname: 'idColumnName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'id',\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Vector Column Name',\n\t\t\t\t\tname: 'vectorColumnName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'embedding',\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Content Column Name',\n\t\t\t\t\tname: 'contentColumnName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'text',\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Metadata Column Name',\n\t\t\t\t\tname: 'metadataColumnName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: 'metadata',\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n};\n\nconst distanceStrategyField: INodeProperties = {\n\tdisplayName: 'Distance Strategy',\n\tname: 'distanceStrategy',\n\ttype: 'options',\n\tdefault: 'cosine',\n\tdescription: 'The method to calculate the distance between two vectors',\n\toptions: [\n\t\t{\n\t\t\tname: 'Cosine',\n\t\t\tvalue: 'cosine',\n\t\t},\n\t\t{\n\t\t\tname: 'Inner Product',\n\t\t\tvalue: 'innerProduct',\n\t\t},\n\t\t{\n\t\t\tname: 'Euclidean',\n\t\t\tvalue: 'euclidean',\n\t\t},\n\t],\n};\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [collectionField, columnNamesField],\n\t},\n];\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [distanceStrategyField, collectionField, columnNamesField, metadataFilterField],\n\t},\n];\n\n/**\n * Extended PGVectorStore class to handle custom filtering.\n * This wrapper is necessary because when used as a retriever,\n * similaritySearchVectorWithScore should use this.filter instead of\n * expecting it from the parameter\n */\nclass ExtendedPGVectorStore extends PGVectorStore {\n\tstatic async initialize(\n\t\tembeddings: EmbeddingsInterface,\n\t\targs: PGVectorStoreArgs & { dimensions?: number },\n\t): Promise<ExtendedPGVectorStore> {\n\t\tconst { dimensions, ...rest } = args;\n\t\tconst postgresqlVectorStore = new this(embeddings, rest);\n\n\t\tawait postgresqlVectorStore._initializeClient();\n\t\tawait postgresqlVectorStore.ensureTableInDatabase(dimensions);\n\t\tif (postgresqlVectorStore.collectionTableName) {\n\t\t\tawait postgresqlVectorStore.ensureCollectionTableInDatabase();\n\t\t}\n\n\t\treturn postgresqlVectorStore;\n\t}\n\n\tasync similaritySearchVectorWithScore(\n\t\tquery: number[],\n\t\tk: number,\n\t\tfilter?: PGVectorStore['FilterType'],\n\t) {\n\t\tconst mergedFilter = { ...this.filter, ...filter };\n\t\treturn await super.similaritySearchVectorWithScore(query, k, mergedFilter);\n\t}\n}\n\nexport class VectorStorePGVector extends createVectorStoreNode<ExtendedPGVectorStore>({\n\tmeta: {\n\t\tdescription: 'Work with your data in Postgresql with the PGVector extension',\n\t\ticon: 'file:postgres.svg',\n\t\tdisplayName: 'Postgres PGVector Store',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstorepgvector/',\n\t\tname: 'vectorStorePGVector',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'postgres',\n\t\t\t\trequired: true,\n\t\t\t\ttestedBy: 'postgresConnectionTest',\n\t\t\t},\n\t\t],\n\t\toperationModes: ['load', 'insert', 'retrieve', 'retrieve-as-tool'],\n\t},\n\tsharedFields,\n\tinsertFields,\n\tloadFields: retrieveFields,\n\tretrieveFields,\n\tasync getVectorStoreClient(context, filter, embeddings, itemIndex) {\n\t\tconst tableName = context.getNodeParameter('tableName', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\t\tconst credentials = await context.getCredentials('postgres');\n\t\tconst pgConf = await configurePostgres.call(context, credentials as PostgresNodeCredentials);\n\t\tconst pool = pgConf.db.$pool as unknown as pg.Pool;\n\n\t\tconst config: PGVectorStoreArgs = {\n\t\t\tpool,\n\t\t\ttableName,\n\t\t\tfilter,\n\t\t};\n\n\t\tconst collectionOptions = context.getNodeParameter(\n\t\t\t'options.collection.values',\n\t\t\t0,\n\t\t\t{},\n\t\t) as CollectionOptions;\n\n\t\tif (collectionOptions?.useCollection) {\n\t\t\tconfig.collectionName = collectionOptions.collectionName;\n\t\t\tconfig.collectionTableName = collectionOptions.collectionTableName;\n\t\t}\n\n\t\tconfig.columns = context.getNodeParameter('options.columnNames.values', 0, {\n\t\t\tidColumnName: 'id',\n\t\t\tvectorColumnName: 'embedding',\n\t\t\tcontentColumnName: 'text',\n\t\t\tmetadataColumnName: 'metadata',\n\t\t}) as ColumnOptions;\n\n\t\tconfig.distanceStrategy = context.getNodeParameter(\n\t\t\t'options.distanceStrategy',\n\t\t\t0,\n\t\t\t'cosine',\n\t\t) as DistanceStrategy;\n\n\t\treturn await ExtendedPGVectorStore.initialize(embeddings, config);\n\t},\n\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\t// NOTE: if you are to create the HNSW index before use, you need to consider moving the distanceStrategy field to\n\t\t// shared fields, because you need that strategy when creating the index.\n\t\tconst tableName = context.getNodeParameter('tableName', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\t\tconst credentials = await context.getCredentials('postgres');\n\t\tconst pgConf = await configurePostgres.call(context, credentials as PostgresNodeCredentials);\n\t\tconst pool = pgConf.db.$pool as unknown as pg.Pool;\n\n\t\tconst config: PGVectorStoreArgs = {\n\t\t\tpool,\n\t\t\ttableName,\n\t\t};\n\n\t\tconst collectionOptions = context.getNodeParameter(\n\t\t\t'options.collection.values',\n\t\t\t0,\n\t\t\t{},\n\t\t) as CollectionOptions;\n\n\t\tif (collectionOptions?.useCollection) {\n\t\t\tconfig.collectionName = collectionOptions.collectionName;\n\t\t\tconfig.collectionTableName = collectionOptions.collectionTableName;\n\t\t}\n\n\t\tconfig.columns = context.getNodeParameter('options.columnNames.values', 0, {\n\t\t\tidColumnName: 'id',\n\t\t\tvectorColumnName: 'embedding',\n\t\t\tcontentColumnName: 'text',\n\t\t\tmetadataColumnName: 'metadata',\n\t\t}) as ColumnOptions;\n\n\t\tconst vectorStore = await PGVectorStore.fromDocuments(documents, embeddings, config);\n\t\tvectorStore.client?.release();\n\t},\n\n\treleaseVectorStoreClient(vectorStore) {\n\t\tvectorStore.client?.release();\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAIO;AAEP,uBAAkC;AAKlC,0BAAoC;AAEpC,mCAAsC;AAetC,MAAM,eAAkC;AAAA,EACvC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACC;AAAA,EACF;AACD;AAEA,MAAM,kBAAmC;AAAA,EACxC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AAAA,IACR,QAAQ;AAAA,MACP,eAAe;AAAA,MACf,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IAClB;AAAA,EACD;AAAA,EACA,aAAa,CAAC;AAAA,EACd,aAAa;AAAA,EACb,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,aAAa;AAAA,MACb,QAAQ;AAAA,QACP;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,QACV;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,UAAU;AAAA,UACV,gBAAgB,EAAE,MAAM,EAAE,eAAe,CAAC,IAAI,EAAE,EAAE;AAAA,QACnD;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,UACT,UAAU;AAAA,UACV,gBAAgB,EAAE,MAAM,EAAE,eAAe,CAAC,IAAI,EAAE,EAAE;AAAA,QACnD;AAAA,MACD;AAAA,IACD;AAAA,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A,MACnB,oBAAoB;AAAA,IACrB,CAAC;AAED,UAAM,cAAc,MAAM,8BAAc,cAAc,WAAW,YAAY,MAAM;AACnF,gBAAY,QAAQ,QAAQ;AAAA,EAC7B;AAAA,EAEA,yBAAyB,aAAa;AACrC,gBAAY,QAAQ,QAAQ;AAAA,EAC7B;AACD,CAAC,EAAE;AAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.ts"],"sourcesContent":["import type { Callbacks } from '@langchain/core/callbacks/manager';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport type { QdrantLibArgs } from '@langchain/qdrant';\nimport { QdrantVectorStore } from '@langchain/qdrant';\nimport { type Schemas as QdrantSchemas } from '@qdrant/js-client-rest';\nimport type { IDataObject, INodeProperties } from 'n8n-workflow';\n\nimport { createQdrantClient, type QdrantCredential } from './Qdrant.utils';\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\nimport { qdrantCollectionsSearch } from '../shared/createVectorStoreNode/methods/listSearch';\nimport { qdrantCollectionRLC } from '../shared/descriptions';\n\nclass ExtendedQdrantVectorStore extends QdrantVectorStore {\n\tprivate static defaultFilter: IDataObject = {};\n\n\tstatic async fromExistingCollection(\n\t\tembeddings: Embeddings,\n\t\targs: QdrantLibArgs,\n\t\tdefaultFilter: IDataObject = {},\n\t): Promise<QdrantVectorStore> {\n\t\tExtendedQdrantVectorStore.defaultFilter = defaultFilter;\n\t\treturn await super.fromExistingCollection(embeddings, args);\n\t}\n\n\tasync similaritySearch(
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.ts"],"sourcesContent":["import type { Callbacks } from '@langchain/core/callbacks/manager';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport type { QdrantLibArgs } from '@langchain/qdrant';\nimport { QdrantVectorStore } from '@langchain/qdrant';\nimport { type Schemas as QdrantSchemas } from '@qdrant/js-client-rest';\nimport type { IDataObject, INodeProperties } from 'n8n-workflow';\n\nimport { createQdrantClient, type QdrantCredential } from './Qdrant.utils';\nimport { createVectorStoreNode } from '../shared/createVectorStoreNode/createVectorStoreNode';\nimport { qdrantCollectionsSearch } from '../shared/createVectorStoreNode/methods/listSearch';\nimport { qdrantCollectionRLC } from '../shared/descriptions';\n\nclass ExtendedQdrantVectorStore extends QdrantVectorStore {\n\tprivate static defaultFilter: IDataObject = {};\n\n\tstatic async fromExistingCollection(\n\t\tembeddings: Embeddings,\n\t\targs: QdrantLibArgs,\n\t\tdefaultFilter: IDataObject = {},\n\t): Promise<QdrantVectorStore> {\n\t\tExtendedQdrantVectorStore.defaultFilter = defaultFilter;\n\t\treturn await super.fromExistingCollection(embeddings, args);\n\t}\n\n\tasync similaritySearch(query: string, k: number, filter?: IDataObject, callbacks?: Callbacks) {\n\t\tconst mergedFilter = { ...ExtendedQdrantVectorStore.defaultFilter, ...filter };\n\t\treturn await super.similaritySearch(query, k, mergedFilter, callbacks);\n\t}\n}\n\nconst sharedFields: INodeProperties[] = [qdrantCollectionRLC];\n\nconst insertFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Collection Config',\n\t\t\t\tname: 'collectionConfig',\n\t\t\t\ttype: 'json',\n\t\t\t\tdefault: '',\n\t\t\t\tdescription:\n\t\t\t\t\t'JSON options for creating a collection. <a href=\"https://qdrant.tech/documentation/concepts/collections\">Learn more</a>.',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst retrieveFields: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\ttype: 'collection',\n\t\tplaceholder: 'Add Option',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Search Filter',\n\t\t\t\tname: 'searchFilterJson',\n\t\t\t\ttype: 'json',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\trows: 5,\n\t\t\t\t},\n\t\t\t\tdefault:\n\t\t\t\t\t'{\\n \"should\": [\\n {\\n \"key\": \"metadata.batch\",\\n \"match\": {\\n \"value\": 12345\\n }\\n }\\n ]\\n}',\n\t\t\t\tvalidateType: 'object',\n\t\t\t\tdescription:\n\t\t\t\t\t'Filter pageContent or metadata using this <a href=\"https://qdrant.tech/documentation/concepts/filtering/\" target=\"_blank\">filtering syntax</a>',\n\t\t\t},\n\t\t],\n\t},\n];\n\nexport class VectorStoreQdrant extends createVectorStoreNode<ExtendedQdrantVectorStore>({\n\tmeta: {\n\t\tdisplayName: 'Qdrant Vector Store',\n\t\tname: 'vectorStoreQdrant',\n\t\tdescription: 'Work with your data in a Qdrant collection',\n\t\ticon: 'file:qdrant.svg',\n\t\tdocsUrl:\n\t\t\t'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoreqdrant/',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'qdrantApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t},\n\tmethods: { listSearch: { qdrantCollectionsSearch } },\n\tloadFields: retrieveFields,\n\tinsertFields,\n\tsharedFields,\n\tretrieveFields,\n\tasync getVectorStoreClient(context, filter, embeddings, itemIndex) {\n\t\tconst collection = context.getNodeParameter('qdrantCollection', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\n\t\tconst credentials = await context.getCredentials('qdrantApi');\n\n\t\tconst client = createQdrantClient(credentials as QdrantCredential);\n\n\t\tconst config: QdrantLibArgs = {\n\t\t\tclient,\n\t\t\tcollectionName: collection,\n\t\t};\n\n\t\treturn await ExtendedQdrantVectorStore.fromExistingCollection(embeddings, config, filter);\n\t},\n\tasync populateVectorStore(context, embeddings, documents, itemIndex) {\n\t\tconst collectionName = context.getNodeParameter('qdrantCollection', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\n\t\t// If collection config is not provided, the collection will be created with default settings\n\t\t// i.e. with the size of the passed embeddings and \"Cosine\" distance metric\n\t\tconst { collectionConfig } = context.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tcollectionConfig?: QdrantSchemas['CreateCollection'];\n\t\t};\n\t\tconst credentials = await context.getCredentials('qdrantApi');\n\n\t\tconst client = createQdrantClient(credentials as QdrantCredential);\n\n\t\tconst config: QdrantLibArgs = {\n\t\t\tclient,\n\t\t\tcollectionName,\n\t\t\tcollectionConfig,\n\t\t};\n\n\t\tawait QdrantVectorStore.fromDocuments(documents, embeddings, config);\n\t},\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAkC;AAIlC,oBAA0D;AAC1D,mCAAsC;AACtC,wBAAwC;AACxC,0BAAoC;AAEpC,MAAM,6BAAN,MAAM,mCAAkC,gCAAkB;AAAA,EAGzD,aAAa,uBACZ,YACA,MACA,gBAA6B,CAAC,GACD;AAC7B,+BAA0B,gBAAgB;AAC1C,WAAO,MAAM,MAAM,uBAAuB,YAAY,IAAI;AAAA,EAC3D;AAAA,EAEA,MAAM,iBAAiB,OAAe,GAAW,QAAsB,WAAuB;AAC7F,UAAM,eAAe,EAAE,GAAG,2BAA0B,eAAe,GAAG,OAAO;AAC7E,WAAO,MAAM,MAAM,iBAAiB,OAAO,GAAG,cAAc,SAAS;AAAA,EACtE;AACD;AAhBM,2BACU,gBAA6B,CAAC;AAD9C,IAAM,4BAAN;AAkBA,MAAM,eAAkC,CAAC,uCAAmB;AAE5D,MAAM,eAAkC;AAAA,EACvC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AA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AQ,iBAAiB,WAAW,WAAW,CAAC,CAAC;AAG9E,UAAM,cAAc,MAAM,QAAQ,eAAe,WAAW;AAE5D,UAAM,aAAS,kCAAmB,WAA+B;AAEjE,UAAM,SAAwB;AAAA,MAC7B;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAEA,UAAM,gCAAkB,cAAc,WAAW,YAAY,MAAM;AAAA,EACpE;AACD,CAAC,EAAE;AAAC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.ts"],"sourcesContent":["import type { SupabaseLibArgs } from '@langchain/community/vectorstores/supabase';\nimport { SupabaseVectorStore } from '@langchain/community/vectorstores/supabase';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport { createClient } from '@supabase/supabase-js';\nimport {\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n\tNodeConnectionTypes,\n} from 'n8n-workflow';\n\nimport { getMetadataFiltersValues } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { metadataFilterField } from '@utils/sharedFields';\n\nimport { supabaseTableNameSearch } from '../shared/createVectorStoreNode/methods/listSearch';\nimport { supabaseTableNameRLC } from '../shared/descriptions';\n\n// This node is deprecated. Use VectorStoreSupabase instead.\nexport class VectorStoreSupabaseLoad implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Supabase: Load',\n\t\tname: 'vectorStoreSupabaseLoad',\n\t\ticon: 'file:supabase.svg',\n\t\t// Vector Store nodes got merged into a single node\n\t\thidden: true,\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Load data from Supabase Vector Store index',\n\t\tdefaults: {\n\t\t\tname: 'Supabase: Load',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Vector Stores'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoresupabase/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'supabaseApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Embedding',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiEmbedding,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\toutputs: [NodeConnectionTypes.AiVectorStore],\n\t\toutputNames: ['Vector Store'],\n\t\tproperties: [\n\t\t\tsupabaseTableNameRLC,\n\t\t\t{\n\t\t\t\tdisplayName: 'Query Name',\n\t\t\t\tname: 'queryName',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'match_documents',\n\t\t\t\trequired: true,\n\t\t\t\tdescription: 'Name of the query to use for matching documents',\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\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [metadataFilterField],\n\t\t\t},\n\t\t],\n\t};\n\n\tmethods = { listSearch: { supabaseTableNameSearch } };\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply Supabase Load Vector Store');\n\n\t\tconst tableName = this.getNodeParameter('tableName', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\t\tconst queryName = this.getNodeParameter('queryName', itemIndex) as string;\n\n\t\tconst credentials = await this.getCredentials('supabaseApi');\n\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t0,\n\t\t)) as Embeddings;\n\n\t\
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.ts"],"sourcesContent":["import type { SupabaseLibArgs } from '@langchain/community/vectorstores/supabase';\nimport { SupabaseVectorStore } from '@langchain/community/vectorstores/supabase';\nimport type { Embeddings } from '@langchain/core/embeddings';\nimport { createClient } from '@supabase/supabase-js';\nimport {\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n\tNodeConnectionTypes,\n} from 'n8n-workflow';\n\nimport { getMetadataFiltersValues } from '@utils/helpers';\nimport { logWrapper } from '@utils/logWrapper';\nimport { metadataFilterField } from '@utils/sharedFields';\n\nimport { supabaseTableNameSearch } from '../shared/createVectorStoreNode/methods/listSearch';\nimport { supabaseTableNameRLC } from '../shared/descriptions';\n\n// This node is deprecated. Use VectorStoreSupabase instead.\nexport class VectorStoreSupabaseLoad implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Supabase: Load',\n\t\tname: 'vectorStoreSupabaseLoad',\n\t\ticon: 'file:supabase.svg',\n\t\t// Vector Store nodes got merged into a single node\n\t\thidden: true,\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Load data from Supabase Vector Store index',\n\t\tdefaults: {\n\t\t\tname: 'Supabase: Load',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Vector Stores'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.vectorstoresupabase/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'supabaseApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Embedding',\n\t\t\t\tmaxConnections: 1,\n\t\t\t\ttype: NodeConnectionTypes.AiEmbedding,\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\toutputs: [NodeConnectionTypes.AiVectorStore],\n\t\toutputNames: ['Vector Store'],\n\t\tproperties: [\n\t\t\tsupabaseTableNameRLC,\n\t\t\t{\n\t\t\t\tdisplayName: 'Query Name',\n\t\t\t\tname: 'queryName',\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'match_documents',\n\t\t\t\trequired: true,\n\t\t\t\tdescription: 'Name of the query to use for matching documents',\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\tplaceholder: 'Add Option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [metadataFilterField],\n\t\t\t},\n\t\t],\n\t};\n\n\tmethods = { listSearch: { supabaseTableNameSearch } };\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply Supabase Load Vector Store');\n\n\t\tconst tableName = this.getNodeParameter('tableName', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\t\tconst queryName = this.getNodeParameter('queryName', itemIndex) as string;\n\n\t\tconst credentials = await this.getCredentials('supabaseApi');\n\t\tconst embeddings = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiEmbedding,\n\t\t\t0,\n\t\t)) as Embeddings;\n\n\t\tconst client = createClient(credentials.host as string, credentials.serviceRole as string);\n\t\tconst config: SupabaseLibArgs = {\n\t\t\tclient,\n\t\t\ttableName,\n\t\t\tqueryName,\n\t\t\tfilter: getMetadataFiltersValues(this, itemIndex),\n\t\t};\n\n\t\tconst vectorStore = await SupabaseVectorStore.fromExistingIndex(embeddings, config);\n\n\t\treturn {\n\t\t\tresponse: logWrapper(vectorStore, this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