@n8n/n8n-nodes-langchain 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/credentials/McpOAuth2Api.credentials.js +1 -2
  2. package/dist/credentials/McpOAuth2Api.credentials.js.map +1 -1
  3. package/dist/nodes/agents/Agent/Agent.node.js +4 -2
  4. package/dist/nodes/agents/Agent/Agent.node.js.map +1 -1
  5. package/dist/nodes/agents/Agent/AgentTool.node.js +4 -2
  6. package/dist/nodes/agents/Agent/AgentTool.node.js.map +1 -1
  7. package/dist/nodes/agents/Agent/V1/AgentV1.node.js +1 -1
  8. package/dist/nodes/agents/Agent/V1/AgentV1.node.js.map +1 -1
  9. package/dist/nodes/agents/Agent/V2/AgentV2.node.js +1 -1
  10. package/dist/nodes/agents/Agent/V2/AgentV2.node.js.map +1 -1
  11. package/dist/nodes/agents/Agent/V3/AgentToolV3.node.js +99 -0
  12. package/dist/nodes/agents/Agent/V3/AgentToolV3.node.js.map +1 -0
  13. package/dist/nodes/agents/Agent/V3/AgentV3.node.js +9 -2
  14. package/dist/nodes/agents/Agent/V3/AgentV3.node.js.map +1 -1
  15. package/dist/nodes/agents/Agent/agents/SqlAgent/description.js +1 -1
  16. package/dist/nodes/agents/Agent/agents/SqlAgent/description.js.map +1 -1
  17. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js +1 -3
  18. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/execute.js.map +1 -1
  19. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/executeBatch.js +4 -0
  20. package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/executeBatch.js.map +1 -1
  21. package/dist/nodes/chains/ChainLLM/ChainLlm.node.js +1 -1
  22. package/dist/nodes/chains/ChainLLM/ChainLlm.node.js.map +1 -1
  23. package/dist/nodes/chains/ChainLLM/methods/config.js +10 -2
  24. package/dist/nodes/chains/ChainLLM/methods/config.js.map +1 -1
  25. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js +11 -3
  26. package/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js.map +1 -1
  27. package/dist/nodes/tools/ToolSerpApi/ToolSerpApi.node.js +9 -3
  28. package/dist/nodes/tools/ToolSerpApi/ToolSerpApi.node.js.map +1 -1
  29. package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js +3 -0
  30. package/dist/nodes/tools/ToolWorkflow/v2/utils/WorkflowToolService.js.map +1 -1
  31. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +66 -15
  32. package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
  33. package/dist/nodes/trigger/ChatTrigger/templates.js +1 -2
  34. package/dist/nodes/trigger/ChatTrigger/templates.js.map +1 -1
  35. package/dist/nodes/vendors/GoogleGemini/actions/file/index.js +2 -2
  36. package/dist/nodes/vendors/GoogleGemini/actions/file/index.js.map +1 -1
  37. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/createStore.operation.js +64 -0
  38. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/createStore.operation.js.map +1 -0
  39. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/deleteStore.operation.js +72 -0
  40. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/deleteStore.operation.js.map +1 -0
  41. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/index.js +94 -0
  42. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/index.js.map +1 -0
  43. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/listStores.operation.js +75 -0
  44. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/listStores.operation.js.map +1 -0
  45. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/uploadToStore.operation.js +129 -0
  46. package/dist/nodes/vendors/GoogleGemini/actions/fileSearch/uploadToStore.operation.js.map +1 -0
  47. package/dist/nodes/vendors/GoogleGemini/actions/node.type.js.map +1 -1
  48. package/dist/nodes/vendors/GoogleGemini/actions/router.js +4 -0
  49. package/dist/nodes/vendors/GoogleGemini/actions/router.js.map +1 -1
  50. package/dist/nodes/vendors/GoogleGemini/actions/text/message.operation.js +184 -11
  51. package/dist/nodes/vendors/GoogleGemini/actions/text/message.operation.js.map +1 -1
  52. package/dist/nodes/vendors/GoogleGemini/actions/versionDescription.js +10 -3
  53. package/dist/nodes/vendors/GoogleGemini/actions/versionDescription.js.map +1 -1
  54. package/dist/nodes/vendors/GoogleGemini/helpers/interfaces.js.map +1 -1
  55. package/dist/nodes/vendors/GoogleGemini/helpers/utils.js +131 -26
  56. package/dist/nodes/vendors/GoogleGemini/helpers/utils.js.map +1 -1
  57. package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js +1 -1
  58. package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js.map +1 -1
  59. package/dist/types/credentials.json +1 -1
  60. package/dist/types/nodes.json +9 -8
  61. package/dist/utils/agent-execution/buildSteps.js +67 -8
  62. package/dist/utils/agent-execution/buildSteps.js.map +1 -1
  63. package/dist/utils/agent-execution/createEngineRequests.js +27 -5
  64. package/dist/utils/agent-execution/createEngineRequests.js.map +1 -1
  65. package/dist/utils/agent-execution/types.js +24 -0
  66. package/dist/utils/agent-execution/types.js.map +1 -1
  67. package/dist/utils/descriptions.js +21 -1
  68. package/dist/utils/descriptions.js.map +1 -1
  69. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../nodes/vendors/GoogleGemini/helpers/interfaces.ts"],"sourcesContent":["import type {\n\tGenerateContentConfig,\n\tGenerationConfig,\n\tGenerateContentParameters,\n} from '@google/genai';\nimport type { IDataObject } from 'n8n-workflow';\nexport { Modality } from '@google/genai';\n\n/* type created based on: https://ai.google.dev/api/generate-content#generationconfig */\nexport type GenerateContentGenerationConfig = Pick<\n\tGenerationConfig,\n\t| 'stopSequences'\n\t| 'responseMimeType'\n\t| 'responseSchema'\n\t| 'responseJsonSchema'\n\t| 'responseModalities'\n\t| 'candidateCount'\n\t| 'maxOutputTokens'\n\t| 'temperature'\n\t| 'topP'\n\t| 'topK'\n\t| 'seed'\n\t| 'presencePenalty'\n\t| 'frequencyPenalty'\n\t| 'responseLogprobs'\n\t| 'logprobs'\n\t| 'speechConfig'\n\t| 'thinkingConfig'\n\t| 'mediaResolution'\n>;\n\n/* Type created based on: https://ai.google.dev/api/generate-content#method:-models.streamgeneratecontent */\nexport interface GenerateContentRequest extends IDataObject {\n\tcontents: GenerateContentParameters['contents'];\n\ttools?: GenerateContentConfig['tools'];\n\ttoolConfig?: GenerateContentConfig['toolConfig'];\n\tsystemInstruction?: GenerateContentConfig['systemInstruction'];\n\tsafetySettings?: GenerateContentConfig['safetySettings'];\n\tgenerationConfig?: GenerateContentGenerationConfig;\n\tcachedContent?: string;\n}\n\nexport interface GenerateContentResponse {\n\tcandidates: Array<{\n\t\tcontent: Content;\n\t}>;\n}\n\nexport interface Content {\n\tparts: Part[];\n\trole: string;\n}\n\nexport type Part =\n\t| { text: string }\n\t| {\n\t\t\tinlineData: {\n\t\t\t\tmimeType: string;\n\t\t\t\tdata: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\tfunctionCall: {\n\t\t\t\tid?: string;\n\t\t\t\tname: string;\n\t\t\t\targs?: IDataObject;\n\t\t\t};\n\t }\n\t| {\n\t\t\tfunctionResponse: {\n\t\t\t\tid?: string;\n\t\t\t\tname: string;\n\t\t\t\tresponse: IDataObject;\n\t\t\t};\n\t }\n\t| {\n\t\t\tfileData?: {\n\t\t\t\tmimeType?: string;\n\t\t\t\tfileUri?: string;\n\t\t\t};\n\t };\n\nexport interface ImagenResponse {\n\tpredictions: Array<{\n\t\tbytesBase64Encoded: string;\n\t\tmimeType: string;\n\t}>;\n}\n\nexport interface VeoResponse {\n\tname: string;\n\tdone: boolean;\n\terror?: {\n\t\tmessage: string;\n\t};\n\tresponse: {\n\t\tgenerateVideoResponse: {\n\t\t\tgeneratedSamples: Array<{\n\t\t\t\tvideo: {\n\t\t\t\t\turi: string;\n\t\t\t\t};\n\t\t\t}>;\n\t\t};\n\t};\n}\n\nexport interface Tool {\n\tfunctionDeclarations?: Array<{\n\t\tname: string;\n\t\tdescription: string;\n\t\tparameters: IDataObject;\n\t}>;\n\tcodeExecution?: object;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,mBAAyB;","names":[]}
1
+ {"version":3,"sources":["../../../../../nodes/vendors/GoogleGemini/helpers/interfaces.ts"],"sourcesContent":["import type {\n\tGenerateContentConfig,\n\tGenerationConfig,\n\tGenerateContentParameters,\n} from '@google/genai';\nimport type { IDataObject } from 'n8n-workflow';\nexport { Modality } from '@google/genai';\n\n/* type created based on: https://ai.google.dev/api/generate-content#generationconfig */\nexport type GenerateContentGenerationConfig = Pick<\n\tGenerationConfig,\n\t| 'stopSequences'\n\t| 'responseMimeType'\n\t| 'responseSchema'\n\t| 'responseJsonSchema'\n\t| 'responseModalities'\n\t| 'candidateCount'\n\t| 'maxOutputTokens'\n\t| 'temperature'\n\t| 'topP'\n\t| 'topK'\n\t| 'seed'\n\t| 'presencePenalty'\n\t| 'frequencyPenalty'\n\t| 'responseLogprobs'\n\t| 'logprobs'\n\t| 'speechConfig'\n\t| 'thinkingConfig'\n\t| 'mediaResolution'\n>;\n\n/* Type created based on: https://ai.google.dev/api/generate-content#method:-models.streamgeneratecontent */\nexport interface GenerateContentRequest extends IDataObject {\n\tcontents: GenerateContentParameters['contents'];\n\ttools?: GenerateContentConfig['tools'];\n\ttoolConfig?: GenerateContentConfig['toolConfig'];\n\tsystemInstruction?: GenerateContentConfig['systemInstruction'];\n\tsafetySettings?: GenerateContentConfig['safetySettings'];\n\tgenerationConfig?: GenerateContentGenerationConfig;\n\tcachedContent?: string;\n}\n\nexport interface GenerateContentResponse {\n\tcandidates: Array<{\n\t\tcontent: Content;\n\t}>;\n}\n\nexport interface Content {\n\tparts: Part[];\n\trole: string;\n}\n\nexport type Part =\n\t| { text: string }\n\t| {\n\t\t\tinlineData: {\n\t\t\t\tmimeType: string;\n\t\t\t\tdata: string;\n\t\t\t};\n\t }\n\t| {\n\t\t\tfunctionCall: {\n\t\t\t\tid?: string;\n\t\t\t\tname: string;\n\t\t\t\targs?: IDataObject;\n\t\t\t};\n\t }\n\t| {\n\t\t\tfunctionResponse: {\n\t\t\t\tid?: string;\n\t\t\t\tname: string;\n\t\t\t\tresponse: IDataObject;\n\t\t\t};\n\t }\n\t| {\n\t\t\tfileData?: {\n\t\t\t\tmimeType?: string;\n\t\t\t\tfileUri?: string;\n\t\t\t};\n\t };\n\nexport interface ImagenResponse {\n\tpredictions: Array<{\n\t\tbytesBase64Encoded: string;\n\t\tmimeType: string;\n\t}>;\n}\n\nexport interface VeoResponse {\n\tname: string;\n\tdone: boolean;\n\terror?: {\n\t\tmessage: string;\n\t};\n\tresponse: {\n\t\tgenerateVideoResponse: {\n\t\t\tgeneratedSamples: Array<{\n\t\t\t\tvideo: {\n\t\t\t\t\turi: string;\n\t\t\t\t};\n\t\t\t}>;\n\t\t};\n\t};\n}\n\n/**\n * File Search operation interface for long-running upload operations\n * Based on: https://ai.google.dev/api/file-search/file-search-stores#method:-media.uploadtofilesearchstore\n */\nexport interface FileSearchOperation {\n\tname: string;\n\tdone: boolean;\n\terror?: { message: string };\n\tresponse?: IDataObject;\n}\n\n/**\n * User configuration for built-in tools in the node parameters\n */\nexport interface BuiltInTools {\n\tgoogleSearch?: boolean;\n\tgoogleMaps?: {\n\t\tlatitude?: number | string;\n\t\tlongitude?: number | string;\n\t};\n\turlContext?: boolean;\n\tfileSearch?: {\n\t\tfileSearchStoreNames?: string;\n\t\tmetadataFilter?: string;\n\t};\n\tcodeExecution?: boolean;\n}\n\n/**\n * Tool structure for the Google Gemini API request\n */\nexport interface Tool {\n\tfunctionDeclarations?: Array<{\n\t\tname: string;\n\t\tdescription: string;\n\t\tparameters: IDataObject;\n\t}>;\n\tgoogleSearch?: object;\n\tgoogleMaps?: object;\n\turlContext?: object;\n\tfileSearch?: {\n\t\tfileSearchStoreNames?: string[];\n\t\tmetadataFilter?: string;\n\t};\n\tcodeExecution?: object;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,mBAAyB;","names":[]}
@@ -28,14 +28,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var utils_exports = {};
30
30
  __export(utils_exports, {
31
+ createFileSearchStore: () => createFileSearchStore,
32
+ deleteFileSearchStore: () => deleteFileSearchStore,
31
33
  downloadFile: () => downloadFile,
34
+ listFileSearchStores: () => listFileSearchStores,
32
35
  transferFile: () => transferFile,
33
- uploadFile: () => uploadFile
36
+ uploadFile: () => uploadFile,
37
+ uploadToFileSearchStore: () => uploadToFileSearchStore
34
38
  });
35
39
  module.exports = __toCommonJS(utils_exports);
40
+ var import_axios = __toESM(require("axios"));
36
41
  var import_n8n_workflow = require("n8n-workflow");
42
+ var import_node_stream = require("node:stream");
37
43
  var import_transport = require("../transport");
38
- var import_axios = __toESM(require("axios"));
44
+ const OPERATION_CHECK_INTERVAL = 1e3;
39
45
  const CHUNK_SIZE = 256 * 1024;
40
46
  async function downloadFile(url, fallbackMimeType, qs) {
41
47
  const downloadResponse = await this.helpers.httpRequest({
@@ -78,7 +84,7 @@ async function uploadFile(fileContent, mimeType) {
78
84
  body: fileContent
79
85
  });
80
86
  while (uploadResponse.file.state !== "ACTIVE" && uploadResponse.file.state !== "FAILED") {
81
- await new Promise((resolve) => setTimeout(resolve, 1e3));
87
+ await new Promise((resolve) => setTimeout(resolve, OPERATION_CHECK_INTERVAL));
82
88
  uploadResponse.file = await import_transport.apiRequest.call(
83
89
  this,
84
90
  "GET",
@@ -96,46 +102,59 @@ async function uploadFile(fileContent, mimeType) {
96
102
  }
97
103
  return { fileUri: uploadResponse.file.uri, mimeType: uploadResponse.file.mimeType };
98
104
  }
99
- async function transferFile(i, downloadUrl, fallbackMimeType, qs) {
100
- let stream;
101
- let mimeType;
105
+ async function getFileStreamFromUrlOrBinary(i, downloadUrl, fallbackMimeType, qs) {
102
106
  if (downloadUrl) {
103
107
  const downloadResponse = await import_axios.default.get(downloadUrl, {
104
108
  params: qs,
105
109
  responseType: "stream"
106
110
  });
107
- mimeType = downloadResponse.headers["content-type"]?.split(";")?.[0] ?? fallbackMimeType;
108
- stream = downloadResponse.data;
109
- } else {
110
- const binaryPropertyName = this.getNodeParameter("binaryPropertyName", i, "data");
111
- if (!binaryPropertyName) {
112
- throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Binary property name is required", {
111
+ const contentType = downloadResponse.headers["content-type"];
112
+ const mimeType = contentType?.split(";")?.[0] ?? fallbackMimeType ?? "application/octet-stream";
113
+ return {
114
+ stream: downloadResponse.data,
115
+ mimeType
116
+ };
117
+ }
118
+ const binaryPropertyName = this.getNodeParameter("binaryPropertyName", i, "data");
119
+ if (!binaryPropertyName) {
120
+ throw new import_n8n_workflow.NodeOperationError(
121
+ this.getNode(),
122
+ "Binary property name or download URL is required",
123
+ {
113
124
  description: "Error uploading file"
114
- });
115
- }
116
- const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
117
- if (!binaryData.id) {
118
- const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
119
- return await uploadFile.call(this, buffer, binaryData.mimeType);
120
- } else {
121
- stream = await this.helpers.getBinaryStream(binaryData.id, CHUNK_SIZE);
122
- mimeType = binaryData.mimeType;
123
- }
125
+ }
126
+ );
124
127
  }
125
- const uploadInitResponse = await import_transport.apiRequest.call(this, "POST", "/upload/v1beta/files", {
128
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
129
+ if (!binaryData.id) {
130
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
131
+ return {
132
+ buffer,
133
+ mimeType: binaryData.mimeType
134
+ };
135
+ }
136
+ return {
137
+ stream: await this.helpers.getBinaryStream(binaryData.id, CHUNK_SIZE),
138
+ mimeType: binaryData.mimeType
139
+ };
140
+ }
141
+ async function uploadStream(stream, config) {
142
+ const { endpoint, mimeType, body } = config;
143
+ const uploadInitResponse = await import_transport.apiRequest.call(this, "POST", endpoint, {
126
144
  headers: {
127
145
  "X-Goog-Upload-Protocol": "resumable",
128
146
  "X-Goog-Upload-Command": "start",
129
147
  "X-Goog-Upload-Header-Content-Type": mimeType,
130
148
  "Content-Type": "application/json"
131
149
  },
150
+ body,
132
151
  option: { returnFullResponse: true }
133
152
  });
134
153
  const uploadUrl = uploadInitResponse.headers["x-goog-upload-url"];
135
154
  if (!uploadUrl) {
136
155
  throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Failed to get upload URL");
137
156
  }
138
- const uploadResponse = await this.helpers.httpRequest({
157
+ return await this.helpers.httpRequest({
139
158
  method: "POST",
140
159
  url: uploadUrl,
141
160
  headers: {
@@ -146,9 +165,26 @@ async function transferFile(i, downloadUrl, fallbackMimeType, qs) {
146
165
  body: stream,
147
166
  returnFullResponse: true
148
167
  });
168
+ }
169
+ async function transferFile(i, downloadUrl, fallbackMimeType, qs) {
170
+ const fileData = await getFileStreamFromUrlOrBinary.call(
171
+ this,
172
+ i,
173
+ downloadUrl,
174
+ fallbackMimeType,
175
+ qs
176
+ );
177
+ if ("buffer" in fileData) {
178
+ return await uploadFile.call(this, fileData.buffer, fileData.mimeType);
179
+ }
180
+ const { stream, mimeType } = fileData;
181
+ const uploadResponse = await uploadStream.call(this, stream, {
182
+ endpoint: "/upload/v1beta/files",
183
+ mimeType
184
+ });
149
185
  let file = uploadResponse.body.file;
150
186
  while (file.state !== "ACTIVE" && file.state !== "FAILED") {
151
- await new Promise((resolve) => setTimeout(resolve, 1e3));
187
+ await new Promise((resolve) => setTimeout(resolve, OPERATION_CHECK_INTERVAL));
152
188
  file = await import_transport.apiRequest.call(this, "GET", `/v1beta/${file.name}`);
153
189
  }
154
190
  if (file.state === "FAILED") {
@@ -158,10 +194,79 @@ async function transferFile(i, downloadUrl, fallbackMimeType, qs) {
158
194
  }
159
195
  return { fileUri: file.uri, mimeType: file.mimeType };
160
196
  }
197
+ async function createFileSearchStore(displayName) {
198
+ return await import_transport.apiRequest.call(this, "POST", "/v1beta/fileSearchStores", {
199
+ body: { displayName }
200
+ });
201
+ }
202
+ async function uploadToFileSearchStore(i, fileSearchStoreName, displayName, downloadUrl, fallbackMimeType, qs) {
203
+ const fileData = await getFileStreamFromUrlOrBinary.call(
204
+ this,
205
+ i,
206
+ downloadUrl,
207
+ fallbackMimeType,
208
+ qs
209
+ );
210
+ let stream;
211
+ let mimeType;
212
+ if ("buffer" in fileData) {
213
+ stream = import_node_stream.Readable.from(fileData.buffer);
214
+ mimeType = fileData.mimeType;
215
+ } else {
216
+ stream = fileData.stream;
217
+ mimeType = fileData.mimeType;
218
+ }
219
+ const uploadResponse = await uploadStream.call(this, stream, {
220
+ endpoint: `/upload/v1beta/${fileSearchStoreName}:uploadToFileSearchStore`,
221
+ mimeType,
222
+ body: { displayName, mimeType }
223
+ });
224
+ const operationName = uploadResponse.body.name;
225
+ let operation = await import_transport.apiRequest.call(
226
+ this,
227
+ "GET",
228
+ `/v1beta/${operationName}`
229
+ );
230
+ while (!operation.done) {
231
+ await new Promise((resolve) => setTimeout(resolve, OPERATION_CHECK_INTERVAL));
232
+ operation = await import_transport.apiRequest.call(
233
+ this,
234
+ "GET",
235
+ `/v1beta/${operationName}`
236
+ );
237
+ }
238
+ if (operation.error) {
239
+ throw new import_n8n_workflow.NodeOperationError(this.getNode(), operation.error.message ?? "Unknown error", {
240
+ description: "Error uploading file to File Search store"
241
+ });
242
+ }
243
+ return operation.response;
244
+ }
245
+ async function listFileSearchStores(pageSize, pageToken) {
246
+ const qs = {};
247
+ if (pageSize !== void 0) {
248
+ qs.pageSize = pageSize;
249
+ }
250
+ if (pageToken) {
251
+ qs.pageToken = pageToken;
252
+ }
253
+ return await import_transport.apiRequest.call(this, "GET", "/v1beta/fileSearchStores", { qs });
254
+ }
255
+ async function deleteFileSearchStore(name, force) {
256
+ const qs = {};
257
+ if (force !== void 0) {
258
+ qs.force = force;
259
+ }
260
+ return await import_transport.apiRequest.call(this, "DELETE", `/v1beta/${name}`, { qs });
261
+ }
161
262
  // Annotate the CommonJS export names for ESM import in node:
162
263
  0 && (module.exports = {
264
+ createFileSearchStore,
265
+ deleteFileSearchStore,
163
266
  downloadFile,
267
+ listFileSearchStores,
164
268
  transferFile,
165
- uploadFile
269
+ uploadFile,
270
+ uploadToFileSearchStore
166
271
  });
167
272
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../nodes/vendors/GoogleGemini/helpers/utils.ts"],"sourcesContent":["import type { IDataObject, IExecuteFunctions } from 'n8n-workflow';\nimport { NodeOperationError } from 'n8n-workflow';\n\nimport { apiRequest } from '../transport';\n\nimport axios from 'axios';\nimport type Stream from 'node:stream';\n\ninterface File {\n\tname: string;\n\turi: string;\n\tmimeType: string;\n\tstate: string;\n\terror?: { message: string };\n}\n\nconst CHUNK_SIZE = 256 * 1024;\n\nexport async function downloadFile(\n\tthis: IExecuteFunctions,\n\turl: string,\n\tfallbackMimeType?: string,\n\tqs?: IDataObject,\n) {\n\tconst downloadResponse = (await this.helpers.httpRequest({\n\t\tmethod: 'GET',\n\t\turl,\n\t\tqs,\n\t\treturnFullResponse: true,\n\t\tencoding: 'arraybuffer',\n\t})) as { body: ArrayBuffer; headers: IDataObject };\n\n\tconst mimeType =\n\t\t(downloadResponse.headers?.['content-type'] as string)?.split(';')?.[0] ?? fallbackMimeType;\n\tconst fileContent = Buffer.from(downloadResponse.body);\n\treturn {\n\t\tfileContent,\n\t\tmimeType,\n\t};\n}\n\nexport async function uploadFile(this: IExecuteFunctions, fileContent: Buffer, mimeType: string) {\n\tconst numBytes = fileContent.length.toString();\n\tconst uploadInitResponse = (await apiRequest.call(this, 'POST', '/upload/v1beta/files', {\n\t\theaders: {\n\t\t\t'X-Goog-Upload-Protocol': 'resumable',\n\t\t\t'X-Goog-Upload-Command': 'start',\n\t\t\t'X-Goog-Upload-Header-Content-Length': numBytes,\n\t\t\t'X-Goog-Upload-Header-Content-Type': mimeType,\n\t\t\t'Content-Type': 'application/json',\n\t\t},\n\t\toption: {\n\t\t\treturnFullResponse: true,\n\t\t},\n\t})) as { headers: IDataObject };\n\tconst uploadUrl = uploadInitResponse.headers['x-goog-upload-url'] as string;\n\n\tconst uploadResponse = (await this.helpers.httpRequest({\n\t\tmethod: 'POST',\n\t\turl: uploadUrl,\n\t\theaders: {\n\t\t\t'Content-Length': numBytes,\n\t\t\t'X-Goog-Upload-Offset': '0',\n\t\t\t'X-Goog-Upload-Command': 'upload, finalize',\n\t\t},\n\t\tbody: fileContent,\n\t})) as { file: File };\n\n\twhile (uploadResponse.file.state !== 'ACTIVE' && uploadResponse.file.state !== 'FAILED') {\n\t\tawait new Promise((resolve) => setTimeout(resolve, 1000));\n\t\tuploadResponse.file = (await apiRequest.call(\n\t\t\tthis,\n\t\t\t'GET',\n\t\t\t`/v1beta/${uploadResponse.file.name}`,\n\t\t)) as File;\n\t}\n\n\tif (uploadResponse.file.state === 'FAILED') {\n\t\tthrow new NodeOperationError(\n\t\t\tthis.getNode(),\n\t\t\tuploadResponse.file.error?.message ?? 'Unknown error',\n\t\t\t{\n\t\t\t\tdescription: 'Error uploading file',\n\t\t\t},\n\t\t);\n\t}\n\n\treturn { fileUri: uploadResponse.file.uri, mimeType: uploadResponse.file.mimeType };\n}\n\nexport async function transferFile(\n\tthis: IExecuteFunctions,\n\ti: number,\n\tdownloadUrl?: string,\n\tfallbackMimeType?: string,\n\tqs?: IDataObject,\n) {\n\tlet stream: Stream;\n\tlet mimeType: string;\n\n\tif (downloadUrl) {\n\t\tconst downloadResponse = await axios.get(downloadUrl, {\n\t\t\tparams: qs,\n\t\t\tresponseType: 'stream',\n\t\t});\n\n\t\tmimeType = downloadResponse.headers['content-type']?.split(';')?.[0] ?? fallbackMimeType;\n\t\tstream = downloadResponse.data;\n\t} else {\n\t\tconst binaryPropertyName = this.getNodeParameter('binaryPropertyName', i, 'data');\n\t\tif (!binaryPropertyName) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Binary property name is required', {\n\t\t\t\tdescription: 'Error uploading file',\n\t\t\t});\n\t\t}\n\t\tconst binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);\n\t\tif (!binaryData.id) {\n\t\t\tconst buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);\n\t\t\treturn await uploadFile.call(this, buffer, binaryData.mimeType);\n\t\t} else {\n\t\t\tstream = await this.helpers.getBinaryStream(binaryData.id, CHUNK_SIZE);\n\t\t\tmimeType = binaryData.mimeType;\n\t\t}\n\t}\n\n\tconst uploadInitResponse = (await apiRequest.call(this, 'POST', '/upload/v1beta/files', {\n\t\theaders: {\n\t\t\t'X-Goog-Upload-Protocol': 'resumable',\n\t\t\t'X-Goog-Upload-Command': 'start',\n\t\t\t'X-Goog-Upload-Header-Content-Type': mimeType,\n\t\t\t'Content-Type': 'application/json',\n\t\t},\n\t\toption: { returnFullResponse: true },\n\t})) as { headers: IDataObject };\n\n\tconst uploadUrl = uploadInitResponse.headers['x-goog-upload-url'] as string;\n\tif (!uploadUrl) {\n\t\tthrow new NodeOperationError(this.getNode(), 'Failed to get upload URL');\n\t}\n\n\tconst uploadResponse = (await this.helpers.httpRequest({\n\t\tmethod: 'POST',\n\t\turl: uploadUrl,\n\t\theaders: {\n\t\t\t'X-Goog-Upload-Offset': '0',\n\t\t\t'X-Goog-Upload-Command': 'upload, finalize',\n\t\t\t'Content-Type': mimeType,\n\t\t},\n\t\tbody: stream,\n\t\treturnFullResponse: true,\n\t})) as { body: { file: File } };\n\n\tlet file = uploadResponse.body.file;\n\n\twhile (file.state !== 'ACTIVE' && file.state !== 'FAILED') {\n\t\tawait new Promise((resolve) => setTimeout(resolve, 1000));\n\t\tfile = (await apiRequest.call(this, 'GET', `/v1beta/${file.name}`)) as File;\n\t}\n\n\tif (file.state === 'FAILED') {\n\t\tthrow new NodeOperationError(this.getNode(), file.error?.message ?? 'Unknown error', {\n\t\t\tdescription: 'Error uploading file',\n\t\t});\n\t}\n\n\treturn { fileUri: file.uri, mimeType: file.mimeType };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAmC;AAEnC,uBAA2B;AAE3B,mBAAkB;AAWlB,MAAM,aAAa,MAAM;AAEzB,eAAsB,aAErB,KACA,kBACA,IACC;AACD,QAAM,mBAAoB,MAAM,KAAK,QAAQ,YAAY;AAAA,IACxD,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,IACpB,UAAU;AAAA,EACX,CAAC;AAED,QAAM,WACJ,iBAAiB,UAAU,cAAc,GAAc,MAAM,GAAG,IAAI,CAAC,KAAK;AAC5E,QAAM,cAAc,OAAO,KAAK,iBAAiB,IAAI;AACrD,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAEA,eAAsB,WAAoC,aAAqB,UAAkB;AAChG,QAAM,WAAW,YAAY,OAAO,SAAS;AAC7C,QAAM,qBAAsB,MAAM,4BAAW,KAAK,MAAM,QAAQ,wBAAwB;AAAA,IACvF,SAAS;AAAA,MACR,0BAA0B;AAAA,MAC1B,yBAAyB;AAAA,MACzB,uCAAuC;AAAA,MACvC,qCAAqC;AAAA,MACrC,gBAAgB;AAAA,IACjB;AAAA,IACA,QAAQ;AAAA,MACP,oBAAoB;AAAA,IACrB;AAAA,EACD,CAAC;AACD,QAAM,YAAY,mBAAmB,QAAQ,mBAAmB;AAEhE,QAAM,iBAAkB,MAAM,KAAK,QAAQ,YAAY;AAAA,IACtD,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,SAAS;AAAA,MACR,kBAAkB;AAAA,MAClB,wBAAwB;AAAA,MACxB,yBAAyB;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AS,MAAM,KAAK,QAAQ,gBAAgB,WAAW,IAAI,UAAU;AACrE,iBAAW,WAAW;AAAA,IACvB;AAAA,EACD;AAEA,QAAM,qBAAsB,MAAM,4BAAW,KAAK,MAAM,QAAQ,wBAAwB;AAAA,IACvF,SAAS;AAAA,MACR,0BAA0B;AAAA,MAC1B,yBAAyB;AAAA,MACzB,qCAAqC;AAAA,MACrC,gBAAgB;AAAA,IACjB;AAAA,IACA,QAAQ,EAAE,oBAAoB,KAAK;AAAA,EACpC,CAAC;AAED,QAAM,YAAY,mBAAmB,QAAQ,mBAAmB;AAChE,MAAI,CAAC,WAAW;AACf,UAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,0BAA0B;AAAA,EACxE;AAEA,QAAM,iBAAkB,MAAM,KAAK,QAAQ,YAAY;AAAA,IACtD,QAAQ;AAAA,IACR,KAAK;AAAA,IACL,SAAS;AAAA,MACR,wBAAwB;AAAA,MACxB,yBAAyB;AAAA,MACzB,gBAAgB;AAAA,IACjB;AAAA,IACA,MAAM;AAAA,IACN,oBAAoB;AAAA,EACrB,CAAC;AAED,MAAI,OAAO,eAAe,KAAK;AAE/B,SAAO,KAAK,UAAU,YAAY,KAAK,UAAU,UAAU;AAC1D,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAI,CAAC;AACxD,WAAQ,MAAM,4BAAW,KAAK,MAAM,OAAO,WAAW,KAAK,IAAI,EAAE;AAAA,EAClE;AAEA,MAAI,KAAK,UAAU,UAAU;AAC5B,UAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,KAAK,OAAO,WAAW,iBAAiB;AAAA,MACpF,aAAa;AAAA,IACd,CAAC;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,KAAK,KAAK,UAAU,KAAK,SAAS;AACrD;","names":["axios"]}
1
+ {"version":3,"sources":["../../../../../nodes/vendors/GoogleGemini/helpers/utils.ts"],"sourcesContent":["import axios from 'axios';\nimport type { IDataObject, IExecuteFunctions } from 'n8n-workflow';\nimport { NodeOperationError } from 'n8n-workflow';\nimport { Readable } from 'node:stream';\nimport type Stream from 'node:stream';\n\nimport type { FileSearchOperation } from './interfaces';\nimport { apiRequest } from '../transport';\n\nconst OPERATION_CHECK_INTERVAL = 1000;\n\ninterface File {\n\tname: string;\n\turi: string;\n\tmimeType: string;\n\tstate: string;\n\terror?: { message: string };\n}\n\ninterface FileStreamData {\n\tstream: Stream;\n\tmimeType: string;\n}\n\ninterface FileBufferData {\n\tbuffer: Buffer;\n\tmimeType: string;\n}\n\ninterface UploadStreamConfig {\n\tendpoint: string;\n\tmimeType: string;\n\tbody?: IDataObject;\n}\n\nconst CHUNK_SIZE = 256 * 1024;\n\nexport async function downloadFile(\n\tthis: IExecuteFunctions,\n\turl: string,\n\tfallbackMimeType?: string,\n\tqs?: IDataObject,\n) {\n\tconst downloadResponse = (await this.helpers.httpRequest({\n\t\tmethod: 'GET',\n\t\turl,\n\t\tqs,\n\t\treturnFullResponse: true,\n\t\tencoding: 'arraybuffer',\n\t})) as { body: ArrayBuffer; headers: IDataObject };\n\n\tconst mimeType =\n\t\t(downloadResponse.headers?.['content-type'] as string)?.split(';')?.[0] ?? fallbackMimeType;\n\tconst fileContent = Buffer.from(downloadResponse.body);\n\treturn {\n\t\tfileContent,\n\t\tmimeType,\n\t};\n}\n\nexport async function uploadFile(this: IExecuteFunctions, fileContent: Buffer, mimeType: string) {\n\tconst numBytes = fileContent.length.toString();\n\tconst uploadInitResponse = (await apiRequest.call(this, 'POST', '/upload/v1beta/files', {\n\t\theaders: {\n\t\t\t'X-Goog-Upload-Protocol': 'resumable',\n\t\t\t'X-Goog-Upload-Command': 'start',\n\t\t\t'X-Goog-Upload-Header-Content-Length': numBytes,\n\t\t\t'X-Goog-Upload-Header-Content-Type': mimeType,\n\t\t\t'Content-Type': 'application/json',\n\t\t},\n\t\toption: {\n\t\t\treturnFullResponse: true,\n\t\t},\n\t})) as { headers: IDataObject };\n\tconst uploadUrl = uploadInitResponse.headers['x-goog-upload-url'] as string;\n\n\tconst uploadResponse = (await this.helpers.httpRequest({\n\t\tmethod: 'POST',\n\t\turl: uploadUrl,\n\t\theaders: {\n\t\t\t'Content-Length': numBytes,\n\t\t\t'X-Goog-Upload-Offset': '0',\n\t\t\t'X-Goog-Upload-Command': 'upload, finalize',\n\t\t},\n\t\tbody: fileContent,\n\t})) as { file: File };\n\n\twhile (uploadResponse.file.state !== 'ACTIVE' && uploadResponse.file.state !== 'FAILED') {\n\t\tawait new Promise((resolve) => setTimeout(resolve, OPERATION_CHECK_INTERVAL));\n\t\tuploadResponse.file = (await apiRequest.call(\n\t\t\tthis,\n\t\t\t'GET',\n\t\t\t`/v1beta/${uploadResponse.file.name}`,\n\t\t)) as File;\n\t}\n\n\tif (uploadResponse.file.state === 'FAILED') {\n\t\tthrow new NodeOperationError(\n\t\t\tthis.getNode(),\n\t\t\tuploadResponse.file.error?.message ?? 'Unknown error',\n\t\t\t{\n\t\t\t\tdescription: 'Error uploading file',\n\t\t\t},\n\t\t);\n\t}\n\n\treturn { fileUri: uploadResponse.file.uri, mimeType: uploadResponse.file.mimeType };\n}\n\nasync function getFileStreamFromUrlOrBinary(\n\tthis: IExecuteFunctions,\n\ti: number,\n\tdownloadUrl?: string,\n\tfallbackMimeType?: string,\n\tqs?: IDataObject,\n): Promise<FileStreamData | FileBufferData> {\n\tif (downloadUrl) {\n\t\tconst downloadResponse = await axios.get(downloadUrl, {\n\t\t\tparams: qs,\n\t\t\tresponseType: 'stream',\n\t\t});\n\n\t\tconst contentType = downloadResponse.headers['content-type'] as string | undefined;\n\t\tconst mimeType = contentType?.split(';')?.[0] ?? fallbackMimeType ?? 'application/octet-stream';\n\n\t\treturn {\n\t\t\tstream: downloadResponse.data as Stream,\n\t\t\tmimeType,\n\t\t};\n\t}\n\n\tconst binaryPropertyName = this.getNodeParameter('binaryPropertyName', i, 'data');\n\tif (!binaryPropertyName) {\n\t\tthrow new NodeOperationError(\n\t\t\tthis.getNode(),\n\t\t\t'Binary property name or download URL is required',\n\t\t\t{\n\t\t\t\tdescription: 'Error uploading file',\n\t\t\t},\n\t\t);\n\t}\n\n\tconst binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);\n\tif (!binaryData.id) {\n\t\tconst buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);\n\t\treturn {\n\t\t\tbuffer,\n\t\t\tmimeType: binaryData.mimeType,\n\t\t};\n\t}\n\n\treturn {\n\t\tstream: await this.helpers.getBinaryStream(binaryData.id, CHUNK_SIZE),\n\t\tmimeType: binaryData.mimeType,\n\t};\n}\n\nasync function uploadStream(\n\tthis: IExecuteFunctions,\n\tstream: Stream,\n\tconfig: UploadStreamConfig,\n): Promise<{ body: IDataObject }> {\n\tconst { endpoint, mimeType, body } = config;\n\n\tconst uploadInitResponse = (await apiRequest.call(this, 'POST', endpoint, {\n\t\theaders: {\n\t\t\t'X-Goog-Upload-Protocol': 'resumable',\n\t\t\t'X-Goog-Upload-Command': 'start',\n\t\t\t'X-Goog-Upload-Header-Content-Type': mimeType,\n\t\t\t'Content-Type': 'application/json',\n\t\t},\n\t\tbody,\n\t\toption: { returnFullResponse: true },\n\t})) as { headers: IDataObject };\n\n\tconst uploadUrl = uploadInitResponse.headers['x-goog-upload-url'] as string;\n\tif (!uploadUrl) {\n\t\tthrow new NodeOperationError(this.getNode(), 'Failed to get upload URL');\n\t}\n\n\treturn (await this.helpers.httpRequest({\n\t\tmethod: 'POST',\n\t\turl: uploadUrl,\n\t\theaders: {\n\t\t\t'X-Goog-Upload-Offset': '0',\n\t\t\t'X-Goog-Upload-Command': 'upload, finalize',\n\t\t\t'Content-Type': mimeType,\n\t\t},\n\t\tbody: stream,\n\t\treturnFullResponse: true,\n\t})) as { body: IDataObject };\n}\n\nexport async function transferFile(\n\tthis: IExecuteFunctions,\n\ti: number,\n\tdownloadUrl?: string,\n\tfallbackMimeType?: string,\n\tqs?: IDataObject,\n) {\n\tconst fileData = await getFileStreamFromUrlOrBinary.call(\n\t\tthis,\n\t\ti,\n\t\tdownloadUrl,\n\t\tfallbackMimeType,\n\t\tqs,\n\t);\n\n\tif ('buffer' in fileData) {\n\t\treturn await uploadFile.call(this, fileData.buffer, fileData.mimeType);\n\t}\n\n\tconst { stream, mimeType } = fileData;\n\tconst uploadResponse = (await uploadStream.call(this, stream, {\n\t\tendpoint: '/upload/v1beta/files',\n\t\tmimeType,\n\t})) as { body: { file: File } };\n\n\tlet file = uploadResponse.body.file;\n\n\twhile (file.state !== 'ACTIVE' && file.state !== 'FAILED') {\n\t\tawait new Promise((resolve) => setTimeout(resolve, OPERATION_CHECK_INTERVAL));\n\t\tfile = (await apiRequest.call(this, 'GET', `/v1beta/${file.name}`)) as File;\n\t}\n\n\tif (file.state === 'FAILED') {\n\t\tthrow new NodeOperationError(this.getNode(), file.error?.message ?? 'Unknown error', {\n\t\t\tdescription: 'Error uploading file',\n\t\t});\n\t}\n\n\treturn { fileUri: file.uri, mimeType: file.mimeType };\n}\n\nexport async function createFileSearchStore(this: IExecuteFunctions, displayName: string) {\n\treturn (await apiRequest.call(this, 'POST', '/v1beta/fileSearchStores', {\n\t\tbody: { displayName },\n\t})) as IDataObject;\n}\n\nexport async function uploadToFileSearchStore(\n\tthis: IExecuteFunctions,\n\ti: number,\n\tfileSearchStoreName: string,\n\tdisplayName: string,\n\tdownloadUrl?: string,\n\tfallbackMimeType?: string,\n\tqs?: IDataObject,\n) {\n\tconst fileData = await getFileStreamFromUrlOrBinary.call(\n\t\tthis,\n\t\ti,\n\t\tdownloadUrl,\n\t\tfallbackMimeType,\n\t\tqs,\n\t);\n\n\tlet stream: Stream;\n\tlet mimeType: string;\n\n\tif ('buffer' in fileData) {\n\t\tstream = Readable.from(fileData.buffer);\n\t\tmimeType = fileData.mimeType;\n\t} else {\n\t\tstream = fileData.stream;\n\t\tmimeType = fileData.mimeType;\n\t}\n\n\tconst uploadResponse = (await uploadStream.call(this, stream, {\n\t\tendpoint: `/upload/v1beta/${fileSearchStoreName}:uploadToFileSearchStore`,\n\t\tmimeType,\n\t\tbody: { displayName, mimeType },\n\t})) as { body: { name: string } };\n\n\tconst operationName = uploadResponse.body.name;\n\tlet operation = (await apiRequest.call(\n\t\tthis,\n\t\t'GET',\n\t\t`/v1beta/${operationName}`,\n\t)) as FileSearchOperation;\n\n\twhile (!operation.done) {\n\t\tawait new Promise((resolve) => setTimeout(resolve, OPERATION_CHECK_INTERVAL));\n\t\toperation = (await apiRequest.call(\n\t\t\tthis,\n\t\t\t'GET',\n\t\t\t`/v1beta/${operationName}`,\n\t\t)) as FileSearchOperation;\n\t}\n\n\tif (operation.error) {\n\t\tthrow new NodeOperationError(this.getNode(), operation.error.message ?? 'Unknown error', {\n\t\t\tdescription: 'Error uploading file to File Search store',\n\t\t});\n\t}\n\n\treturn operation.response;\n}\n\nexport async function listFileSearchStores(\n\tthis: IExecuteFunctions,\n\tpageSize?: number,\n\tpageToken?: string,\n) {\n\tconst qs: IDataObject = {};\n\tif (pageSize !== undefined) {\n\t\tqs.pageSize = pageSize;\n\t}\n\tif (pageToken) {\n\t\tqs.pageToken = pageToken;\n\t}\n\n\treturn (await apiRequest.call(this, 'GET', '/v1beta/fileSearchStores', { qs })) as IDataObject;\n}\n\nexport async function deleteFileSearchStore(\n\tthis: IExecuteFunctions,\n\tname: string,\n\tforce?: boolean,\n) {\n\tconst qs: IDataObject = {};\n\tif (force !== undefined) {\n\t\tqs.force = force;\n\t}\n\n\treturn (await apiRequest.call(this, 'DELETE', `/v1beta/${name}`, { qs })) as IDataObject;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,0BAAmC;AACnC,yBAAyB;AAIzB,uBAA2B;AAE3B,MAAM,2BAA2B;AA0BjC,MAAM,aAAa,MAAM;AAEzB,eAAsB,aAErB,KACA,kBACA,IACC;AACD,QAAM,mBAAoB,MAAM,KAAK,QAAQ,YAA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,4BAAW,KAAK,MAAM,OAAO,4BAA4B,EAAE,GAAG,CAAC;AAC9E;AAEA,eAAsB,sBAErB,MACA,OACC;AACD,QAAM,KAAkB,CAAC;AACzB,MAAI,UAAU,QAAW;AACxB,OAAG,QAAQ;AAAA,EACZ;AAEA,SAAQ,MAAM,4BAAW,KAAK,MAAM,UAAU,WAAW,IAAI,IAAI,EAAE,GAAG,CAAC;AACxE;","names":["axios"]}
@@ -46,7 +46,7 @@ var import_httpProxyAgent = require("../../../../../../utils/httpProxyAgent");
46
46
  const properties = [
47
47
  import_descriptions2.assistantRLC,
48
48
  {
49
- ...import_descriptions.promptTypeOptions,
49
+ ...import_descriptions.promptTypeOptionsDeprecated,
50
50
  name: "prompt"
51
51
  },
52
52
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/actions/assistant/message.operation.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport { AgentExecutor } from '@langchain/classic/agents';\nimport type { OpenAIToolType } from '@langchain/classic/dist/experimental/openai_assistant/schema';\nimport { OpenAIAssistantRunnable } from '@langchain/classic/experimental/openai_assistant';\nimport type { BufferWindowMemory } from '@langchain/classic/memory';\nimport omit from 'lodash/omit';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeProperties,\n} from 'n8n-workflow';\nimport {\n\tApplicationError,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\tupdateDisplayOptions,\n} from 'n8n-workflow';\nimport { OpenAI as OpenAIClient } from 'openai';\n\nimport { promptTypeOptions } from '@utils/descriptions';\nimport { getConnectedTools, getPromptInputByType } from '@utils/helpers';\nimport { getTracingConfig } from '@utils/tracing';\n\nimport { formatToOpenAIAssistantTool, getChatMessages } from '../../../helpers/utils';\nimport { assistantRLC } from '../descriptions';\nimport { getProxyAgent } from '@utils/httpProxyAgent';\n\nconst properties: INodeProperties[] = [\n\tassistantRLC,\n\t{\n\t\t...promptTypeOptions,\n\t\tname: 'prompt',\n\t},\n\t{\n\t\tdisplayName: 'Prompt (User Message)',\n\t\tname: 'text',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: 'e.g. Hello, how can you help me?',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tprompt: ['define'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Memory',\n\t\tname: 'memory',\n\t\ttype: 'options',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Use memory connector',\n\t\t\t\tvalue: 'connector',\n\t\t\t\tdescription: 'Connect one of the supported memory nodes',\n\t\t\t},\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\tname: 'Use thread ID',\n\t\t\t\tvalue: 'threadId',\n\t\t\t\tdescription: 'Specify the ID of the thread to continue',\n\t\t\t},\n\t\t],\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t},\n\t\t},\n\t\tdefault: 'connector',\n\t},\n\t{\n\t\tdisplayName: 'Thread ID',\n\t\tname: 'threadId',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: '',\n\t\tdescription: 'The ID of the thread to continue, a new thread will be created if not specified',\n\t\thint: 'If the thread ID is empty or undefined a new thread will be created and included in the response',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t\tmemory: ['threadId'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Connect your own custom n8n tools to this node on the canvas',\n\t\tname: 'noticeTools',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\tdescription: 'Additional options to add',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\tname: 'baseURL',\n\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.8 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Max Retries',\n\t\t\t\tname: 'maxRetries',\n\t\t\t\tdefault: 2,\n\t\t\t\tdescription: 'Maximum number of retries to attempt',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\tname: 'timeout',\n\t\t\t\tdefault: 10000,\n\t\t\t\tdescription: 'Maximum amount of time a request is allowed to take in milliseconds',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Preserve Original Tools',\n\t\t\t\tname: 'preserveOriginalTools',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to preserve the original tools of the assistant after the execution of this node, otherwise the tools will be replaced with the connected tools, if any, default is true',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['message'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\nconst mapChatMessageToThreadMessage = (\n\tmessage: BaseMessage,\n): OpenAIClient.Beta.Threads.ThreadCreateParams.Message => ({\n\trole: message._getType() === 'ai' ? 'assistant' : 'user',\n\tcontent: message.content.toString(),\n});\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst credentials = await this.getCredentials('openAiApi');\n\tconst nodeVersion = this.getNode().typeVersion;\n\n\tconst input = getPromptInputByType({\n\t\tctx: this,\n\t\ti,\n\t\tinputKey: 'text',\n\t\tpromptTypeKey: 'prompt',\n\t});\n\n\tconst assistantId = this.getNodeParameter('assistantId', i, '', { extractValue: true }) as string;\n\n\tconst options = this.getNodeParameter('options', i, {}) as {\n\t\tbaseURL?: string;\n\t\tmaxRetries: number;\n\t\ttimeout: number;\n\t\tpreserveOriginalTools?: boolean;\n\t};\n\n\tconst baseURL = (options.baseURL ?? credentials.url) as string;\n\n\tconst client = new OpenAIClient({\n\t\tapiKey: credentials.apiKey as string,\n\t\tmaxRetries: options.maxRetries ?? 2,\n\t\ttimeout: options.timeout ?? 10000,\n\t\tbaseURL,\n\t\tfetchOptions: {\n\t\t\tdispatcher: getProxyAgent(baseURL),\n\t\t},\n\t});\n\n\tconst agent = new OpenAIAssistantRunnable({ assistantId, client, asAgent: true });\n\n\tconst tools = await getConnectedTools(this, nodeVersion > 1, false);\n\tlet assistantTools;\n\n\tif (tools.length) {\n\t\tconst transformedConnectedTools = tools?.map(formatToOpenAIAssistantTool) ?? [];\n\t\tconst nativeToolsParsed: OpenAIToolType = [];\n\n\t\tassistantTools = (await client.beta.assistants.retrieve(assistantId)).tools;\n\n\t\tconst useCodeInterpreter = assistantTools.some((tool) => tool.type === 'code_interpreter');\n\t\tif (useCodeInterpreter) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'code_interpreter',\n\t\t\t});\n\t\t}\n\n\t\tconst useRetrieval = assistantTools.some((tool) => tool.type === 'file_search');\n\t\tif (useRetrieval) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'file_search',\n\t\t\t});\n\t\t}\n\n\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\ttools: [...nativeToolsParsed, ...transformedConnectedTools],\n\t\t});\n\t}\n\n\tconst agentExecutor = AgentExecutor.fromAgentAndTools({\n\t\tagent,\n\t\ttools: tools ?? [],\n\t});\n\n\tconst useMemoryConnector =\n\t\tnodeVersion >= 1.6 && this.getNodeParameter('memory', i) === 'connector';\n\tconst memory =\n\t\tuseMemoryConnector || nodeVersion < 1.6\n\t\t\t? ((await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t\t| BufferWindowMemory\n\t\t\t\t\t| undefined)\n\t\t\t: undefined;\n\n\tconst threadId =\n\t\tnodeVersion >= 1.6 && !useMemoryConnector\n\t\t\t? (this.getNodeParameter('threadId', i) as string)\n\t\t\t: undefined;\n\n\tconst chainValues: IDataObject = {\n\t\tcontent: input,\n\t\tsignal: this.getExecutionCancelSignal(),\n\t\ttimeout: options.timeout ?? 10000,\n\t};\n\tlet thread: OpenAIClient.Beta.Threads.Thread;\n\tif (memory) {\n\t\tconst chatMessages = await getChatMessages(memory);\n\n\t\t// Construct a new thread from the chat history to map the memory\n\t\tif (chatMessages.length) {\n\t\t\tconst first32Messages = chatMessages.slice(0, 32);\n\t\t\t// There is a undocumented limit of 32 messages per thread when creating a thread with messages\n\t\t\tconst mappedMessages: OpenAIClient.Beta.Threads.ThreadCreateParams.Message[] =\n\t\t\t\tfirst32Messages.map(mapChatMessageToThreadMessage);\n\n\t\t\tthread = await client.beta.threads.create({ messages: mappedMessages });\n\t\t\tconst overLimitMessages = chatMessages.slice(32).map(mapChatMessageToThreadMessage);\n\n\t\t\t// Send the remaining messages that exceed the limit of 32 sequentially\n\t\t\tfor (const message of overLimitMessages) {\n\t\t\t\tawait client.beta.threads.messages.create(thread.id, message);\n\t\t\t}\n\n\t\t\tchainValues.threadId = thread.id;\n\t\t}\n\t} else if (threadId) {\n\t\tchainValues.threadId = threadId;\n\t}\n\n\tlet filteredResponse: IDataObject = {};\n\ttry {\n\t\tconst response = await agentExecutor.withConfig(getTracingConfig(this)).invoke(chainValues);\n\t\tif (memory) {\n\t\t\tawait memory.saveContext({ input }, { output: response.output });\n\n\t\t\tif (response.threadId && response.runId) {\n\t\t\t\tconst threadRun = await client.beta.threads.runs.retrieve(response.runId, {\n\t\t\t\t\tthread_id: response.threadId,\n\t\t\t\t});\n\t\t\t\tresponse.usage = threadRun.usage;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\toptions.preserveOriginalTools !== false &&\n\t\t\tnodeVersion >= 1.3 &&\n\t\t\t(assistantTools ?? [])?.length\n\t\t) {\n\t\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\t\ttools: assistantTools,\n\t\t\t});\n\t\t}\n\t\t// Remove configuration properties and runId added by Langchain that are not relevant to the user\n\t\tfilteredResponse = omit(response, ['signal', 'timeout', 'content', 'runId']) as IDataObject;\n\t} catch (error) {\n\t\tif (!(error instanceof ApplicationError)) {\n\t\t\tthrow new NodeOperationError(this.getNode(), error.message, { itemIndex: i });\n\t\t}\n\t}\n\n\treturn [{ json: filteredResponse, pairedItem: { item: i } }];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAE9B,8BAAwC;AAExC,kBAAiB;AAOjB,0BAKO;AACP,oBAAuC;AAEvC,0BAAkC;AAClC,qBAAwD;AACxD,qBAAiC;AAEjC,mBAA6D;AAC7D,IAAAA,uBAA6B;AAC7B,4BAA8B;AAE9B,MAAM,aAAgC;AAAA,EACrC;AAAA,EACA;AAAA,IACC,GAAG;AAAA,IACH,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,QAAQ,CAAC,QAAQ;AAAA,MAClB;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAA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B,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;AAC5D;","names":["import_descriptions","OpenAIClient","omit"]}
1
+ {"version":3,"sources":["../../../../../../../nodes/vendors/OpenAi/v1/actions/assistant/message.operation.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport { AgentExecutor } from '@langchain/classic/agents';\nimport type { OpenAIToolType } from '@langchain/classic/dist/experimental/openai_assistant/schema';\nimport { OpenAIAssistantRunnable } from '@langchain/classic/experimental/openai_assistant';\nimport type { BufferWindowMemory } from '@langchain/classic/memory';\nimport omit from 'lodash/omit';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeProperties,\n} from 'n8n-workflow';\nimport {\n\tApplicationError,\n\tNodeConnectionTypes,\n\tNodeOperationError,\n\tupdateDisplayOptions,\n} from 'n8n-workflow';\nimport { OpenAI as OpenAIClient } from 'openai';\n\nimport { promptTypeOptionsDeprecated } from '@utils/descriptions';\nimport { getConnectedTools, getPromptInputByType } from '@utils/helpers';\nimport { getTracingConfig } from '@utils/tracing';\n\nimport { formatToOpenAIAssistantTool, getChatMessages } from '../../../helpers/utils';\nimport { assistantRLC } from '../descriptions';\nimport { getProxyAgent } from '@utils/httpProxyAgent';\n\nconst properties: INodeProperties[] = [\n\tassistantRLC,\n\t{\n\t\t...promptTypeOptionsDeprecated,\n\t\tname: 'prompt',\n\t},\n\t{\n\t\tdisplayName: 'Prompt (User Message)',\n\t\tname: 'text',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: 'e.g. Hello, how can you help me?',\n\t\ttypeOptions: {\n\t\t\trows: 2,\n\t\t},\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tprompt: ['define'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Memory',\n\t\tname: 'memory',\n\t\ttype: 'options',\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Use memory connector',\n\t\t\t\tvalue: 'connector',\n\t\t\t\tdescription: 'Connect one of the supported memory nodes',\n\t\t\t},\n\t\t\t{\n\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\tname: 'Use thread ID',\n\t\t\t\tvalue: 'threadId',\n\t\t\t\tdescription: 'Specify the ID of the thread to continue',\n\t\t\t},\n\t\t],\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t},\n\t\t},\n\t\tdefault: 'connector',\n\t},\n\t{\n\t\tdisplayName: 'Thread ID',\n\t\tname: 'threadId',\n\t\ttype: 'string',\n\t\tdefault: '',\n\t\tplaceholder: '',\n\t\tdescription: 'The ID of the thread to continue, a new thread will be created if not specified',\n\t\thint: 'If the thread ID is empty or undefined a new thread will be created and included in the response',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'@version': [{ _cnd: { gte: 1.6 } }],\n\t\t\t\tmemory: ['threadId'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Connect your own custom n8n tools to this node on the canvas',\n\t\tname: 'noticeTools',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\tdescription: 'Additional options to add',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\tname: 'baseURL',\n\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\ttype: 'string',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.8 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Max Retries',\n\t\t\t\tname: 'maxRetries',\n\t\t\t\tdefault: 2,\n\t\t\t\tdescription: 'Maximum number of retries to attempt',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\tname: 'timeout',\n\t\t\t\tdefault: 10000,\n\t\t\t\tdescription: 'Maximum amount of time a request is allowed to take in milliseconds',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Preserve Original Tools',\n\t\t\t\tname: 'preserveOriginalTools',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdefault: true,\n\t\t\t\tdescription:\n\t\t\t\t\t'Whether to preserve the original tools of the assistant after the execution of this node, otherwise the tools will be replaced with the connected tools, if any, default is true',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.3 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['message'],\n\t\tresource: ['assistant'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\nconst mapChatMessageToThreadMessage = (\n\tmessage: BaseMessage,\n): OpenAIClient.Beta.Threads.ThreadCreateParams.Message => ({\n\trole: message._getType() === 'ai' ? 'assistant' : 'user',\n\tcontent: message.content.toString(),\n});\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst credentials = await this.getCredentials('openAiApi');\n\tconst nodeVersion = this.getNode().typeVersion;\n\n\tconst input = getPromptInputByType({\n\t\tctx: this,\n\t\ti,\n\t\tinputKey: 'text',\n\t\tpromptTypeKey: 'prompt',\n\t});\n\n\tconst assistantId = this.getNodeParameter('assistantId', i, '', { extractValue: true }) as string;\n\n\tconst options = this.getNodeParameter('options', i, {}) as {\n\t\tbaseURL?: string;\n\t\tmaxRetries: number;\n\t\ttimeout: number;\n\t\tpreserveOriginalTools?: boolean;\n\t};\n\n\tconst baseURL = (options.baseURL ?? credentials.url) as string;\n\n\tconst client = new OpenAIClient({\n\t\tapiKey: credentials.apiKey as string,\n\t\tmaxRetries: options.maxRetries ?? 2,\n\t\ttimeout: options.timeout ?? 10000,\n\t\tbaseURL,\n\t\tfetchOptions: {\n\t\t\tdispatcher: getProxyAgent(baseURL),\n\t\t},\n\t});\n\n\tconst agent = new OpenAIAssistantRunnable({ assistantId, client, asAgent: true });\n\n\tconst tools = await getConnectedTools(this, nodeVersion > 1, false);\n\tlet assistantTools;\n\n\tif (tools.length) {\n\t\tconst transformedConnectedTools = tools?.map(formatToOpenAIAssistantTool) ?? [];\n\t\tconst nativeToolsParsed: OpenAIToolType = [];\n\n\t\tassistantTools = (await client.beta.assistants.retrieve(assistantId)).tools;\n\n\t\tconst useCodeInterpreter = assistantTools.some((tool) => tool.type === 'code_interpreter');\n\t\tif (useCodeInterpreter) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'code_interpreter',\n\t\t\t});\n\t\t}\n\n\t\tconst useRetrieval = assistantTools.some((tool) => tool.type === 'file_search');\n\t\tif (useRetrieval) {\n\t\t\tnativeToolsParsed.push({\n\t\t\t\ttype: 'file_search',\n\t\t\t});\n\t\t}\n\n\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\ttools: [...nativeToolsParsed, ...transformedConnectedTools],\n\t\t});\n\t}\n\n\tconst agentExecutor = AgentExecutor.fromAgentAndTools({\n\t\tagent,\n\t\ttools: tools ?? [],\n\t});\n\n\tconst useMemoryConnector =\n\t\tnodeVersion >= 1.6 && this.getNodeParameter('memory', i) === 'connector';\n\tconst memory =\n\t\tuseMemoryConnector || nodeVersion < 1.6\n\t\t\t? ((await this.getInputConnectionData(NodeConnectionTypes.AiMemory, 0)) as\n\t\t\t\t\t| BufferWindowMemory\n\t\t\t\t\t| undefined)\n\t\t\t: undefined;\n\n\tconst threadId =\n\t\tnodeVersion >= 1.6 && !useMemoryConnector\n\t\t\t? (this.getNodeParameter('threadId', i) as string)\n\t\t\t: undefined;\n\n\tconst chainValues: IDataObject = {\n\t\tcontent: input,\n\t\tsignal: this.getExecutionCancelSignal(),\n\t\ttimeout: options.timeout ?? 10000,\n\t};\n\tlet thread: OpenAIClient.Beta.Threads.Thread;\n\tif (memory) {\n\t\tconst chatMessages = await getChatMessages(memory);\n\n\t\t// Construct a new thread from the chat history to map the memory\n\t\tif (chatMessages.length) {\n\t\t\tconst first32Messages = chatMessages.slice(0, 32);\n\t\t\t// There is a undocumented limit of 32 messages per thread when creating a thread with messages\n\t\t\tconst mappedMessages: OpenAIClient.Beta.Threads.ThreadCreateParams.Message[] =\n\t\t\t\tfirst32Messages.map(mapChatMessageToThreadMessage);\n\n\t\t\tthread = await client.beta.threads.create({ messages: mappedMessages });\n\t\t\tconst overLimitMessages = chatMessages.slice(32).map(mapChatMessageToThreadMessage);\n\n\t\t\t// Send the remaining messages that exceed the limit of 32 sequentially\n\t\t\tfor (const message of overLimitMessages) {\n\t\t\t\tawait client.beta.threads.messages.create(thread.id, message);\n\t\t\t}\n\n\t\t\tchainValues.threadId = thread.id;\n\t\t}\n\t} else if (threadId) {\n\t\tchainValues.threadId = threadId;\n\t}\n\n\tlet filteredResponse: IDataObject = {};\n\ttry {\n\t\tconst response = await agentExecutor.withConfig(getTracingConfig(this)).invoke(chainValues);\n\t\tif (memory) {\n\t\t\tawait memory.saveContext({ input }, { output: response.output });\n\n\t\t\tif (response.threadId && response.runId) {\n\t\t\t\tconst threadRun = await client.beta.threads.runs.retrieve(response.runId, {\n\t\t\t\t\tthread_id: response.threadId,\n\t\t\t\t});\n\t\t\t\tresponse.usage = threadRun.usage;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\toptions.preserveOriginalTools !== false &&\n\t\t\tnodeVersion >= 1.3 &&\n\t\t\t(assistantTools ?? [])?.length\n\t\t) {\n\t\t\tawait client.beta.assistants.update(assistantId, {\n\t\t\t\ttools: assistantTools,\n\t\t\t});\n\t\t}\n\t\t// Remove configuration properties and runId added by Langchain that are not relevant to the user\n\t\tfilteredResponse = omit(response, ['signal', 'timeout', 'content', 'runId']) as IDataObject;\n\t} catch (error) {\n\t\tif (!(error instanceof ApplicationError)) {\n\t\t\tthrow new NodeOperationError(this.getNode(), error.message, { itemIndex: i });\n\t\t}\n\t}\n\n\treturn [{ json: filteredResponse, pairedItem: { item: i } }];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAE9B,8BAAwC;AAExC,kBAAiB;AAOjB,0BAKO;AACP,oBAAuC;AAEvC,0BAA4C;AAC5C,qBAAwD;AACxD,qBAAiC;AAEjC,mBAA6D;AAC7D,IAAAA,uBAA6B;AAC7B,4BAA8B;AAE9B,MAAM,aAAgC;AAAA,EACrC;AAAA,EACA;AAAA,IACC,GAAG;AAAA,IACH,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,MACZ,MAAM;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,QAAQ,CAAC,QAAQ;AAAA,MAClB;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,aAAa;AAAA,MACd;AAAA,MACA;AAAA;AAAA,QAEC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;AAAA,MACpC;AAAA,IACD;AAAA,IACA,SAAS;AAAA,EACV;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;A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W;AAAA,EACxB;AAEA,MAAI,mBAAgC,CAAC;AACrC,MAAI;AACH,UAAM,WAAW,MAAM,cAAc,eAAW,iCAAiB,IAAI,CAAC,EAAE,OAAO,WAAW;AAC1F,QAAI,QAAQ;AACX,YAAM,OAAO,YAAY,EAAE,MAAM,GAAG,EAAE,QAAQ,SAAS,OAAO,CAAC;AAE/D,UAAI,SAAS,YAAY,SAAS,OAAO;AACxC,cAAM,YAAY,MAAM,OAAO,KAAK,QAAQ,KAAK,SAAS,SAAS,OAAO;AAAA,UACzE,WAAW,SAAS;AAAA,QACrB,CAAC;AACD,iBAAS,QAAQ,UAAU;AAAA,MAC5B;AAAA,IACD;AAEA,QACC,QAAQ,0BAA0B,SAClC,eAAe,QACd,kBAAkB,CAAC,IAAI,QACvB;AACD,YAAM,OAAO,KAAK,WAAW,OAAO,aAAa;AAAA,QAChD,OAAO;AAAA,MACR,CAAC;AAAA,IACF;AAEA,2BAAmB,YAAAC,SAAK,UAAU,CAAC,UAAU,WAAW,WAAW,OAAO,CAAC;AAAA,EAC5E,SAAS,OAAO;AACf,QAAI,EAAE,iBAAiB,uCAAmB;AACzC,YAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,MAAM,SAAS,EAAE,WAAW,EAAE,CAAC;AAAA,IAC7E;AAAA,EACD;AAEA,SAAO,CAAC,EAAE,MAAM,kBAAkB,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;AAC5D;","names":["import_descriptions","OpenAIClient","omit"]}
@@ -8,7 +8,7 @@
8
8
  {"name":"googlePalmApi","displayName":"Google Gemini(PaLM) Api","documentationUrl":"google","properties":[{"displayName":"Host","name":"host","required":true,"type":"string","default":"https://generativelanguage.googleapis.com"},{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"qs":{"key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{$credentials.host}}/v1beta/models"}},"supportedNodes":["googleGemini","embeddingsGoogleGemini","lmChatGoogleGemini"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vendors/GoogleGemini/gemini.svg"},
9
9
  {"name":"groqApi","displayName":"Groq","documentationUrl":"groq","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://api.groq.com/openai/v1","url":"/models"}},"supportedNodes":["lmChatGroq"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatGroq/groq.svg"},
10
10
  {"name":"huggingFaceApi","displayName":"HuggingFaceApi","documentationUrl":"huggingface","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://huggingface.co","url":"/api/whoami-v2"}},"supportedNodes":["embeddingsHuggingFaceInference","lmOpenHuggingFaceInference"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsHuggingFaceInference/huggingface.svg"},
11
- {"name":"mcpOAuth2Api","extends":["oAuth2Api"],"displayName":"MCP OAuth2 API","documentationUrl":"mcp","properties":[{"displayName":"Use Dynamic Client Registration","name":"useDynamicClientRegistration","type":"boolean","default":true,"required":true}],"supportedNodes":["mcpClient","mcpClientTool"],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/mcp/mcp.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/mcp/mcp.dark.svg"}},
11
+ {"name":"mcpOAuth2Api","extends":["oAuth2Api"],"displayName":"MCP OAuth2 API","documentationUrl":"mcp","properties":[{"displayName":"Use Dynamic Client Registration","name":"useDynamicClientRegistration","type":"boolean","default":true}],"supportedNodes":["mcpClient","mcpClientTool"],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/mcp/mcp.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/mcp/mcp.dark.svg"}},
12
12
  {"name":"motorheadApi","displayName":"MotorheadApi","documentationUrl":"motorhead","properties":[{"displayName":"Host","name":"host","required":true,"type":"string","default":"https://api.getmetal.io/v1"},{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Client ID","name":"clientId","type":"string","default":""}],"authenticate":{"type":"generic","properties":{"headers":{"x-metal-client-id":"={{$credentials.clientId}}","x-metal-api-key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{$credentials.host}}/keys/current"}},"supportedNodes":["memoryMotorhead"],"icon":"fa:file-export","iconColor":"black"},
13
13
  {"name":"milvusApi","displayName":"Milvus","documentationUrl":"milvus","properties":[{"displayName":"Base URL","name":"baseUrl","required":true,"type":"string","default":"http://localhost:19530"},{"displayName":"Username","name":"username","type":"string","default":""},{"displayName":"Password","name":"password","type":"string","typeOptions":{"password":true},"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.username}}:{{$credentials.password}}"}}},"test":{"request":{"baseURL":"={{ $credentials.baseUrl }}","url":"/v1/vector/collections","method":"GET"}},"supportedNodes":["vectorStoreMilvus"],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMilvus/milvus-icon-black.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/vector_store/VectorStoreMilvus/milvus-icon-white.svg"}},
14
14
  {"name":"mistralCloudApi","displayName":"Mistral Cloud API","documentationUrl":"mistral","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://api.mistral.ai/v1","url":"/models","method":"GET"}},"supportedNodes":["embeddingsMistralCloud","lmChatMistralCloud"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsMistralCloud/mistral.svg"},