@n8n/n8n-nodes-langchain 1.83.1 → 1.84.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/known/nodes.json +4 -0
  3. package/dist/nodes/agents/Agent/Agent.node.js +5 -1
  4. package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
  5. package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js +9 -19
  6. package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js.map +1 -1
  7. package/dist/nodes/agents/Agent/agents/OpenAiFunctionsAgent/execute.js +3 -7
  8. package/dist/nodes/agents/Agent/agents/OpenAiFunctionsAgent/execute.js.map +1 -1
  9. package/dist/nodes/agents/Agent/agents/PlanAndExecuteAgent/execute.js +3 -7
  10. package/dist/nodes/agents/Agent/agents/PlanAndExecuteAgent/execute.js.map +1 -1
  11. package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js +3 -7
  12. package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js.map +1 -1
  13. package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js +5 -6
  14. package/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js.map +1 -1
  15. package/dist/nodes/chains/ChainLLM/ChainLlm.node.js +17 -389
  16. package/dist/nodes/chains/ChainLLM/ChainLlm.node.js.map +1 -1
  17. package/dist/nodes/chains/ChainLLM/methods/chainExecutor.d.ts +15 -0
  18. package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js +69 -0
  19. package/dist/nodes/chains/ChainLLM/methods/chainExecutor.js.map +1 -0
  20. package/dist/nodes/chains/ChainLLM/methods/config.d.ts +14 -0
  21. package/dist/nodes/chains/ChainLLM/methods/config.js +253 -0
  22. package/dist/nodes/chains/ChainLLM/methods/config.js.map +1 -0
  23. package/dist/nodes/chains/ChainLLM/methods/imageUtils.d.ts +12 -0
  24. package/dist/nodes/chains/ChainLLM/methods/imageUtils.js +66 -0
  25. package/dist/nodes/chains/ChainLLM/methods/imageUtils.js.map +1 -0
  26. package/dist/nodes/chains/ChainLLM/methods/index.d.ts +4 -0
  27. package/dist/nodes/chains/ChainLLM/methods/index.js +11 -0
  28. package/dist/nodes/chains/ChainLLM/methods/index.js.map +1 -0
  29. package/dist/nodes/chains/ChainLLM/methods/promptUtils.d.ts +3 -0
  30. package/dist/nodes/chains/ChainLLM/methods/promptUtils.js +69 -0
  31. package/dist/nodes/chains/ChainLLM/methods/promptUtils.js.map +1 -0
  32. package/dist/nodes/chains/ChainLLM/methods/responseFormatter.d.ts +2 -0
  33. package/dist/nodes/chains/ChainLLM/methods/responseFormatter.js +29 -0
  34. package/dist/nodes/chains/ChainLLM/methods/responseFormatter.js.map +1 -0
  35. package/dist/nodes/chains/ChainLLM/methods/types.d.ts +28 -0
  36. package/dist/nodes/chains/ChainLLM/methods/types.js +3 -0
  37. package/dist/nodes/chains/ChainLLM/methods/types.js.map +1 -0
  38. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +68 -33
  39. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
  40. package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js +1 -0
  41. package/dist/nodes/llms/LMChatOpenAi/methods/loadModels.js.map +1 -1
  42. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +1 -1
  43. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
  44. package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js +1 -1
  45. package/dist/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.js.map +1 -1
  46. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.d.ts +16 -0
  47. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.js +244 -0
  48. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.js.map +1 -0
  49. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.dark.svg +3 -0
  50. package/dist/nodes/vector_store/VectorStoreMongoDBAtlas/mongodb.svg +3 -0
  51. package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js +1 -1
  52. package/dist/nodes/vector_store/VectorStorePGVector/VectorStorePGVector.node.js.map +1 -1
  53. package/dist/nodes/vector_store/VectorStorePinecone/VectorStorePinecone.node.js +2 -2
  54. package/dist/nodes/vector_store/VectorStorePinecone/VectorStorePinecone.node.js.map +1 -1
  55. package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.d.ts +1 -1
  56. package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.js +1 -1
  57. package/dist/nodes/vector_store/VectorStorePineconeInsert/VectorStorePineconeInsert.node.js.map +1 -1
  58. package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.d.ts +1 -1
  59. package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.js +1 -1
  60. package/dist/nodes/vector_store/VectorStorePineconeLoad/VectorStorePineconeLoad.node.js.map +1 -1
  61. package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js +2 -2
  62. package/dist/nodes/vector_store/VectorStoreQdrant/VectorStoreQdrant.node.js.map +1 -1
  63. package/dist/nodes/vector_store/VectorStoreSupabase/VectorStoreSupabase.node.js +2 -2
  64. package/dist/nodes/vector_store/VectorStoreSupabase/VectorStoreSupabase.node.js.map +1 -1
  65. package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.d.ts +1 -1
  66. package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.js +1 -1
  67. package/dist/nodes/vector_store/VectorStoreSupabaseInsert/VectorStoreSupabaseInsert.node.js.map +1 -1
  68. package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.d.ts +1 -1
  69. package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.js +1 -1
  70. package/dist/nodes/vector_store/VectorStoreSupabaseLoad/VectorStoreSupabaseLoad.node.js.map +1 -1
  71. package/dist/nodes/vector_store/VectorStoreZep/VectorStoreZep.node.js +1 -1
  72. package/dist/nodes/vector_store/VectorStoreZep/VectorStoreZep.node.js.map +1 -1
  73. package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.d.ts +4 -0
  74. package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.js +44 -0
  75. package/dist/nodes/vector_store/shared/createVectorStoreNode/constants.js.map +1 -0
  76. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.d.ts +15 -0
  77. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js +226 -0
  78. package/dist/nodes/vector_store/shared/createVectorStoreNode/createVectorStoreNode.js.map +1 -0
  79. package/dist/nodes/vector_store/shared/createVectorStoreNode/methods/listSearch.js.map +1 -0
  80. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.d.ts +5 -0
  81. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js +22 -0
  82. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/index.js.map +1 -0
  83. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.d.ts +5 -0
  84. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.js +34 -0
  85. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/insertOperation.js.map +1 -0
  86. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.d.ts +5 -0
  87. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js +33 -0
  88. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/loadOperation.js.map +1 -0
  89. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.d.ts +5 -0
  90. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js +42 -0
  91. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveAsToolOperation.js.map +1 -0
  92. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.d.ts +5 -0
  93. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js +16 -0
  94. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/retrieveOperation.js.map +1 -0
  95. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.d.ts +5 -0
  96. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js +39 -0
  97. package/dist/nodes/vector_store/shared/createVectorStoreNode/operations/updateOperation.js.map +1 -0
  98. package/dist/nodes/vector_store/shared/{createVectorStoreNode.d.ts → createVectorStoreNode/types.d.ts} +3 -16
  99. package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js +3 -0
  100. package/dist/nodes/vector_store/shared/createVectorStoreNode/types.js.map +1 -0
  101. package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.d.ts +6 -0
  102. package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.js +20 -0
  103. package/dist/nodes/vector_store/shared/createVectorStoreNode/utils.js.map +1 -0
  104. package/dist/types/nodes.json +10 -9
  105. package/dist/utils/helpers.d.ts +1 -0
  106. package/dist/utils/helpers.js +12 -0
  107. package/dist/utils/helpers.js.map +1 -1
  108. package/dist/utils/output_parsers/N8nOutputFixingParser.js +6 -1
  109. package/dist/utils/output_parsers/N8nOutputFixingParser.js.map +1 -1
  110. package/dist/utils/output_parsers/N8nOutputParser.d.ts +1 -1
  111. package/dist/utils/output_parsers/N8nOutputParser.js +5 -5
  112. package/dist/utils/output_parsers/N8nOutputParser.js.map +1 -1
  113. package/dist/utils/output_parsers/N8nStructuredOutputParser.js +2 -1
  114. package/dist/utils/output_parsers/N8nStructuredOutputParser.js.map +1 -1
  115. package/package.json +9 -6
  116. package/dist/nodes/chains/ChainLLM/utils.d.ts +0 -5
  117. package/dist/nodes/chains/ChainLLM/utils.js +0 -14
  118. package/dist/nodes/chains/ChainLLM/utils.js.map +0 -1
  119. package/dist/nodes/vector_store/shared/createVectorStoreNode.js +0 -369
  120. package/dist/nodes/vector_store/shared/createVectorStoreNode.js.map +0 -1
  121. package/dist/nodes/vector_store/shared/methods/listSearch.js.map +0 -1
  122. /package/dist/nodes/vector_store/shared/{methods → createVectorStoreNode/methods}/listSearch.d.ts +0 -0
  123. /package/dist/nodes/vector_store/shared/{methods → createVectorStoreNode/methods}/listSearch.js +0 -0
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nodeProperties = void 0;
4
+ exports.getInputs = getInputs;
5
+ const prompts_1 = require("@langchain/core/prompts");
6
+ const descriptions_1 = require("../../../../utils/descriptions");
7
+ const sharedFields_1 = require("../../../../utils/sharedFields");
8
+ function getInputs(parameters) {
9
+ const inputs = [
10
+ { displayName: '', type: "main" },
11
+ {
12
+ displayName: 'Model',
13
+ maxConnections: 1,
14
+ type: "ai_languageModel",
15
+ required: true,
16
+ },
17
+ ];
18
+ const hasOutputParser = parameters?.hasOutputParser;
19
+ if (hasOutputParser === undefined || hasOutputParser === true) {
20
+ inputs.push({
21
+ displayName: 'Output Parser',
22
+ type: "ai_outputParser",
23
+ maxConnections: 1,
24
+ required: false,
25
+ });
26
+ }
27
+ return inputs;
28
+ }
29
+ exports.nodeProperties = [
30
+ (0, sharedFields_1.getTemplateNoticeField)(1978),
31
+ {
32
+ displayName: 'Prompt',
33
+ name: 'prompt',
34
+ type: 'string',
35
+ required: true,
36
+ default: '={{ $json.input }}',
37
+ displayOptions: {
38
+ show: {
39
+ '@version': [1],
40
+ },
41
+ },
42
+ },
43
+ {
44
+ displayName: 'Prompt',
45
+ name: 'prompt',
46
+ type: 'string',
47
+ required: true,
48
+ default: '={{ $json.chat_input }}',
49
+ displayOptions: {
50
+ show: {
51
+ '@version': [1.1, 1.2],
52
+ },
53
+ },
54
+ },
55
+ {
56
+ displayName: 'Prompt',
57
+ name: 'prompt',
58
+ type: 'string',
59
+ required: true,
60
+ default: '={{ $json.chatInput }}',
61
+ displayOptions: {
62
+ show: {
63
+ '@version': [1.3],
64
+ },
65
+ },
66
+ },
67
+ {
68
+ ...descriptions_1.promptTypeOptions,
69
+ displayOptions: {
70
+ hide: {
71
+ '@version': [1, 1.1, 1.2, 1.3],
72
+ },
73
+ },
74
+ },
75
+ {
76
+ ...descriptions_1.textFromPreviousNode,
77
+ displayOptions: { show: { promptType: ['auto'], '@version': [{ _cnd: { gte: 1.5 } }] } },
78
+ },
79
+ {
80
+ displayName: 'Prompt (User Message)',
81
+ name: 'text',
82
+ type: 'string',
83
+ required: true,
84
+ default: '',
85
+ placeholder: 'e.g. Hello, how can you help me?',
86
+ typeOptions: {
87
+ rows: 2,
88
+ },
89
+ displayOptions: {
90
+ show: {
91
+ promptType: ['define'],
92
+ },
93
+ },
94
+ },
95
+ {
96
+ displayName: 'Require Specific Output Format',
97
+ name: 'hasOutputParser',
98
+ type: 'boolean',
99
+ default: false,
100
+ noDataExpression: true,
101
+ displayOptions: {
102
+ hide: {
103
+ '@version': [1, 1.1, 1.3],
104
+ },
105
+ },
106
+ },
107
+ {
108
+ displayName: 'Chat Messages (if Using a Chat Model)',
109
+ name: 'messages',
110
+ type: 'fixedCollection',
111
+ typeOptions: {
112
+ multipleValues: true,
113
+ },
114
+ default: {},
115
+ placeholder: 'Add prompt',
116
+ options: [
117
+ {
118
+ name: 'messageValues',
119
+ displayName: 'Prompt',
120
+ values: [
121
+ {
122
+ displayName: 'Type Name or ID',
123
+ name: 'type',
124
+ type: 'options',
125
+ options: [
126
+ {
127
+ name: 'AI',
128
+ value: prompts_1.AIMessagePromptTemplate.lc_name(),
129
+ },
130
+ {
131
+ name: 'System',
132
+ value: prompts_1.SystemMessagePromptTemplate.lc_name(),
133
+ },
134
+ {
135
+ name: 'User',
136
+ value: prompts_1.HumanMessagePromptTemplate.lc_name(),
137
+ },
138
+ ],
139
+ default: prompts_1.SystemMessagePromptTemplate.lc_name(),
140
+ },
141
+ {
142
+ displayName: 'Message Type',
143
+ name: 'messageType',
144
+ type: 'options',
145
+ displayOptions: {
146
+ show: {
147
+ type: [prompts_1.HumanMessagePromptTemplate.lc_name()],
148
+ },
149
+ },
150
+ options: [
151
+ {
152
+ name: 'Text',
153
+ value: 'text',
154
+ description: 'Simple text message',
155
+ },
156
+ {
157
+ name: 'Image (Binary)',
158
+ value: 'imageBinary',
159
+ description: 'Process the binary input from the previous node',
160
+ },
161
+ {
162
+ name: 'Image (URL)',
163
+ value: 'imageUrl',
164
+ description: 'Process the image from the specified URL',
165
+ },
166
+ ],
167
+ default: 'text',
168
+ },
169
+ {
170
+ displayName: 'Image Data Field Name',
171
+ name: 'binaryImageDataKey',
172
+ type: 'string',
173
+ default: 'data',
174
+ required: true,
175
+ description: "The name of the field in the chain's input that contains the binary image file to be processed",
176
+ displayOptions: {
177
+ show: {
178
+ messageType: ['imageBinary'],
179
+ },
180
+ },
181
+ },
182
+ {
183
+ displayName: 'Image URL',
184
+ name: 'imageUrl',
185
+ type: 'string',
186
+ default: '',
187
+ required: true,
188
+ description: 'URL to the image to be processed',
189
+ displayOptions: {
190
+ show: {
191
+ messageType: ['imageUrl'],
192
+ },
193
+ },
194
+ },
195
+ {
196
+ displayName: 'Image Details',
197
+ description: 'Control how the model processes the image and generates its textual understanding',
198
+ name: 'imageDetail',
199
+ type: 'options',
200
+ displayOptions: {
201
+ show: {
202
+ type: [prompts_1.HumanMessagePromptTemplate.lc_name()],
203
+ messageType: ['imageBinary', 'imageUrl'],
204
+ },
205
+ },
206
+ options: [
207
+ {
208
+ name: 'Auto',
209
+ value: 'auto',
210
+ description: 'Model will use the auto setting which will look at the image input size and decide if it should use the low or high setting',
211
+ },
212
+ {
213
+ name: 'Low',
214
+ value: 'low',
215
+ description: 'The model will receive a low-res 512px x 512px version of the image, and represent the image with a budget of 65 tokens. This allows the API to return faster responses and consume fewer input tokens for use cases that do not require high detail.',
216
+ },
217
+ {
218
+ name: 'High',
219
+ value: 'high',
220
+ description: 'Allows the model to see the low res image and then creates detailed crops of input images as 512px squares based on the input image size. Each of the detailed crops uses twice the token budget (65 tokens) for a total of 129 tokens.',
221
+ },
222
+ ],
223
+ default: 'auto',
224
+ },
225
+ {
226
+ displayName: 'Message',
227
+ name: 'message',
228
+ type: 'string',
229
+ required: true,
230
+ displayOptions: {
231
+ hide: {
232
+ messageType: ['imageBinary', 'imageUrl'],
233
+ },
234
+ },
235
+ default: '',
236
+ },
237
+ ],
238
+ },
239
+ ],
240
+ },
241
+ {
242
+ displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${"ai_outputParser"}'>output parser</a> on the canvas to specify the output format you require`,
243
+ name: 'notice',
244
+ type: 'notice',
245
+ default: '',
246
+ displayOptions: {
247
+ show: {
248
+ hasOutputParser: [true],
249
+ },
250
+ },
251
+ },
252
+ ];
253
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../nodes/chains/ChainLLM/methods/config.ts"],"names":[],"mappings":";;;AAcA,8BAwBC;AAtCD,qDAIiC;AAIjC,sDAA8E;AAC9E,sDAA6D;AAK7D,SAAgB,SAAS,CAAC,UAAuB;IAChD,MAAM,MAAM,GAAG;QACd,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,QAAyB,EAAE;QAClD;YACC,WAAW,EAAE,OAAO;YACpB,cAAc,EAAE,CAAC;YACjB,IAAI,oBAAoC;YACxC,QAAQ,EAAE,IAAI;SACd;KACD,CAAC;IAIF,MAAM,eAAe,GAAG,UAAU,EAAE,eAAe,CAAC;IACpD,IAAI,eAAe,KAAK,SAAS,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC/D,MAAM,CAAC,IAAI,CAAC;YACX,WAAW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BACxC;yBACD;wBACD,OAAO,EAAE;4BACR;gCACC,IAAI,EAAE,MAAM;gCACZ,KAAK,EAAE,MAAM;gCACb,WAAW,EACV,6HAA6H;6BAC9H;4BACD;gCACC,IAAI,EAAE,KAAK;gCACX,KAAK,EAAE,KAAK;gCACZ,WAAW,EACV,uPAAuP;6BACxP;4BACD;gCACC,IAAI,EAAE,MAAM;gCACZ,KAAK,EAAE,MAAM;gCACb,WAAW,EACV,yOAAyO;6BAC1O;yBACD;wBACD,OAAO,EAAE,MAAM;qBACf;oBAED;wBACC,WAAW,EAAE,SAAS;wBACtB,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,QAAQ;wBACd,QAAQ,EAAE,IAAI;wBACd,cAAc,EAAE;4BACf,IAAI,EAAE;gCACL,WAAW,EAAE,CAAC,aAAa,EAAE,UAAU,CAAC;6BACxC;yBACD;wBACD,OAAO,EAAE,EAAE;qBACX;iBACD;aACD;SACD;KACD;IACD;QACC,WAAW,EAAE,8FAA8F,iBAAiC,4EAA4E;QACxN,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,eAAe,EAAE,CAAC,IAAI,CAAC;aACvB;SACD;KACD;CACD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { HumanMessage } from '@langchain/core/messages';
2
+ import type { IExecuteFunctions, IBinaryData } from 'n8n-workflow';
3
+ import { OperationalError } from 'n8n-workflow';
4
+ import type { MessageTemplate } from './types';
5
+ export declare class UnsupportedMimeTypeError extends OperationalError {
6
+ }
7
+ export declare function dataUriFromImageData(binaryData: IBinaryData, bufferData: Buffer): string;
8
+ export declare function createImageMessage({ context, itemIndex, message, }: {
9
+ context: IExecuteFunctions;
10
+ itemIndex: number;
11
+ message: MessageTemplate;
12
+ }): Promise<HumanMessage>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedMimeTypeError = void 0;
4
+ exports.dataUriFromImageData = dataUriFromImageData;
5
+ exports.createImageMessage = createImageMessage;
6
+ const messages_1 = require("@langchain/core/messages");
7
+ const google_genai_1 = require("@langchain/google-genai");
8
+ const ollama_1 = require("@langchain/ollama");
9
+ const n8n_workflow_1 = require("n8n-workflow");
10
+ class UnsupportedMimeTypeError extends n8n_workflow_1.OperationalError {
11
+ }
12
+ exports.UnsupportedMimeTypeError = UnsupportedMimeTypeError;
13
+ function dataUriFromImageData(binaryData, bufferData) {
14
+ if (!binaryData.mimeType?.startsWith('image/')) {
15
+ throw new UnsupportedMimeTypeError(`${binaryData.mimeType} is not a supported type of binary data. Only images are supported.`);
16
+ }
17
+ return `data:${binaryData.mimeType};base64,${bufferData.toString('base64')}`;
18
+ }
19
+ async function createImageMessage({ context, itemIndex, message, }) {
20
+ if (message.messageType !== 'imageBinary' && message.messageType !== 'imageUrl') {
21
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Invalid message type. Only imageBinary and imageUrl are supported');
22
+ }
23
+ const detail = message.imageDetail === 'auto' ? undefined : message.imageDetail;
24
+ if (message.messageType === 'imageUrl' && message.imageUrl) {
25
+ return new messages_1.HumanMessage({
26
+ content: [
27
+ {
28
+ type: 'image_url',
29
+ image_url: {
30
+ url: message.imageUrl,
31
+ detail,
32
+ },
33
+ },
34
+ ],
35
+ });
36
+ }
37
+ const binaryDataKey = message.binaryImageDataKey ?? 'data';
38
+ const inputData = context.getInputData()[itemIndex];
39
+ const binaryData = inputData.binary?.[binaryDataKey];
40
+ if (!binaryData) {
41
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'No binary data set.');
42
+ }
43
+ const bufferData = await context.helpers.getBinaryDataBuffer(itemIndex, binaryDataKey);
44
+ const model = (await context.getInputConnectionData("ai_languageModel", 0));
45
+ try {
46
+ const dataURI = dataUriFromImageData(binaryData, bufferData);
47
+ const directUriModels = [google_genai_1.ChatGoogleGenerativeAI, ollama_1.ChatOllama];
48
+ const imageUrl = directUriModels.some((i) => model instanceof i)
49
+ ? dataURI
50
+ : { url: dataURI, detail };
51
+ return new messages_1.HumanMessage({
52
+ content: [
53
+ {
54
+ type: 'image_url',
55
+ image_url: imageUrl,
56
+ },
57
+ ],
58
+ });
59
+ }
60
+ catch (error) {
61
+ if (error instanceof UnsupportedMimeTypeError)
62
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), error.message);
63
+ throw error;
64
+ }
65
+ }
66
+ //# sourceMappingURL=imageUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageUtils.js","sourceRoot":"","sources":["../../../../../nodes/chains/ChainLLM/methods/imageUtils.ts"],"names":[],"mappings":";;;AAcA,oDAOC;AAKD,gDAwEC;AAjGD,uDAAwD;AACxD,0DAAiE;AACjE,8CAA+C;AAE/C,+CAAwF;AAIxF,MAAa,wBAAyB,SAAQ,+BAAgB;CAAG;AAAjE,4DAAiE;AAKjE,SAAgB,oBAAoB,CAAC,UAAuB,EAAE,UAAkB;IAC/E,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,wBAAwB,CACjC,GAAG,UAAU,CAAC,QAAQ,qEAAqE,CAC3F,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,UAAU,CAAC,QAAQ,WAAW,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC9E,CAAC;AAKM,KAAK,UAAU,kBAAkB,CAAC,EACxC,OAAO,EACP,SAAS,EACT,OAAO,GAKP;IAEA,IAAI,OAAO,CAAC,WAAW,KAAK,aAAa,IAAI,OAAO,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACjF,MAAM,IAAI,iCAAkB,CAC3B,OAAO,CAAC,OAAO,EAAE,EACjB,mEAAmE,CACnE,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,C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AAC;YACvB,OAAO,EAAE;gBACR;oBACC,IAAI,EAAE,WAAW;oBACjB,SAAS,EAAE,QAAQ;iBACnB;aACD;SACD,CAAC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,KAAK,YAAY,wBAAwB;YAC5C,MAAM,IAAI,iCAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAChE,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { executeChain } from './chainExecutor';
2
+ export { getInputs, nodeProperties } from './config';
3
+ export { formatResponse } from './responseFormatter';
4
+ export type { MessageTemplate } from './types';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatResponse = exports.nodeProperties = exports.getInputs = exports.executeChain = void 0;
4
+ var chainExecutor_1 = require("./chainExecutor");
5
+ Object.defineProperty(exports, "executeChain", { enumerable: true, get: function () { return chainExecutor_1.executeChain; } });
6
+ var config_1 = require("./config");
7
+ Object.defineProperty(exports, "getInputs", { enumerable: true, get: function () { return config_1.getInputs; } });
8
+ Object.defineProperty(exports, "nodeProperties", { enumerable: true, get: function () { return config_1.nodeProperties; } });
9
+ var responseFormatter_1 = require("./responseFormatter");
10
+ Object.defineProperty(exports, "formatResponse", { enumerable: true, get: function () { return responseFormatter_1.formatResponse; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/chains/ChainLLM/methods/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,mCAAqD;AAA5C,mGAAA,SAAS,OAAA;AAAE,wGAAA,cAAc,OAAA;AAClC,yDAAqD;AAA5C,mHAAA,cAAc,OAAA"}
@@ -0,0 +1,3 @@
1
+ import { PromptTemplate, ChatPromptTemplate } from '@langchain/core/prompts';
2
+ import type { PromptParams } from './types';
3
+ export declare function createPromptTemplate({ context, itemIndex, llm, messages, formatInstructions, query, }: PromptParams): Promise<PromptTemplate<any, any> | ChatPromptTemplate<any, any>>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPromptTemplate = createPromptTemplate;
4
+ const messages_1 = require("@langchain/core/messages");
5
+ const prompts_1 = require("@langchain/core/prompts");
6
+ const n8n_workflow_1 = require("n8n-workflow");
7
+ const helpers_1 = require("../../../../utils/helpers");
8
+ const imageUtils_1 = require("./imageUtils");
9
+ function buildQueryTemplate(formatInstructions) {
10
+ return new prompts_1.PromptTemplate({
11
+ template: `{query}${formatInstructions ? '\n{formatInstructions}' : ''}`,
12
+ inputVariables: ['query'],
13
+ partialVariables: formatInstructions ? { formatInstructions } : undefined,
14
+ });
15
+ }
16
+ async function processMessageTemplates({ context, itemIndex, messages, }) {
17
+ return await Promise.all(messages.map(async (message) => {
18
+ const messageClass = [
19
+ prompts_1.SystemMessagePromptTemplate,
20
+ prompts_1.AIMessagePromptTemplate,
21
+ prompts_1.HumanMessagePromptTemplate,
22
+ ].find((m) => m.lc_name() === message.type);
23
+ if (!messageClass) {
24
+ throw new n8n_workflow_1.OperationalError('Invalid message type', {
25
+ extra: { messageType: message.type },
26
+ });
27
+ }
28
+ if (messageClass === prompts_1.HumanMessagePromptTemplate && message.messageType !== 'text') {
29
+ return await (0, imageUtils_1.createImageMessage)({ context, itemIndex, message });
30
+ }
31
+ return messageClass.fromTemplate((message.message || '').replace(/[{}]/g, (match) => match + match));
32
+ }));
33
+ }
34
+ async function finalizePromptTemplate({ parsedMessages, queryTemplate, query, }) {
35
+ const lastMessage = parsedMessages[parsedMessages.length - 1];
36
+ if (lastMessage instanceof messages_1.HumanMessage && Array.isArray(lastMessage.content)) {
37
+ const humanMessage = new prompts_1.HumanMessagePromptTemplate(queryTemplate);
38
+ const formattedMessage = await humanMessage.format({ query });
39
+ if (Array.isArray(lastMessage.content)) {
40
+ const updatedContent = [
41
+ ...lastMessage.content,
42
+ {
43
+ text: formattedMessage.content.toString(),
44
+ type: 'text',
45
+ },
46
+ ];
47
+ lastMessage.content = updatedContent;
48
+ }
49
+ }
50
+ else {
51
+ parsedMessages.push(new prompts_1.HumanMessagePromptTemplate(queryTemplate));
52
+ }
53
+ return prompts_1.ChatPromptTemplate.fromMessages(parsedMessages);
54
+ }
55
+ async function createPromptTemplate({ context, itemIndex, llm, messages, formatInstructions, query, }) {
56
+ const queryTemplate = buildQueryTemplate(formatInstructions);
57
+ if (!(0, helpers_1.isChatInstance)(llm)) {
58
+ return queryTemplate;
59
+ }
60
+ const parsedMessages = messages?.length
61
+ ? await processMessageTemplates({ context, itemIndex, messages })
62
+ : [];
63
+ return await finalizePromptTemplate({
64
+ parsedMessages,
65
+ queryTemplate,
66
+ query,
67
+ });
68
+ }
69
+ //# sourceMappingURL=promptUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptUtils.js","sourceRoot":"","sources":["../../../../../nodes/chains/ChainLLM/methods/promptUtils.ts"],"names":[],"mappings":";;AAqHA,oDA2BC;AAhJD,uDAAwD;AAExD,qDAMiC;AAEjC,+CAAgD;AAEhD,4CAAgD;AAEhD,6CAAkD;AAMlD,SAAS,kBAAkB,CAAC,kBAA2B;IACtD,OAAO,IAAI,wBAAc,CAAC;QACzB,QAAQ,EAAE,UAAU,kBAAkB,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,EAAE;QACxE,cAAc,EAAE,CAAC,OAAO,CAAC;QACzB,gBAAgB,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,SAAS;KACzE,CAAC,CAAC;AACJ,CAAC;AAKD,KAAK,UAAU,uBAAuB,CAAC,EACtC,OAAO,EACP,SAAS,EACT,QAAQ,GAKR;IACA,OAAO,MAAM,OAAO,CAAC,GAAG,CACvB,QAAQ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C,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;YAExC,MAAM,cAAc,GAAG;gBACtB,GAAG,WAAW,CAAC,OAAO;gBACtB;oBACC,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE;oBACzC,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YAGF,WAAW,CAAC,OAAO,GAAG,cAAc,CAAC;QACtC,CAAC;IACF,CAAC;SAAM,CAAC;QAEP,cAAc,CAAC,IAAI,CAAC,IAAI,oCAA0B,CAAC,aAAa,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,4BAAkB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;AACxD,CAAC;AAMM,KAAK,UAAU,oBAAoB,CAAC,EAC1C,OAAO,EACP,SAAS,EACT,GAAG,EACH,QAAQ,EACR,kBAAkB,EAClB,KAAK,GACS;IAEd,MAAM,aAAa,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IAG7D,IAAI,CAAC,IAAA,wBAAc,EAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,aAAa,CAAC;IACtB,CAAC;IAGD,MAAM,cAAc,GAAG,QAAQ,EAAE,MAAM;QACtC,CAAC,CAAC,MAAM,uBAAuB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;QACjE,CAAC,CAAC,EAAE,CAAC;IAGN,OAAO,MAAM,sBAAsB,CAAC;QACnC,cAAc;QACd,aAAa;QACb,KAAK;KACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { IDataObject } from 'n8n-workflow';
2
+ export declare function formatResponse(response: unknown, version: number): IDataObject;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatResponse = formatResponse;
4
+ function formatResponse(response, version) {
5
+ if (typeof response === 'string') {
6
+ return {
7
+ text: response.trim(),
8
+ };
9
+ }
10
+ if (Array.isArray(response)) {
11
+ return {
12
+ data: response,
13
+ };
14
+ }
15
+ if (response instanceof Object) {
16
+ if (version >= 1.6) {
17
+ return response;
18
+ }
19
+ return {
20
+ text: JSON.stringify(response),
21
+ };
22
+ }
23
+ return {
24
+ response: {
25
+ text: response,
26
+ },
27
+ };
28
+ }
29
+ //# sourceMappingURL=responseFormatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responseFormatter.js","sourceRoot":"","sources":["../../../../../nodes/chains/ChainLLM/methods/responseFormatter.ts"],"names":[],"mappings":";;AAKA,wCA4BC;AA5BD,SAAgB,cAAc,CAAC,QAAiB,EAAE,OAAe;IAChE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO;YACN,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;SACrB,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO;YACN,IAAI,EAAE,QAAQ;SACd,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,YAAY,MAAM,EAAE,CAAC;QAChC,IAAI,OAAO,IAAI,GAAG,EAAE,CAAC;YACpB,OAAO,QAAuB,CAAC;QAChC,CAAC;QAED,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;SAC9B,CAAC;IACH,CAAC;IAED,OAAO;QACN,QAAQ,EAAE;YACT,IAAI,EAAE,QAAQ;SACd;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { BaseLanguageModel } from '@langchain/core/language_models/base';
2
+ import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
3
+ import type { IExecuteFunctions } from 'n8n-workflow';
4
+ import type { N8nOutputParser } from '../../../../utils/output_parsers/N8nOutputParser';
5
+ export interface MessageTemplate {
6
+ type: string;
7
+ message: string;
8
+ messageType: 'text' | 'imageBinary' | 'imageUrl';
9
+ binaryImageDataKey?: string;
10
+ imageUrl?: string;
11
+ imageDetail?: 'auto' | 'low' | 'high';
12
+ }
13
+ export interface PromptParams {
14
+ context: IExecuteFunctions;
15
+ itemIndex: number;
16
+ llm: BaseLanguageModel | BaseChatModel;
17
+ messages?: MessageTemplate[];
18
+ formatInstructions?: string;
19
+ query?: string;
20
+ }
21
+ export interface ChainExecutionParams {
22
+ context: IExecuteFunctions;
23
+ itemIndex: number;
24
+ query: string;
25
+ llm: BaseLanguageModel;
26
+ outputParser?: N8nOutputParser;
27
+ messages?: MessageTemplate[];
28
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../nodes/chains/ChainLLM/methods/types.ts"],"names":[],"mappings":""}