@n8n/n8n-nodes-langchain 2.4.3 → 2.5.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.
- package/dist/credentials/ChromaCloudApi.credentials.js +82 -0
- package/dist/credentials/ChromaCloudApi.credentials.js.map +1 -0
- package/dist/credentials/ChromaSelfHostedApi.credentials.js +105 -0
- package/dist/credentials/ChromaSelfHostedApi.credentials.js.map +1 -0
- package/dist/known/credentials.json +14 -0
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js +3 -2
- package/dist/nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.js.map +1 -1
- package/dist/nodes/code/Code.node.js +1 -1
- package/dist/nodes/code/Code.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js +2 -1
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js +3 -5
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
- package/dist/nodes/llms/LMChatLemonade/LmChatLemonade.node.js +4 -0
- package/dist/nodes/llms/LMChatLemonade/LmChatLemonade.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js +4 -1
- package/dist/nodes/llms/LMChatOllama/LmChatOllama.node.js.map +1 -1
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js +15 -10
- package/dist/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js +6 -2
- package/dist/nodes/llms/LMOpenAi/LmOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +6 -2
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js +6 -2
- package/dist/nodes/llms/LmChatDeepSeek/LmChatDeepSeek.node.js.map +1 -1
- package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js +5 -0
- package/dist/nodes/llms/LmChatMistralCloud/LmChatMistralCloud.node.js.map +1 -1
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js +6 -2
- package/dist/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.js.map +1 -1
- package/dist/nodes/llms/LmChatVercelAiGateway/LmChatVercelAiGateway.node.js +6 -2
- package/dist/nodes/llms/LmChatVercelAiGateway/LmChatVercelAiGateway.node.js.map +1 -1
- package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js +6 -2
- package/dist/nodes/llms/LmChatXAiGrok/LmChatXAiGrok.node.js.map +1 -1
- package/dist/nodes/mcp/shared/utils.js +4 -2
- package/dist/nodes/mcp/shared/utils.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/Chat.node.js +118 -108
- package/dist/nodes/trigger/ChatTrigger/Chat.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js +22 -13
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/constants.js +28 -18
- package/dist/nodes/trigger/ChatTrigger/constants.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/util.js +75 -4
- package/dist/nodes/trigger/ChatTrigger/util.js.map +1 -1
- package/dist/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.js +356 -0
- package/dist/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.js.map +1 -0
- package/dist/nodes/vector_store/VectorStoreChromaDB/chroma.svg +9 -0
- package/dist/nodes/vector_store/shared/descriptions.js +24 -0
- package/dist/nodes/vector_store/shared/descriptions.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js +6 -2
- package/dist/nodes/vendors/OpenAi/v1/actions/assistant/message.operation.js.map +1 -1
- package/dist/types/credentials.json +2 -0
- package/dist/types/nodes.json +4 -3
- package/dist/utils/httpProxyAgent.js +15 -4
- package/dist/utils/httpProxyAgent.js.map +1 -1
- package/dist/utils/tracing.js +1 -1
- package/dist/utils/tracing.js.map +1 -1
- package/package.json +14 -10
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ChromaCloudApi_credentials_exports = {};
|
|
20
|
+
__export(ChromaCloudApi_credentials_exports, {
|
|
21
|
+
ChromaCloudApi: () => ChromaCloudApi
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ChromaCloudApi_credentials_exports);
|
|
24
|
+
class ChromaCloudApi {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.name = "chromaCloudApi";
|
|
27
|
+
this.displayName = "ChromaDB Cloud";
|
|
28
|
+
this.documentationUrl = "chroma";
|
|
29
|
+
this.properties = [
|
|
30
|
+
{
|
|
31
|
+
displayName: "API Key",
|
|
32
|
+
name: "apiKey",
|
|
33
|
+
type: "string",
|
|
34
|
+
typeOptions: { password: true },
|
|
35
|
+
default: "",
|
|
36
|
+
required: true,
|
|
37
|
+
description: "Your Chroma Cloud API key"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
displayName: "Tenant ID",
|
|
41
|
+
name: "tenant",
|
|
42
|
+
type: "string",
|
|
43
|
+
default: "",
|
|
44
|
+
description: "Optional: Tenant ID (auto-resolved if API key is scoped to single DB)"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
displayName: "Database Name",
|
|
48
|
+
name: "database",
|
|
49
|
+
type: "string",
|
|
50
|
+
default: "",
|
|
51
|
+
description: "Optional: Database name (auto-resolved if API key is scoped to single DB)"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
displayName: "Base URL",
|
|
55
|
+
name: "baseUrl",
|
|
56
|
+
type: "string",
|
|
57
|
+
default: "https://api.trychroma.com",
|
|
58
|
+
required: true
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
this.authenticate = {
|
|
62
|
+
type: "generic",
|
|
63
|
+
properties: {
|
|
64
|
+
headers: {
|
|
65
|
+
"x-chroma-token": "={{$credentials.apiKey}}"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
this.test = {
|
|
70
|
+
request: {
|
|
71
|
+
baseURL: "={{$credentials.baseUrl}}",
|
|
72
|
+
url: "/api/v2",
|
|
73
|
+
method: "GET"
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
ChromaCloudApi
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=ChromaCloudApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../credentials/ChromaCloudApi.credentials.ts"],"sourcesContent":["import type {\n\tIAuthenticateGeneric,\n\tICredentialTestRequest,\n\tICredentialType,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nexport class ChromaCloudApi implements ICredentialType {\n\tname = 'chromaCloudApi';\n\n\tdisplayName = 'ChromaDB Cloud';\n\n\tdocumentationUrl = 'chroma';\n\n\tproperties: INodeProperties[] = [\n\t\t{\n\t\t\tdisplayName: 'API Key',\n\t\t\tname: 'apiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\trequired: true,\n\t\t\tdescription: 'Your Chroma Cloud API key',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Tenant ID',\n\t\t\tname: 'tenant',\n\t\t\ttype: 'string',\n\t\t\tdefault: '',\n\t\t\tdescription: 'Optional: Tenant ID (auto-resolved if API key is scoped to single DB)',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Database Name',\n\t\t\tname: 'database',\n\t\t\ttype: 'string',\n\t\t\tdefault: '',\n\t\t\tdescription: 'Optional: Database name (auto-resolved if API key is scoped to single DB)',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Base URL',\n\t\t\tname: 'baseUrl',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'https://api.trychroma.com',\n\t\t\trequired: true,\n\t\t},\n\t];\n\n\tauthenticate: IAuthenticateGeneric = {\n\t\ttype: 'generic',\n\t\tproperties: {\n\t\t\theaders: {\n\t\t\t\t'x-chroma-token': '={{$credentials.apiKey}}',\n\t\t\t},\n\t\t},\n\t};\n\n\ttest: ICredentialTestRequest = {\n\t\trequest: {\n\t\t\tbaseURL: '={{$credentials.baseUrl}}',\n\t\t\turl: '/api/v2',\n\t\t\tmethod: 'GET',\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,eAA0C;AAAA,EAAhD;AACN,gBAAO;AAEP,uBAAc;AAEd,4BAAmB;AAEnB,sBAAgC;AAAA,MAC/B;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa,EAAE,UAAU,KAAK;AAAA,QAC9B,SAAS;AAAA,QACT,UAAU;AAAA,QACV,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,UAAU;AAAA,MACX;AAAA,IACD;AAEA,wBAAqC;AAAA,MACpC,MAAM;AAAA,MACN,YAAY;AAAA,QACX,SAAS;AAAA,UACR,kBAAkB;AAAA,QACnB;AAAA,MACD;AAAA,IACD;AAEA,gBAA+B;AAAA,MAC9B,SAAS;AAAA,QACR,SAAS;AAAA,QACT,KAAK;AAAA,QACL,QAAQ;AAAA,MACT;AAAA,IACD;AAAA;AACD;","names":[]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ChromaSelfHostedApi_credentials_exports = {};
|
|
20
|
+
__export(ChromaSelfHostedApi_credentials_exports, {
|
|
21
|
+
ChromaSelfHostedApi: () => ChromaSelfHostedApi
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ChromaSelfHostedApi_credentials_exports);
|
|
24
|
+
class ChromaSelfHostedApi {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.name = "chromaSelfHostedApi";
|
|
27
|
+
this.displayName = "ChromaDB Self-Hosted";
|
|
28
|
+
this.documentationUrl = "chroma";
|
|
29
|
+
this.properties = [
|
|
30
|
+
{
|
|
31
|
+
displayName: "Base URL",
|
|
32
|
+
name: "baseUrl",
|
|
33
|
+
type: "string",
|
|
34
|
+
default: "http://localhost:8000",
|
|
35
|
+
placeholder: "http://localhost:8000",
|
|
36
|
+
description: "The URL of your ChromaDB instance. Note that path prefixes are not supported, so the URL must point directly to the instance root."
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
displayName: "Authentication",
|
|
40
|
+
name: "authentication",
|
|
41
|
+
type: "options",
|
|
42
|
+
options: [
|
|
43
|
+
{
|
|
44
|
+
name: "None",
|
|
45
|
+
value: "none"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "API Key",
|
|
49
|
+
value: "apiKey"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "Token",
|
|
53
|
+
value: "token"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
default: "none"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: "API Key",
|
|
60
|
+
name: "apiKey",
|
|
61
|
+
type: "string",
|
|
62
|
+
typeOptions: { password: true },
|
|
63
|
+
default: "",
|
|
64
|
+
displayOptions: {
|
|
65
|
+
show: {
|
|
66
|
+
authentication: ["apiKey"]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
displayName: "Token",
|
|
72
|
+
name: "token",
|
|
73
|
+
type: "string",
|
|
74
|
+
typeOptions: { password: true },
|
|
75
|
+
default: "",
|
|
76
|
+
displayOptions: {
|
|
77
|
+
show: {
|
|
78
|
+
authentication: ["token"]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
this.authenticate = {
|
|
84
|
+
type: "generic",
|
|
85
|
+
properties: {
|
|
86
|
+
headers: {
|
|
87
|
+
Authorization: '={{$credentials.authentication === "apiKey" && $credentials.apiKey ? "Bearer " + $credentials.apiKey : ""}}',
|
|
88
|
+
"X-Chroma-Token": '={{$credentials.authentication === "token" && $credentials.token ? $credentials.token : ""}}'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
this.test = {
|
|
93
|
+
request: {
|
|
94
|
+
baseURL: "={{$credentials.baseUrl}}",
|
|
95
|
+
url: "/api/v2/heartbeat",
|
|
96
|
+
method: "GET"
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
ChromaSelfHostedApi
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=ChromaSelfHostedApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../credentials/ChromaSelfHostedApi.credentials.ts"],"sourcesContent":["import type {\n\tIAuthenticateGeneric,\n\tICredentialTestRequest,\n\tICredentialType,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nexport class ChromaSelfHostedApi implements ICredentialType {\n\tname = 'chromaSelfHostedApi';\n\n\tdisplayName = 'ChromaDB Self-Hosted';\n\n\tdocumentationUrl = 'chroma';\n\n\tproperties: INodeProperties[] = [\n\t\t{\n\t\t\tdisplayName: 'Base URL',\n\t\t\tname: 'baseUrl',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'http://localhost:8000',\n\t\t\tplaceholder: 'http://localhost:8000',\n\t\t\tdescription:\n\t\t\t\t'The URL of your ChromaDB instance. Note that path prefixes are not supported, so the URL must point directly to the instance root.',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Authentication',\n\t\t\tname: 'authentication',\n\t\t\ttype: 'options',\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tname: 'None',\n\t\t\t\t\tvalue: 'none',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'API Key',\n\t\t\t\t\tvalue: 'apiKey',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Token',\n\t\t\t\t\tvalue: 'token',\n\t\t\t\t},\n\t\t\t],\n\t\t\tdefault: 'none',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'API Key',\n\t\t\tname: 'apiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tauthentication: ['apiKey'],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Token',\n\t\t\tname: 'token',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tauthentication: ['token'],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t];\n\n\tauthenticate: IAuthenticateGeneric = {\n\t\ttype: 'generic',\n\t\tproperties: {\n\t\t\theaders: {\n\t\t\t\tAuthorization:\n\t\t\t\t\t'={{$credentials.authentication === \"apiKey\" && $credentials.apiKey ? \"Bearer \" + $credentials.apiKey : \"\"}}',\n\t\t\t\t'X-Chroma-Token':\n\t\t\t\t\t'={{$credentials.authentication === \"token\" && $credentials.token ? $credentials.token : \"\"}}',\n\t\t\t},\n\t\t},\n\t};\n\n\ttest: ICredentialTestRequest = {\n\t\trequest: {\n\t\t\tbaseURL: '={{$credentials.baseUrl}}',\n\t\t\turl: '/api/v2/heartbeat',\n\t\t\tmethod: 'GET',\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,oBAA+C;AAAA,EAArD;AACN,gBAAO;AAEP,uBAAc;AAEd,4BAAmB;AAEnB,sBAAgC;AAAA,MAC/B;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,QACb,aACC;AAAA,MACF;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,UACR;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,QACD;AAAA,QACA,SAAS;AAAA,MACV;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa,EAAE,UAAU,KAAK;AAAA,QAC9B,SAAS;AAAA,QACT,gBAAgB;AAAA,UACf,MAAM;AAAA,YACL,gBAAgB,CAAC,QAAQ;AAAA,UAC1B;AAAA,QACD;AAAA,MACD;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa,EAAE,UAAU,KAAK;AAAA,QAC9B,SAAS;AAAA,QACT,gBAAgB;AAAA,UACf,MAAM;AAAA,YACL,gBAAgB,CAAC,OAAO;AAAA,UACzB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,wBAAqC;AAAA,MACpC,MAAM;AAAA,MACN,YAAY;AAAA,QACX,SAAS;AAAA,UACR,eACC;AAAA,UACD,kBACC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAEA,gBAA+B;AAAA,MAC9B,SAAS;AAAA,QACR,SAAS;AAAA,QACT,KAAK;AAAA,QACL,QAAQ;AAAA,MACT;AAAA,IACD;AAAA;AACD;","names":[]}
|
|
@@ -32,6 +32,20 @@
|
|
|
32
32
|
"lmChatAzureOpenAi"
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
|
+
"chromaSelfHostedApi": {
|
|
36
|
+
"className": "ChromaSelfHostedApi",
|
|
37
|
+
"sourcePath": "dist/credentials/ChromaSelfHostedApi.credentials.js",
|
|
38
|
+
"supportedNodes": [
|
|
39
|
+
"vectorStoreChromaDB"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"chromaCloudApi": {
|
|
43
|
+
"className": "ChromaCloudApi",
|
|
44
|
+
"sourcePath": "dist/credentials/ChromaCloudApi.credentials.js",
|
|
45
|
+
"supportedNodes": [
|
|
46
|
+
"vectorStoreChromaDB"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
35
49
|
"cohereApi": {
|
|
36
50
|
"className": "CohereApi",
|
|
37
51
|
"sourcePath": "dist/credentials/CohereApi.credentials.js",
|
package/dist/known/nodes.json
CHANGED
|
@@ -411,6 +411,10 @@
|
|
|
411
411
|
"className": "VectorStoreZepLoad",
|
|
412
412
|
"sourcePath": "dist/nodes/vector_store/VectorStoreZepLoad/VectorStoreZepLoad.node.js"
|
|
413
413
|
},
|
|
414
|
+
"vectorStoreChromaDB": {
|
|
415
|
+
"className": "VectorStoreChromaDB",
|
|
416
|
+
"sourcePath": "dist/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.js"
|
|
417
|
+
},
|
|
414
418
|
"toolExecutor": {
|
|
415
419
|
"className": "ToolExecutor",
|
|
416
420
|
"sourcePath": "dist/nodes/ToolExecutor/ToolExecutor.node.js"
|
|
@@ -22,6 +22,7 @@ __export(runAgent_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(runAgent_exports);
|
|
24
24
|
var import_agent_execution = require("../../../../../../../utils/agent-execution");
|
|
25
|
+
var import_tracing = require("../../../../../../../utils/tracing");
|
|
25
26
|
var import_prompt = require("../../prompt");
|
|
26
27
|
var import_buildResponseMetadata = require("./buildResponseMetadata");
|
|
27
28
|
async function runAgent(ctx, executor, itemContext, model, memory, response) {
|
|
@@ -36,7 +37,7 @@ async function runAgent(ctx, executor, itemContext, model, memory, response) {
|
|
|
36
37
|
const isStreamingAvailable = "isStreaming" in ctx ? ctx.isStreaming?.() : void 0;
|
|
37
38
|
if ("isStreaming" in ctx && options.enableStreaming && isStreamingAvailable && ctx.getNode().typeVersion >= 2.1) {
|
|
38
39
|
const chatHistory = await (0, import_agent_execution.loadMemory)(memory, model, options.maxTokensFromMemory);
|
|
39
|
-
const eventStream = executor.streamEvents(
|
|
40
|
+
const eventStream = executor.withConfig((0, import_tracing.getTracingConfig)(ctx)).streamEvents(
|
|
40
41
|
{
|
|
41
42
|
...invokeParams,
|
|
42
43
|
chat_history: chatHistory
|
|
@@ -64,7 +65,7 @@ async function runAgent(ctx, executor, itemContext, model, memory, response) {
|
|
|
64
65
|
return result;
|
|
65
66
|
} else {
|
|
66
67
|
const chatHistory = await (0, import_agent_execution.loadMemory)(memory, model, options.maxTokensFromMemory);
|
|
67
|
-
const modelResponse = await executor.invoke({
|
|
68
|
+
const modelResponse = await executor.withConfig((0, import_tracing.getTracingConfig)(ctx)).invoke({
|
|
68
69
|
...invokeParams,
|
|
69
70
|
chat_history: chatHistory
|
|
70
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../nodes/agents/Agent/agents/ToolsAgent/V3/helpers/runAgent.ts"],"sourcesContent":["import type { AgentRunnableSequence } from '@langchain/classic/agents';\nimport type { BaseChatMemory } from '@langchain/classic/memory';\nimport type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport {\n\tloadMemory,\n\tprocessEventStream,\n\tcreateEngineRequests,\n\tsaveToMemory,\n} from '@utils/agent-execution';\nimport { getTracingConfig } from '@utils/tracing';\nimport type {\n\tIExecuteFunctions,\n\tISupplyDataFunctions,\n\tEngineResponse,\n\tEngineRequest,\n} from 'n8n-workflow';\n\nimport { SYSTEM_MESSAGE } from '../../prompt';\nimport type { AgentResult, RequestResponseMetadata } from '../types';\nimport { buildResponseMetadata } from './buildResponseMetadata';\nimport type { ItemContext } from './prepareItemContext';\n\ntype RunAgentResult = AgentResult | EngineRequest<RequestResponseMetadata>;\n/**\n * Runs the agent for a single item, choosing between streaming or non-streaming execution.\n * Handles both regular execution and execution after tool calls.\n *\n * @param ctx - The execution context\n * @param executor - The agent runnable sequence\n * @param itemContext - Context for the current item\n * @param model - The chat model for token counting\n * @param memory - Optional memory for conversation context\n * @param response - Optional engine response with previous tool calls\n * @returns AgentResult or engine request with tool calls\n */\nexport async function runAgent(\n\tctx: IExecuteFunctions | ISupplyDataFunctions,\n\texecutor: AgentRunnableSequence,\n\titemContext: ItemContext,\n\tmodel: BaseChatModel,\n\tmemory: BaseChatMemory | undefined,\n\tresponse?: EngineResponse<RequestResponseMetadata>,\n): Promise<RunAgentResult> {\n\tconst { itemIndex, input, steps, tools, options } = itemContext;\n\n\tconst invokeParams = {\n\t\tsteps,\n\t\tinput,\n\t\tsystem_message: options.systemMessage ?? SYSTEM_MESSAGE,\n\t\tformatting_instructions:\n\t\t\t'IMPORTANT: For your response to user, you MUST use the `format_final_json_response` tool with your complete answer formatted according to the required schema. Do not attempt to format the JSON manually - always use this tool. Your response will be rejected if it is not properly formatted through this tool. Only use this tool once you are ready to provide your final answer.',\n\t};\n\tconst executeOptions = { signal: ctx.getExecutionCancelSignal() };\n\n\t// Check if streaming is actually available\n\tconst isStreamingAvailable = 'isStreaming' in ctx ? ctx.isStreaming?.() : undefined;\n\n\tif (\n\t\t'isStreaming' in ctx &&\n\t\toptions.enableStreaming &&\n\t\tisStreamingAvailable &&\n\t\tctx.getNode().typeVersion >= 2.1\n\t) {\n\t\tconst chatHistory = await loadMemory(memory, model, options.maxTokensFromMemory);\n\t\tconst eventStream = executor.withConfig(getTracingConfig(ctx)).streamEvents(\n\t\t\t{\n\t\t\t\t...invokeParams,\n\t\t\t\tchat_history: chatHistory,\n\t\t\t},\n\t\t\t{\n\t\t\t\tversion: 'v2',\n\t\t\t\t...executeOptions,\n\t\t\t},\n\t\t);\n\n\t\tconst result = await processEventStream(ctx, eventStream, itemIndex);\n\n\t\t// If result contains tool calls, build the request object like the normal flow\n\t\tif (result.toolCalls && result.toolCalls.length > 0) {\n\t\t\tconst actions = await createEngineRequests(result.toolCalls, itemIndex, tools);\n\n\t\t\treturn {\n\t\t\t\tactions,\n\t\t\t\tmetadata: buildResponseMetadata(response, itemIndex),\n\t\t\t};\n\t\t}\n\t\t// Save conversation to memory including any tool call context\n\t\tif (memory && input && result?.output) {\n\t\t\tconst previousCount = response?.metadata?.previousRequests?.length;\n\t\t\tawait saveToMemory(input, result.output, memory, steps, previousCount);\n\t\t}\n\n\t\tif (options.returnIntermediateSteps && steps.length > 0) {\n\t\t\tresult.intermediateSteps = steps;\n\t\t}\n\n\t\treturn result;\n\t} else {\n\t\t// Handle regular execution\n\t\tconst chatHistory = await loadMemory(memory, model, options.maxTokensFromMemory);\n\n\t\tconst modelResponse = await executor.withConfig(getTracingConfig(ctx)).invoke({\n\t\t\t...invokeParams,\n\t\t\tchat_history: chatHistory,\n\t\t});\n\n\t\tif ('returnValues' in modelResponse) {\n\t\t\t// Save conversation to memory including any tool call context\n\t\t\tif (memory && input && modelResponse.returnValues.output) {\n\t\t\t\tconst previousCount = response?.metadata?.previousRequests?.length;\n\t\t\t\tawait saveToMemory(input, modelResponse.returnValues.output, memory, steps, previousCount);\n\t\t\t}\n\t\t\t// Include intermediate steps if requested\n\t\t\tconst result = { ...modelResponse.returnValues };\n\t\t\tif (options.returnIntermediateSteps && steps.length > 0) {\n\t\t\t\tresult.intermediateSteps = steps;\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\n\t\t// If response contains tool calls, we need to return this in the right format\n\t\tconst actions = await createEngineRequests(modelResponse, itemIndex, tools);\n\n\t\treturn {\n\t\t\tactions,\n\t\t\tmetadata: buildResponseMetadata(response, itemIndex),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,6BAKO;AACP,qBAAiC;AAQjC,oBAA+B;AAE/B,mCAAsC;AAgBtC,eAAsB,SACrB,KACA,UACA,aACA,OACA,QACA,UAC0B;AAC1B,QAAM,EAAE,WAAW,OAAO,OAAO,OAAO,QAAQ,IAAI;AAEpD,QAAM,eAAe;AAAA,IACpB;AAAA,IACA;AAAA,IACA,gBAAgB,QAAQ,iBAAiB;AAAA,IACzC,yBACC;AAAA,EACF;AACA,QAAM,iBAAiB,EAAE,QAAQ,IAAI,yBAAyB,EAAE;AAGhE,QAAM,uBAAuB,iBAAiB,MAAM,IAAI,cAAc,IAAI;AAE1E,MACC,iBAAiB,OACjB,QAAQ,mBACR,wBACA,IAAI,QAAQ,EAAE,eAAe,KAC5B;AACD,UAAM,cAAc,UAAM,mCAAW,QAAQ,OAAO,QAAQ,mBAAmB;AAC/E,UAAM,cAAc,SAAS,eAAW,iCAAiB,GAAG,CAAC,EAAE;AAAA,MAC9D;AAAA,QACC,GAAG;AAAA,QACH,cAAc;AAAA,MACf;AAAA,MACA;AAAA,QACC,SAAS;AAAA,QACT,GAAG;AAAA,MACJ;AAAA,IACD;AA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Resolver
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(Code_node_exports);
|
|
26
|
-
var import_vm2 = require("
|
|
26
|
+
var import_vm2 = require("vm2");
|
|
27
27
|
var import_JavaScriptSandbox = require("n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox");
|
|
28
28
|
var import_Sandbox = require("n8n-nodes-base/dist/nodes/Code/Sandbox");
|
|
29
29
|
var import_utils = require("n8n-nodes-base/dist/nodes/Code/utils");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../nodes/code/Code.node.ts"],"sourcesContent":["import type { Tool } from '@langchain/core/tools';\nimport { makeResolverFromLegacyOptions } from '@n8n/vm2';\nimport { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';\nimport { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport { standardizeOutput } from 'n8n-nodes-base/dist/nodes/Code/utils';\nimport { NodeOperationError, NodeConnectionTypes } from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tINodeOutputConfiguration,\n\tSupplyData,\n\tISupplyDataFunctions,\n} from 'n8n-workflow';\n\n// TODO: Add support for execute function. Got already started but got commented out\n\nimport { logWrapper } from '@utils/logWrapper';\n\nconst { NODE_FUNCTION_ALLOW_BUILTIN: builtIn, NODE_FUNCTION_ALLOW_EXTERNAL: external } =\n\tprocess.env;\n\n// TODO: Replace\nconst connectorTypes = {\n\t[NodeConnectionTypes.AiChain]: 'Chain',\n\t[NodeConnectionTypes.AiDocument]: 'Document',\n\t[NodeConnectionTypes.AiEmbedding]: 'Embedding',\n\t[NodeConnectionTypes.AiLanguageModel]: 'Language Model',\n\t[NodeConnectionTypes.AiMemory]: 'Memory',\n\t[NodeConnectionTypes.AiOutputParser]: 'Output Parser',\n\t[NodeConnectionTypes.AiTextSplitter]: 'Text Splitter',\n\t[NodeConnectionTypes.AiTool]: 'Tool',\n\t[NodeConnectionTypes.AiVectorStore]: 'Vector Store',\n\t[NodeConnectionTypes.Main]: 'Main',\n};\n\nconst defaultCodeExecute = `const { PromptTemplate } = require('@langchain/core/prompts');\n\nconst query = 'Tell me a joke';\nconst prompt = PromptTemplate.fromTemplate(query);\n\n// If you are allowing more than one language model input connection (-1 or\n// anything greater than 1), getInputConnectionData returns an array, so you\n// will have to change the code below it to deal with that. For example, use\n// llm[0] in the chain definition\n\nconst llm = await this.getInputConnectionData('ai_languageModel', 0);\nlet chain = prompt.pipe(llm);\nconst output = await chain.invoke();\nreturn [ {json: { output } } ];\n\n// NOTE: Old langchain imports (e.g., 'langchain/chains') are automatically\n// converted to '@langchain/classic' imports for backwards compatibility.`;\n\nconst defaultCodeSupplyData = `const { WikipediaQueryRun } = require( '@langchain/community/tools/wikipedia_query_run');\nreturn new WikipediaQueryRun();`;\n\n/**\n * Transforms old langchain import paths to @langchain/classic for backwards compatibility.\n * Only transforms paths that actually moved to the classic package.\n *\n * @param moduleName - The original module name from the import statement\n * @returns The transformed module name, or the original if no transformation is needed\n */\nexport function transformLegacyLangchainImport(moduleName: string): string {\n\t// List of langchain submodules that moved to @langchain/classic\n\t// Based on https://www.npmjs.com/package/@langchain/classic exports\n\tconst classicModules = [\n\t\t'agents',\n\t\t'callbacks',\n\t\t'chains',\n\t\t'chat_models/universal',\n\t\t'document',\n\t\t'document_loaders',\n\t\t'document_transformers',\n\t\t'embeddings/cache_backed',\n\t\t'embeddings/fake',\n\t\t'evaluation',\n\t\t'experimental',\n\t\t'hub',\n\t\t'indexes',\n\t\t'load',\n\t\t'memory',\n\t\t'output_parsers',\n\t\t'retrievers',\n\t\t'schema',\n\t\t'smith',\n\t\t'sql_db',\n\t\t'storage',\n\t\t'stores',\n\t\t'text_splitter',\n\t\t'tools',\n\t\t'util',\n\t\t'vectorstores',\n\t];\n\n\t// Check if this is a langchain/ import (old style)\n\tif (moduleName.startsWith('langchain/')) {\n\t\tconst subpath = moduleName.substring('langchain/'.length);\n\n\t\t// Check if this subpath or any parent path is in the classic modules list\n\t\tfor (const classicModule of classicModules) {\n\t\t\tif (subpath === classicModule || subpath.startsWith(classicModule + '/')) {\n\t\t\t\t// Transform to @langchain/classic\n\t\t\t\treturn `@langchain/classic/${subpath}`;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn moduleName;\n}\n\n/**\n * Transforms user code to replace old langchain require/import statements\n * with @langchain/classic equivalents.\n *\n * @param code - The user's code string\n * @returns The transformed code with updated import paths\n */\nfunction transformLegacyLangchainCode(code: string): string {\n\t// Transform require statements: require('langchain/...')\n\tlet transformedCode = code.replace(\n\t\t/require\\s*\\(\\s*['\"]langchain\\/([\\w/_]+)['\"]\\s*\\)/g,\n\t\t(match, subpath) => {\n\t\t\tconst oldPath = `langchain/${subpath}`;\n\t\t\tconst newPath = transformLegacyLangchainImport(oldPath);\n\t\t\treturn newPath === oldPath ? match : `require('${newPath}')`;\n\t\t},\n\t);\n\n\t// Transform import statements: from 'langchain/...'\n\ttransformedCode = transformedCode.replace(\n\t\t/from\\s+['\"]langchain\\/([\\w/_]+)['\"]/g,\n\t\t(match, subpath) => {\n\t\t\tconst oldPath = `langchain/${subpath}`;\n\t\t\tconst newPath = transformLegacyLangchainImport(oldPath);\n\t\t\treturn newPath === oldPath ? match : `from '${newPath}'`;\n\t\t},\n\t);\n\n\treturn transformedCode;\n}\n\nconst langchainModules = ['langchain', '@langchain/*'];\nexport const vmResolver = makeResolverFromLegacyOptions({\n\texternal: {\n\t\tmodules: external ? [...langchainModules, ...external.split(',')] : [...langchainModules],\n\t\ttransitive: false,\n\t},\n\tresolve(moduleName, parentDirname) {\n\t\tif (moduleName.match(/^langchain\\//) ?? moduleName.match(/^@langchain\\//)) {\n\t\t\treturn require.resolve(`@n8n/n8n-nodes-langchain/node_modules/${moduleName}.cjs`, {\n\t\t\t\tpaths: [parentDirname],\n\t\t\t});\n\t\t}\n\t\treturn;\n\t},\n\tbuiltin: builtIn?.split(',') ?? [],\n});\n\nfunction getSandbox(\n\tthis: IExecuteFunctions | ISupplyDataFunctions,\n\tcode: string,\n\toptions?: { addItems?: boolean; itemIndex?: number },\n) {\n\tconst itemIndex = options?.itemIndex ?? 0;\n\tconst node = this.getNode();\n\tconst workflowMode = this.getMode();\n\n\t// Transform legacy langchain imports to @langchain/classic\n\tconst transformedCode = transformLegacyLangchainCode(code);\n\n\tconst context = getSandboxContext.call(this, itemIndex);\n\tcontext.addInputData = this.addInputData.bind(this);\n\tcontext.addOutputData = this.addOutputData.bind(this);\n\tcontext.getInputConnectionData = this.getInputConnectionData.bind(this);\n\tcontext.getInputData = this.getInputData.bind(this);\n\tcontext.getNode = this.getNode.bind(this);\n\tcontext.getExecutionCancelSignal = this.getExecutionCancelSignal.bind(this);\n\tcontext.getNodeOutputs = this.getNodeOutputs.bind(this);\n\tcontext.executeWorkflow = this.executeWorkflow.bind(this);\n\tcontext.getWorkflowDataProxy = this.getWorkflowDataProxy.bind(this);\n\tcontext.logger = this.logger;\n\n\tif (options?.addItems) {\n\t\tcontext.items = context.$input.all();\n\t}\n\n\tconst sandbox = new JavaScriptSandbox(context, transformedCode, this.helpers, {\n\t\tresolver: vmResolver,\n\t});\n\n\tsandbox.on(\n\t\t'output',\n\t\tworkflowMode === 'manual'\n\t\t\t? this.sendMessageToUI.bind(this)\n\t\t\t: (...args: unknown[]) =>\n\t\t\t\t\tconsole.log(`[Workflow \"${this.getWorkflow().id}\"][Node \"${node.name}\"]`, ...args),\n\t);\n\treturn sandbox;\n}\n\nexport class Code implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'LangChain Code',\n\t\tname: 'code',\n\t\ticon: 'fa:code',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'LangChain Code Node',\n\t\tdefaults: {\n\t\t\tname: 'LangChain Code',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Miscellaneous'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.code/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: `={{ ((values) => { const connectorTypes = ${JSON.stringify(\n\t\t\tconnectorTypes,\n\t\t)}; return values.map(value => { return { type: value.type, required: value.required, maxConnections: value.maxConnections === -1 ? undefined : value.maxConnections, displayName: connectorTypes[value.type] !== 'Main' ? connectorTypes[value.type] : undefined } } ) })($parameter.inputs.input) }}`,\n\t\toutputs: `={{ ((values) => { const connectorTypes = ${JSON.stringify(\n\t\t\tconnectorTypes,\n\t\t)}; return values.map(value => { return { type: value.type, displayName: connectorTypes[value.type] !== 'Main' ? connectorTypes[value.type] : undefined } } ) })($parameter.outputs.output) }}`,\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Code',\n\t\t\t\tname: 'code',\n\t\t\t\tplaceholder: 'Add Code',\n\t\t\t\ttype: 'fixedCollection',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'execute',\n\t\t\t\t\t\tdisplayName: 'Execute',\n\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'JavaScript - Execute',\n\t\t\t\t\t\t\t\tname: 'code',\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\t\t\teditor: 'jsEditor',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdefault: defaultCodeExecute,\n\t\t\t\t\t\t\t\thint: 'This code will only run and return data if a \"Main\" input & output got created.',\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'supplyData',\n\t\t\t\t\t\tdisplayName: 'Supply Data',\n\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'JavaScript - Supply Data',\n\t\t\t\t\t\t\t\tname: 'code',\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\t\t\teditor: 'jsEditor',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdefault: defaultCodeSupplyData,\n\t\t\t\t\t\t\t\thint: 'This code will only run and return data if an output got created which is not \"Main\".',\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\n\t\t\t// TODO: Add links to docs which provide additional information regarding functionality\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'You can import LangChain and use all available functionality. Debug by using <code>console.log()</code> statements and viewing their output in the browser console.',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Inputs',\n\t\t\t\tname: 'inputs',\n\t\t\t\tplaceholder: 'Add Input',\n\t\t\t\ttype: 'fixedCollection',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tmultipleValues: true,\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\tdescription: 'The input to add',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'input',\n\t\t\t\t\t\tdisplayName: 'Input',\n\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Type',\n\t\t\t\t\t\t\t\tname: 'type',\n\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\toptions: Object.keys(connectorTypes).map((key) => ({\n\t\t\t\t\t\t\t\t\tname: connectorTypes[key as keyof typeof connectorTypes],\n\t\t\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tdescription: 'The type of the input',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Max Connections',\n\t\t\t\t\t\t\t\tname: 'maxConnections',\n\t\t\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'How many nodes of this type are allowed to be connected. Set it to -1 for unlimited.',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Required',\n\t\t\t\t\t\t\t\tname: 'required',\n\t\t\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tdescription: 'Whether the input needs a connection',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Outputs',\n\t\t\t\tname: 'outputs',\n\t\t\t\tplaceholder: 'Add Output',\n\t\t\t\ttype: 'fixedCollection',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tmultipleValues: true,\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\tdescription: 'The output to add',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'output',\n\t\t\t\t\t\tdisplayName: 'Output',\n\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Type',\n\t\t\t\t\t\t\t\tname: 'type',\n\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\toptions: Object.keys(connectorTypes).map((key) => ({\n\t\t\t\t\t\t\t\t\tname: connectorTypes[key as keyof typeof connectorTypes],\n\t\t\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tdescription: 'The type of the input',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst itemIndex = 0;\n\n\t\tconst code = this.getNodeParameter('code', itemIndex) as { execute?: { code: string } };\n\n\t\tif (!code.execute?.code) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`No code for \"Execute\" set on node \"${this.getNode().name}`,\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst sandbox = getSandbox.call(this, code.execute.code, { addItems: true, itemIndex });\n\n\t\tconst outputs = this.getNodeOutputs();\n\t\tconst mainOutputs: INodeOutputConfiguration[] = outputs.filter(\n\t\t\t(output) => output.type === NodeConnectionTypes.Main,\n\t\t);\n\n\t\tconst options = { multiOutput: mainOutputs.length !== 1 };\n\n\t\tlet items: INodeExecutionData[] | INodeExecutionData[][];\n\t\ttry {\n\t\t\titems = await sandbox.runCodeAllItems(options);\n\t\t} catch (error) {\n\t\t\tif (!this.continueOnFail()) throw error;\n\t\t\titems = [{ json: { error: (error as Error).message } }];\n\t\t\tif (options.multiOutput) {\n\t\t\t\titems = [items];\n\t\t\t}\n\t\t}\n\n\t\tif (mainOutputs.length === 0) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'The node does not have a \"Main\" output set. Please add one.',\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t},\n\t\t\t);\n\t\t} else if (!options.multiOutput) {\n\t\t\tfor (const item of items as INodeExecutionData[]) {\n\t\t\t\tstandardizeOutput(item.json);\n\t\t\t}\n\t\t\treturn [items as INodeExecutionData[]];\n\t\t} else {\n\t\t\titems.forEach((data) => {\n\t\t\t\tfor (const item of data as INodeExecutionData[]) {\n\t\t\t\t\tstandardizeOutput(item.json);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn items as INodeExecutionData[][];\n\t\t}\n\t}\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst code = this.getNodeParameter('code', itemIndex) as { supplyData?: { code: string } };\n\n\t\tif (!code.supplyData?.code) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`No code for \"Supply Data\" set on node \"${this.getNode().name}`,\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst sandbox = getSandbox.call(this, code.supplyData.code, { itemIndex });\n\t\tconst response = await sandbox.runCode<Tool>();\n\n\t\treturn {\n\t\t\tresponse: logWrapper(response, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAA8C;AAC9C,+BAAkC;AAClC,qBAAkC;AAClC,mBAAkC;AAClC,0BAAwD;AAaxD,wBAA2B;AAE3B,MAAM,EAAE,6BAA6B,SAAS,8BAA8B,SAAS,IACpF,QAAQ;AAGT,MAAM,iBA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AK,QAAQ,EAAE,IAAI;AAAA,QAC7D;AAAA,UACC;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,UAAU,WAAW,KAAK,MAAM,KAAK,WAAW,MAAM,EAAE,UAAU,CAAC;AACzE,UAAM,WAAW,MAAM,QAAQ,QAAc;AAE7C,WAAO;AAAA,MACN,cAAU,8BAAW,UAAU,IAAI;AAAA,IACpC;AAAA,EACD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../nodes/code/Code.node.ts"],"sourcesContent":["import type { Tool } from '@langchain/core/tools';\nimport { makeResolverFromLegacyOptions } from 'vm2';\nimport { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';\nimport { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';\nimport { standardizeOutput } from 'n8n-nodes-base/dist/nodes/Code/utils';\nimport { NodeOperationError, NodeConnectionTypes } from 'n8n-workflow';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tINodeOutputConfiguration,\n\tSupplyData,\n\tISupplyDataFunctions,\n} from 'n8n-workflow';\n\n// TODO: Add support for execute function. Got already started but got commented out\n\nimport { logWrapper } from '@utils/logWrapper';\n\nconst { NODE_FUNCTION_ALLOW_BUILTIN: builtIn, NODE_FUNCTION_ALLOW_EXTERNAL: external } =\n\tprocess.env;\n\n// TODO: Replace\nconst connectorTypes = {\n\t[NodeConnectionTypes.AiChain]: 'Chain',\n\t[NodeConnectionTypes.AiDocument]: 'Document',\n\t[NodeConnectionTypes.AiEmbedding]: 'Embedding',\n\t[NodeConnectionTypes.AiLanguageModel]: 'Language Model',\n\t[NodeConnectionTypes.AiMemory]: 'Memory',\n\t[NodeConnectionTypes.AiOutputParser]: 'Output Parser',\n\t[NodeConnectionTypes.AiTextSplitter]: 'Text Splitter',\n\t[NodeConnectionTypes.AiTool]: 'Tool',\n\t[NodeConnectionTypes.AiVectorStore]: 'Vector Store',\n\t[NodeConnectionTypes.Main]: 'Main',\n};\n\nconst defaultCodeExecute = `const { PromptTemplate } = require('@langchain/core/prompts');\n\nconst query = 'Tell me a joke';\nconst prompt = PromptTemplate.fromTemplate(query);\n\n// If you are allowing more than one language model input connection (-1 or\n// anything greater than 1), getInputConnectionData returns an array, so you\n// will have to change the code below it to deal with that. For example, use\n// llm[0] in the chain definition\n\nconst llm = await this.getInputConnectionData('ai_languageModel', 0);\nlet chain = prompt.pipe(llm);\nconst output = await chain.invoke();\nreturn [ {json: { output } } ];\n\n// NOTE: Old langchain imports (e.g., 'langchain/chains') are automatically\n// converted to '@langchain/classic' imports for backwards compatibility.`;\n\nconst defaultCodeSupplyData = `const { WikipediaQueryRun } = require( '@langchain/community/tools/wikipedia_query_run');\nreturn new WikipediaQueryRun();`;\n\n/**\n * Transforms old langchain import paths to @langchain/classic for backwards compatibility.\n * Only transforms paths that actually moved to the classic package.\n *\n * @param moduleName - The original module name from the import statement\n * @returns The transformed module name, or the original if no transformation is needed\n */\nexport function transformLegacyLangchainImport(moduleName: string): string {\n\t// List of langchain submodules that moved to @langchain/classic\n\t// Based on https://www.npmjs.com/package/@langchain/classic exports\n\tconst classicModules = [\n\t\t'agents',\n\t\t'callbacks',\n\t\t'chains',\n\t\t'chat_models/universal',\n\t\t'document',\n\t\t'document_loaders',\n\t\t'document_transformers',\n\t\t'embeddings/cache_backed',\n\t\t'embeddings/fake',\n\t\t'evaluation',\n\t\t'experimental',\n\t\t'hub',\n\t\t'indexes',\n\t\t'load',\n\t\t'memory',\n\t\t'output_parsers',\n\t\t'retrievers',\n\t\t'schema',\n\t\t'smith',\n\t\t'sql_db',\n\t\t'storage',\n\t\t'stores',\n\t\t'text_splitter',\n\t\t'tools',\n\t\t'util',\n\t\t'vectorstores',\n\t];\n\n\t// Check if this is a langchain/ import (old style)\n\tif (moduleName.startsWith('langchain/')) {\n\t\tconst subpath = moduleName.substring('langchain/'.length);\n\n\t\t// Check if this subpath or any parent path is in the classic modules list\n\t\tfor (const classicModule of classicModules) {\n\t\t\tif (subpath === classicModule || subpath.startsWith(classicModule + '/')) {\n\t\t\t\t// Transform to @langchain/classic\n\t\t\t\treturn `@langchain/classic/${subpath}`;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn moduleName;\n}\n\n/**\n * Transforms user code to replace old langchain require/import statements\n * with @langchain/classic equivalents.\n *\n * @param code - The user's code string\n * @returns The transformed code with updated import paths\n */\nfunction transformLegacyLangchainCode(code: string): string {\n\t// Transform require statements: require('langchain/...')\n\tlet transformedCode = code.replace(\n\t\t/require\\s*\\(\\s*['\"]langchain\\/([\\w/_]+)['\"]\\s*\\)/g,\n\t\t(match, subpath) => {\n\t\t\tconst oldPath = `langchain/${subpath}`;\n\t\t\tconst newPath = transformLegacyLangchainImport(oldPath);\n\t\t\treturn newPath === oldPath ? match : `require('${newPath}')`;\n\t\t},\n\t);\n\n\t// Transform import statements: from 'langchain/...'\n\ttransformedCode = transformedCode.replace(\n\t\t/from\\s+['\"]langchain\\/([\\w/_]+)['\"]/g,\n\t\t(match, subpath) => {\n\t\t\tconst oldPath = `langchain/${subpath}`;\n\t\t\tconst newPath = transformLegacyLangchainImport(oldPath);\n\t\t\treturn newPath === oldPath ? match : `from '${newPath}'`;\n\t\t},\n\t);\n\n\treturn transformedCode;\n}\n\nconst langchainModules = ['langchain', '@langchain/*'];\nexport const vmResolver = makeResolverFromLegacyOptions({\n\texternal: {\n\t\tmodules: external ? [...langchainModules, ...external.split(',')] : [...langchainModules],\n\t\ttransitive: false,\n\t},\n\tresolve(moduleName, parentDirname) {\n\t\tif (moduleName.match(/^langchain\\//) ?? moduleName.match(/^@langchain\\//)) {\n\t\t\treturn require.resolve(`@n8n/n8n-nodes-langchain/node_modules/${moduleName}.cjs`, {\n\t\t\t\tpaths: [parentDirname],\n\t\t\t});\n\t\t}\n\t\treturn;\n\t},\n\tbuiltin: builtIn?.split(',') ?? [],\n});\n\nfunction getSandbox(\n\tthis: IExecuteFunctions | ISupplyDataFunctions,\n\tcode: string,\n\toptions?: { addItems?: boolean; itemIndex?: number },\n) {\n\tconst itemIndex = options?.itemIndex ?? 0;\n\tconst node = this.getNode();\n\tconst workflowMode = this.getMode();\n\n\t// Transform legacy langchain imports to @langchain/classic\n\tconst transformedCode = transformLegacyLangchainCode(code);\n\n\tconst context = getSandboxContext.call(this, itemIndex);\n\tcontext.addInputData = this.addInputData.bind(this);\n\tcontext.addOutputData = this.addOutputData.bind(this);\n\tcontext.getInputConnectionData = this.getInputConnectionData.bind(this);\n\tcontext.getInputData = this.getInputData.bind(this);\n\tcontext.getNode = this.getNode.bind(this);\n\tcontext.getExecutionCancelSignal = this.getExecutionCancelSignal.bind(this);\n\tcontext.getNodeOutputs = this.getNodeOutputs.bind(this);\n\tcontext.executeWorkflow = this.executeWorkflow.bind(this);\n\tcontext.getWorkflowDataProxy = this.getWorkflowDataProxy.bind(this);\n\tcontext.logger = this.logger;\n\n\tif (options?.addItems) {\n\t\tcontext.items = context.$input.all();\n\t}\n\n\tconst sandbox = new JavaScriptSandbox(context, transformedCode, this.helpers, {\n\t\tresolver: vmResolver,\n\t});\n\n\tsandbox.on(\n\t\t'output',\n\t\tworkflowMode === 'manual'\n\t\t\t? this.sendMessageToUI.bind(this)\n\t\t\t: (...args: unknown[]) =>\n\t\t\t\t\tconsole.log(`[Workflow \"${this.getWorkflow().id}\"][Node \"${node.name}\"]`, ...args),\n\t);\n\treturn sandbox;\n}\n\nexport class Code implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'LangChain Code',\n\t\tname: 'code',\n\t\ticon: 'fa:code',\n\t\ticonColor: 'black',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'LangChain Code Node',\n\t\tdefaults: {\n\t\t\tname: 'LangChain Code',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Miscellaneous'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.code/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tinputs: `={{ ((values) => { const connectorTypes = ${JSON.stringify(\n\t\t\tconnectorTypes,\n\t\t)}; return values.map(value => { return { type: value.type, required: value.required, maxConnections: value.maxConnections === -1 ? undefined : value.maxConnections, displayName: connectorTypes[value.type] !== 'Main' ? connectorTypes[value.type] : undefined } } ) })($parameter.inputs.input) }}`,\n\t\toutputs: `={{ ((values) => { const connectorTypes = ${JSON.stringify(\n\t\t\tconnectorTypes,\n\t\t)}; return values.map(value => { return { type: value.type, displayName: connectorTypes[value.type] !== 'Main' ? connectorTypes[value.type] : undefined } } ) })($parameter.outputs.output) }}`,\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Code',\n\t\t\t\tname: 'code',\n\t\t\t\tplaceholder: 'Add Code',\n\t\t\t\ttype: 'fixedCollection',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'execute',\n\t\t\t\t\t\tdisplayName: 'Execute',\n\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'JavaScript - Execute',\n\t\t\t\t\t\t\t\tname: 'code',\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\t\t\teditor: 'jsEditor',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdefault: defaultCodeExecute,\n\t\t\t\t\t\t\t\thint: 'This code will only run and return data if a \"Main\" input & output got created.',\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'supplyData',\n\t\t\t\t\t\tdisplayName: 'Supply Data',\n\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'JavaScript - Supply Data',\n\t\t\t\t\t\t\t\tname: 'code',\n\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\t\t\teditor: 'jsEditor',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tdefault: defaultCodeSupplyData,\n\t\t\t\t\t\t\t\thint: 'This code will only run and return data if an output got created which is not \"Main\".',\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\n\t\t\t// TODO: Add links to docs which provide additional information regarding functionality\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'You can import LangChain and use all available functionality. Debug by using <code>console.log()</code> statements and viewing their output in the browser console.',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Inputs',\n\t\t\t\tname: 'inputs',\n\t\t\t\tplaceholder: 'Add Input',\n\t\t\t\ttype: 'fixedCollection',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tmultipleValues: true,\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\tdescription: 'The input to add',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'input',\n\t\t\t\t\t\tdisplayName: 'Input',\n\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Type',\n\t\t\t\t\t\t\t\tname: 'type',\n\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\toptions: Object.keys(connectorTypes).map((key) => ({\n\t\t\t\t\t\t\t\t\tname: connectorTypes[key as keyof typeof connectorTypes],\n\t\t\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tdescription: 'The type of the input',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Max Connections',\n\t\t\t\t\t\t\t\tname: 'maxConnections',\n\t\t\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'How many nodes of this type are allowed to be connected. Set it to -1 for unlimited.',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Required',\n\t\t\t\t\t\t\t\tname: 'required',\n\t\t\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tdescription: 'Whether the input needs a connection',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Outputs',\n\t\t\t\tname: 'outputs',\n\t\t\t\tplaceholder: 'Add Output',\n\t\t\t\ttype: 'fixedCollection',\n\t\t\t\tnoDataExpression: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tmultipleValues: true,\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\tdescription: 'The output to add',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'output',\n\t\t\t\t\t\tdisplayName: 'Output',\n\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Type',\n\t\t\t\t\t\t\t\tname: 'type',\n\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\toptions: Object.keys(connectorTypes).map((key) => ({\n\t\t\t\t\t\t\t\t\tname: connectorTypes[key as keyof typeof connectorTypes],\n\t\t\t\t\t\t\t\t\tvalue: key,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\tnoDataExpression: true,\n\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tdescription: 'The type of the input',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst itemIndex = 0;\n\n\t\tconst code = this.getNodeParameter('code', itemIndex) as { execute?: { code: string } };\n\n\t\tif (!code.execute?.code) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`No code for \"Execute\" set on node \"${this.getNode().name}`,\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst sandbox = getSandbox.call(this, code.execute.code, { addItems: true, itemIndex });\n\n\t\tconst outputs = this.getNodeOutputs();\n\t\tconst mainOutputs: INodeOutputConfiguration[] = outputs.filter(\n\t\t\t(output) => output.type === NodeConnectionTypes.Main,\n\t\t);\n\n\t\tconst options = { multiOutput: mainOutputs.length !== 1 };\n\n\t\tlet items: INodeExecutionData[] | INodeExecutionData[][];\n\t\ttry {\n\t\t\titems = await sandbox.runCodeAllItems(options);\n\t\t} catch (error) {\n\t\t\tif (!this.continueOnFail()) throw error;\n\t\t\titems = [{ json: { error: (error as Error).message } }];\n\t\t\tif (options.multiOutput) {\n\t\t\t\titems = [items];\n\t\t\t}\n\t\t}\n\n\t\tif (mainOutputs.length === 0) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'The node does not have a \"Main\" output set. Please add one.',\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t},\n\t\t\t);\n\t\t} else if (!options.multiOutput) {\n\t\t\tfor (const item of items as INodeExecutionData[]) {\n\t\t\t\tstandardizeOutput(item.json);\n\t\t\t}\n\t\t\treturn [items as INodeExecutionData[]];\n\t\t} else {\n\t\t\titems.forEach((data) => {\n\t\t\t\tfor (const item of data as INodeExecutionData[]) {\n\t\t\t\t\tstandardizeOutput(item.json);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn items as INodeExecutionData[][];\n\t\t}\n\t}\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst code = this.getNodeParameter('code', itemIndex) as { supplyData?: { code: string } };\n\n\t\tif (!code.supplyData?.code) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`No code for \"Supply Data\" set on node \"${this.getNode().name}`,\n\t\t\t\t{\n\t\t\t\t\titemIndex,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst sandbox = getSandbox.call(this, code.supplyData.code, { itemIndex });\n\t\tconst response = await sandbox.runCode<Tool>();\n\n\t\treturn {\n\t\t\tresponse: logWrapper(response, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAA8C;AAC9C,+BAAkC;AAClC,qBAAkC;AAClC,mBAAkC;AAClC,0BAAwD;AAaxD,wBAA2B;AAE3B,MAAM,EAAE,6BAA6B,SAAS,8BAA8B,SAAS,IACpF,QAAQ;AAGT,MAAM,iBAAiB;AAAA,EACtB,CAAC,wCAAoB,OAAO,GAAG;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ACC;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,UAAM,UAAU,WAAW,KAAK,MAAM,KAAK,WAAW,MAAM,EAAE,UAAU,CAAC;AACzE,UAAM,WAAW,MAAM,QAAQ,QAAc;AAE7C,WAAO;AAAA,MACN,cAAU,8BAAW,UAAU,IAAI;AAAA,IACpC;AAAA,EACD;AACD;","names":[]}
|
|
@@ -153,7 +153,8 @@ class EmbeddingsAzureOpenAi {
|
|
|
153
153
|
configuration: {
|
|
154
154
|
fetchOptions: {
|
|
155
155
|
dispatcher: (0, import_httpProxyAgent.getProxyAgent)(
|
|
156
|
-
credentials.endpoint ?? `https://${credentials.resourceName}.openai.azure.com
|
|
156
|
+
credentials.endpoint ?? `https://${credentials.resourceName}.openai.azure.com`,
|
|
157
|
+
{}
|
|
157
158
|
)
|
|
158
159
|
}
|
|
159
160
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.ts"],"sourcesContent":["import { AzureOpenAIEmbeddings } from '@langchain/openai';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getProxyAgent } from '@utils/httpProxyAgent';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class EmbeddingsAzureOpenAi implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Embeddings Azure OpenAI',\n\t\tname: 'embeddingsAzureOpenAi',\n\t\ticon: 'file:azure.svg',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'azureOpenAiApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Use Embeddings Azure OpenAI',\n\t\tdefaults: {\n\t\t\tname: 'Embeddings Azure OpenAI',\n\t\t},\n\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Embeddings'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsazureopenai/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiEmbedding],\n\t\toutputNames: ['Embeddings'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Model (Deployment) Name',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'The name of the model(deployment) to use',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Batch Size',\n\t\t\t\t\t\tname: 'batchSize',\n\t\t\t\t\t\tdefault: 512,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2048 },\n\t\t\t\t\t\tdescription: 'Maximum number of documents to send in each request',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Strip New Lines',\n\t\t\t\t\t\tname: 'stripNewLines',\n\t\t\t\t\t\tdefault: true,\n\t\t\t\t\t\tdescription: 'Whether to strip new lines from the input text',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Maximum amount of time a request is allowed to take in seconds. Set to -1 for no timeout.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Dimensions',\n\t\t\t\t\t\tname: 'dimensions',\n\t\t\t\t\t\tdefault: undefined,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '256',\n\t\t\t\t\t\t\t\tvalue: 256,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '512',\n\t\t\t\t\t\t\t\tvalue: 512,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '1024',\n\t\t\t\t\t\t\t\tvalue: 1024,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '1536',\n\t\t\t\t\t\t\t\tvalue: 1536,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '3072',\n\t\t\t\t\t\t\t\tvalue: 3072,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for embeddings');\n\t\tconst credentials = await this.getCredentials<{\n\t\t\tapiKey: string;\n\t\t\tresourceName: string;\n\t\t\tapiVersion: string;\n\t\t\tendpoint?: string;\n\t\t}>('azureOpenAiApi');\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tbatchSize?: number;\n\t\t\tstripNewLines?: boolean;\n\t\t\ttimeout?: number;\n\t\t\tdimensions?: number | undefined;\n\t\t};\n\n\t\tif (options.timeout === -1) {\n\t\t\toptions.timeout = undefined;\n\t\t}\n\n\t\tconst embeddings = new AzureOpenAIEmbeddings({\n\t\t\tazureOpenAIApiDeploymentName: modelName,\n\t\t\t// instance name only needed to set base url\n\t\t\tazureOpenAIApiInstanceName: !credentials.endpoint ? credentials.resourceName : undefined,\n\t\t\tazureOpenAIApiKey: credentials.apiKey,\n\t\t\tazureOpenAIApiVersion: credentials.apiVersion,\n\t\t\t// azureOpenAIEndpoint and configuration.baseURL are both ignored here\n\t\t\t// only setting azureOpenAIBasePath worked\n\t\t\tazureOpenAIBasePath: credentials.endpoint\n\t\t\t\t? `${credentials.endpoint}/openai/deployments`\n\t\t\t\t: undefined,\n\t\t\tconfiguration: {\n\t\t\t\tfetchOptions: {\n\t\t\t\t\tdispatcher: getProxyAgent(\n\t\t\t\t\t\tcredentials.endpoint ?? `https://${credentials.resourceName}.openai.azure.com`,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsC;AACtC,0BAMO;AAEP,4BAA8B;AAC9B,wBAA2B;AAC3B,0BAA6C;AAEtC,MAAM,sBAA2C;AAAA,EAAjD;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,QACX;AAAA,MACD;AAAA,MACA,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;A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BACA;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,gBACA;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,gBACA;AAAA,kBACC,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR;AAAA,cACD;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,SAAK,OAAO,MAAM,4BAA4B;AAC9C,UAAM,cAAc,MAAM,KAAK,eAK5B,gBAAgB;AACnB,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAE1D,UAAM,UAAU,KAAK,iBAAiB,WAAW,WAAW,CAAC,CAAC;AAO9D,QAAI,QAAQ,YAAY,IAAI;AAC3B,cAAQ,UAAU;AAAA,IACnB;AAEA,UAAM,aAAa,IAAI,oCAAsB;AAAA,MAC5C,8BAA8B;AAAA;AAAA,MAE9B,4BAA4B,CAAC,YAAY,WAAW,YAAY,eAAe;AAAA,MAC/E,mBAAmB,YAAY;AAAA,MAC/B,uBAAuB,YAAY;AAAA;AAAA;AAAA,MAGnC,qBAAqB,YAAY,WAC9B,GAAG,YAAY,QAAQ,wBACvB;AAAA,MACH,eAAe;AAAA,QACd,cAAc;AAAA,UACb,gBAAY;AAAA,YACX,YAAY,YAAY,WAAW,YAAY,YAAY;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.ts"],"sourcesContent":["import { AzureOpenAIEmbeddings } from '@langchain/openai';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getProxyAgent } from '@utils/httpProxyAgent';\nimport { logWrapper } from '@utils/logWrapper';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nexport class EmbeddingsAzureOpenAi implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Embeddings Azure OpenAI',\n\t\tname: 'embeddingsAzureOpenAi',\n\t\ticon: 'file:azure.svg',\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'azureOpenAiApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'Use Embeddings Azure OpenAI',\n\t\tdefaults: {\n\t\t\tname: 'Embeddings Azure OpenAI',\n\t\t},\n\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Embeddings'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsazureopenai/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiEmbedding],\n\t\toutputNames: ['Embeddings'],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),\n\t\t\t{\n\t\t\t\tdisplayName: 'Model (Deployment) Name',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'The name of the model(deployment) to use',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Batch Size',\n\t\t\t\t\t\tname: 'batchSize',\n\t\t\t\t\t\tdefault: 512,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2048 },\n\t\t\t\t\t\tdescription: 'Maximum number of documents to send in each request',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Strip New Lines',\n\t\t\t\t\t\tname: 'stripNewLines',\n\t\t\t\t\t\tdefault: true,\n\t\t\t\t\t\tdescription: 'Whether to strip new lines from the input text',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Maximum amount of time a request is allowed to take in seconds. Set to -1 for no timeout.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Dimensions',\n\t\t\t\t\t\tname: 'dimensions',\n\t\t\t\t\t\tdefault: undefined,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '256',\n\t\t\t\t\t\t\t\tvalue: 256,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '512',\n\t\t\t\t\t\t\t\tvalue: 512,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '1024',\n\t\t\t\t\t\t\t\tvalue: 1024,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '1536',\n\t\t\t\t\t\t\t\tvalue: 1536,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '3072',\n\t\t\t\t\t\t\t\tvalue: 3072,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for embeddings');\n\t\tconst credentials = await this.getCredentials<{\n\t\t\tapiKey: string;\n\t\t\tresourceName: string;\n\t\t\tapiVersion: string;\n\t\t\tendpoint?: string;\n\t\t}>('azureOpenAiApi');\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tbatchSize?: number;\n\t\t\tstripNewLines?: boolean;\n\t\t\ttimeout?: number;\n\t\t\tdimensions?: number | undefined;\n\t\t};\n\n\t\tif (options.timeout === -1) {\n\t\t\toptions.timeout = undefined;\n\t\t}\n\n\t\tconst embeddings = new AzureOpenAIEmbeddings({\n\t\t\tazureOpenAIApiDeploymentName: modelName,\n\t\t\t// instance name only needed to set base url\n\t\t\tazureOpenAIApiInstanceName: !credentials.endpoint ? credentials.resourceName : undefined,\n\t\t\tazureOpenAIApiKey: credentials.apiKey,\n\t\t\tazureOpenAIApiVersion: credentials.apiVersion,\n\t\t\t// azureOpenAIEndpoint and configuration.baseURL are both ignored here\n\t\t\t// only setting azureOpenAIBasePath worked\n\t\t\tazureOpenAIBasePath: credentials.endpoint\n\t\t\t\t? `${credentials.endpoint}/openai/deployments`\n\t\t\t\t: undefined,\n\t\t\tconfiguration: {\n\t\t\t\tfetchOptions: {\n\t\t\t\t\tdispatcher: getProxyAgent(\n\t\t\t\t\t\tcredentials.endpoint ?? `https://${credentials.resourceName}.openai.azure.com`,\n\t\t\t\t\t\t{},\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAs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ACD;AAAA,MACA,GAAG;AAAA,IACJ,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,YAAY,IAAI;AAAA,IACtC;AAAA,EACD;AACD;","names":[]}
|
|
@@ -251,11 +251,9 @@ class EmbeddingsOpenAi {
|
|
|
251
251
|
} else if (credentials.url) {
|
|
252
252
|
configuration.baseURL = credentials.url;
|
|
253
253
|
}
|
|
254
|
-
|
|
255
|
-
configuration.
|
|
256
|
-
|
|
257
|
-
};
|
|
258
|
-
}
|
|
254
|
+
configuration.fetchOptions = {
|
|
255
|
+
dispatcher: (0, import_httpProxyAgent.getProxyAgent)(configuration.baseURL ?? "https://api.openai.com/v1", {})
|
|
256
|
+
};
|
|
259
257
|
const embeddings = new import_openai.OpenAIEmbeddings({
|
|
260
258
|
model: this.getNodeParameter("model", itemIndex, "text-embedding-3-small"),
|
|
261
259
|
apiKey: credentials.apiKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.ts"],"sourcesContent":["import { OpenAIEmbeddings } from '@langchain/openai';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype SupplyData,\n\ttype ISupplyDataFunctions,\n\ttype INodeProperties,\n} from 'n8n-workflow';\nimport type { ClientOptions } from 'openai';\n\nimport { logWrapper } from '@utils/logWrapper';\n\nimport { getProxyAgent } from '@utils/httpProxyAgent';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\nimport { Container } from '@n8n/di';\nimport { AiConfig } from '@n8n/config';\n\nconst modelParameter: INodeProperties = {\n\tdisplayName: 'Model',\n\tname: 'model',\n\ttype: 'options',\n\tdescription:\n\t\t'The model which will generate the embeddings. <a href=\"https://platform.openai.com/docs/models/overview\">Learn more</a>.',\n\ttypeOptions: {\n\t\tloadOptions: {\n\t\t\trouting: {\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\turl: '={{ $parameter.options?.baseURL?.split(\"/\").slice(-1).pop() || $credentials?.url?.split(\"/\").slice(-1).pop() || \"v1\" }}/models',\n\t\t\t\t},\n\t\t\t\toutput: {\n\t\t\t\t\tpostReceive: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'rootProperty',\n\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\tproperty: 'data',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'filter',\n\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t// If the baseURL is not set or is set to api.openai.com, include only embedding models\n\t\t\t\t\t\t\t\tpass: `={{\n\t\t\t\t\t\t\t\t\t($parameter.options?.baseURL && !$parameter.options?.baseURL?.startsWith('https://api.openai.com/')) ||\n\t\t\t\t\t\t\t\t\t($credentials?.url && !$credentials.url.startsWith('https://api.openai.com/')) ||\n\t\t\t\t\t\t\t\t\t$responseItem.id.includes('embed')\n\t\t\t\t\t\t\t\t}}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'setKeyValue',\n\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\tname: '={{$responseItem.id}}',\n\t\t\t\t\t\t\t\tvalue: '={{$responseItem.id}}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'sort',\n\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\tkey: 'name',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\trouting: {\n\t\tsend: {\n\t\t\ttype: 'body',\n\t\t\tproperty: 'model',\n\t\t},\n\t},\n\tdefault: 'text-embedding-3-small',\n};\n\nexport class EmbeddingsOpenAi implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Embeddings OpenAI',\n\t\tname: 'embeddingsOpenAi',\n\t\ticon: { light: 'file:openAiLight.svg', dark: 'file:openAiLight.dark.svg' },\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'openAiApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2],\n\t\tdescription: 'Use Embeddings OpenAI',\n\t\tdefaults: {\n\t\t\tname: 'Embeddings OpenAI',\n\t\t},\n\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Embeddings'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsopenai/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiEmbedding],\n\t\toutputNames: ['Embeddings'],\n\t\trequestDefaults: {\n\t\t\tignoreHttpStatusErrors: true,\n\t\t\tbaseURL:\n\t\t\t\t'={{ $parameter.options?.baseURL?.split(\"/\").slice(0,-1).join(\"/\") || $credentials.url?.split(\"/\").slice(0,-1).join(\"/\") || \"https://api.openai.com\" }}',\n\t\t},\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),\n\t\t\t{\n\t\t\t\t...modelParameter,\n\t\t\t\tdefault: 'text-embedding-ada-002',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...modelParameter,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Dimensions',\n\t\t\t\t\t\tname: 'dimensions',\n\t\t\t\t\t\tdefault: undefined,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '256',\n\t\t\t\t\t\t\t\tvalue: 256,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '512',\n\t\t\t\t\t\t\t\tvalue: 512,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '1024',\n\t\t\t\t\t\t\t\tvalue: 1024,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '1536',\n\t\t\t\t\t\t\t\tvalue: 1536,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '3072',\n\t\t\t\t\t\t\t\tvalue: 3072,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\t\t\tname: 'baseURL',\n\t\t\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Batch Size',\n\t\t\t\t\t\tname: 'batchSize',\n\t\t\t\t\t\tdefault: 512,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2048 },\n\t\t\t\t\t\tdescription: 'Maximum number of documents to send in each request',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Strip New Lines',\n\t\t\t\t\t\tname: 'stripNewLines',\n\t\t\t\t\t\tdefault: true,\n\t\t\t\t\t\tdescription: 'Whether to strip new lines from the input text',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Maximum amount of time a request is allowed to take in seconds. Set to -1 for no timeout.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Encoding Format',\n\t\t\t\t\t\tname: 'encodingFormat',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\tdescription: 'The format to return the embeddings in',\n\t\t\t\t\t\tdefault: undefined,\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Float',\n\t\t\t\t\t\t\t\tvalue: 'float',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Base64',\n\t\t\t\t\t\t\t\tvalue: 'base64',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for embeddings');\n\t\tconst credentials = await this.getCredentials('openAiApi');\n\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tbaseURL?: string;\n\t\t\tbatchSize?: number;\n\t\t\tstripNewLines?: boolean;\n\t\t\ttimeout?: number;\n\t\t\tdimensions?: number | undefined;\n\t\t\tencodingFormat?: 'float' | 'base64' | undefined;\n\t\t};\n\n\t\tif (options.timeout === -1) {\n\t\t\toptions.timeout = undefined;\n\t\t}\n\n\t\tconst { openAiDefaultHeaders: defaultHeaders } = Container.get(AiConfig);\n\n\t\tconst configuration: ClientOptions = {\n\t\t\tdefaultHeaders,\n\t\t};\n\t\tif (options.baseURL) {\n\t\t\tconfiguration.baseURL = options.baseURL;\n\t\t} else if (credentials.url) {\n\t\t\tconfiguration.baseURL = credentials.url as string;\n\t\t}\n\n\t\tif (configuration.baseURL) {\n\t\t\tconfiguration.fetchOptions = {\n\t\t\t\tdispatcher: getProxyAgent(configuration.baseURL ?? 'https://api.openai.com/v1'),\n\t\t\t};\n\t\t}\n\n\t\tconst embeddings = new OpenAIEmbeddings({\n\t\t\tmodel: this.getNodeParameter('model', itemIndex, 'text-embedding-3-small') as string,\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\t...options,\n\t\t\tconfiguration,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,0BAOO;AAGP,wBAA2B;AAE3B,4BAA8B;AAC9B,0BAA6C;AAC7C,gBAA0B;AAC1B,oBAAyB;AAEzB,MAAM,iBAAkC;AAAA,EACvC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aACC;AAAA,EACD,aAAa;AAAA,IACZ,aAAa;AAAA,MACZ,SAAS;AAAA,QACR,SAAS;AAAA,UACR,QAAQ;AAAA,UACR,KAAK;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AAM,aAAa,IAAI,+BAAiB;AAAA,MACvC,OAAO,KAAK,iBAAiB,SAAS,WAAW,wBAAwB;AAAA,MACzE,QAAQ,YAAY;AAAA,MACpB,GAAG;AAAA,MACH;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,cAAU,8BAAW,YAAY,IAAI;AAAA,IACtC;AAAA,EACD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.ts"],"sourcesContent":["import { OpenAIEmbeddings } from '@langchain/openai';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype SupplyData,\n\ttype ISupplyDataFunctions,\n\ttype INodeProperties,\n} from 'n8n-workflow';\nimport type { ClientOptions } from 'openai';\n\nimport { logWrapper } from '@utils/logWrapper';\n\nimport { getProxyAgent } from '@utils/httpProxyAgent';\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\nimport { Container } from '@n8n/di';\nimport { AiConfig } from '@n8n/config';\n\nconst modelParameter: INodeProperties = {\n\tdisplayName: 'Model',\n\tname: 'model',\n\ttype: 'options',\n\tdescription:\n\t\t'The model which will generate the embeddings. <a href=\"https://platform.openai.com/docs/models/overview\">Learn more</a>.',\n\ttypeOptions: {\n\t\tloadOptions: {\n\t\t\trouting: {\n\t\t\t\trequest: {\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\turl: '={{ $parameter.options?.baseURL?.split(\"/\").slice(-1).pop() || $credentials?.url?.split(\"/\").slice(-1).pop() || \"v1\" }}/models',\n\t\t\t\t},\n\t\t\t\toutput: {\n\t\t\t\t\tpostReceive: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'rootProperty',\n\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\tproperty: 'data',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'filter',\n\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t// If the baseURL is not set or is set to api.openai.com, include only embedding models\n\t\t\t\t\t\t\t\tpass: `={{\n\t\t\t\t\t\t\t\t\t($parameter.options?.baseURL && !$parameter.options?.baseURL?.startsWith('https://api.openai.com/')) ||\n\t\t\t\t\t\t\t\t\t($credentials?.url && !$credentials.url.startsWith('https://api.openai.com/')) ||\n\t\t\t\t\t\t\t\t\t$responseItem.id.includes('embed')\n\t\t\t\t\t\t\t\t}}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'setKeyValue',\n\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\tname: '={{$responseItem.id}}',\n\t\t\t\t\t\t\t\tvalue: '={{$responseItem.id}}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'sort',\n\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\tkey: 'name',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\trouting: {\n\t\tsend: {\n\t\t\ttype: 'body',\n\t\t\tproperty: 'model',\n\t\t},\n\t},\n\tdefault: 'text-embedding-3-small',\n};\n\nexport class EmbeddingsOpenAi implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Embeddings OpenAI',\n\t\tname: 'embeddingsOpenAi',\n\t\ticon: { light: 'file:openAiLight.svg', dark: 'file:openAiLight.dark.svg' },\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'openAiApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2],\n\t\tdescription: 'Use Embeddings OpenAI',\n\t\tdefaults: {\n\t\t\tname: 'Embeddings OpenAI',\n\t\t},\n\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Embeddings'],\n\t\t\t},\n\t\t\tresources: {\n\t\t\t\tprimaryDocumentation: [\n\t\t\t\t\t{\n\t\t\t\t\t\turl: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsopenai/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\n\t\tinputs: [],\n\n\t\toutputs: [NodeConnectionTypes.AiEmbedding],\n\t\toutputNames: ['Embeddings'],\n\t\trequestDefaults: {\n\t\t\tignoreHttpStatusErrors: true,\n\t\t\tbaseURL:\n\t\t\t\t'={{ $parameter.options?.baseURL?.split(\"/\").slice(0,-1).join(\"/\") || $credentials.url?.split(\"/\").slice(0,-1).join(\"/\") || \"https://api.openai.com\" }}',\n\t\t},\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiVectorStore]),\n\t\t\t{\n\t\t\t\t...modelParameter,\n\t\t\t\tdefault: 'text-embedding-ada-002',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...modelParameter,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\tplaceholder: 'Add Option',\n\t\t\t\tdescription: 'Additional options to add',\n\t\t\t\ttype: 'collection',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Dimensions',\n\t\t\t\t\t\tname: 'dimensions',\n\t\t\t\t\t\tdefault: undefined,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '256',\n\t\t\t\t\t\t\t\tvalue: 256,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '512',\n\t\t\t\t\t\t\t\tvalue: 512,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '1024',\n\t\t\t\t\t\t\t\tvalue: 1024,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '1536',\n\t\t\t\t\t\t\t\tvalue: 1536,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: '3072',\n\t\t\t\t\t\t\t\tvalue: 3072,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Base URL',\n\t\t\t\t\t\tname: 'baseURL',\n\t\t\t\t\t\tdefault: 'https://api.openai.com/v1',\n\t\t\t\t\t\tdescription: 'Override the default base URL for the API',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'@version': [{ _cnd: { gte: 1.2 } }],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Batch Size',\n\t\t\t\t\t\tname: 'batchSize',\n\t\t\t\t\t\tdefault: 512,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2048 },\n\t\t\t\t\t\tdescription: 'Maximum number of documents to send in each request',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Strip New Lines',\n\t\t\t\t\t\tname: 'stripNewLines',\n\t\t\t\t\t\tdefault: true,\n\t\t\t\t\t\tdescription: 'Whether to strip new lines from the input text',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Maximum amount of time a request is allowed to take in seconds. Set to -1 for no timeout.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Encoding Format',\n\t\t\t\t\t\tname: 'encodingFormat',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\tdescription: 'The format to return the embeddings in',\n\t\t\t\t\t\tdefault: undefined,\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Float',\n\t\t\t\t\t\t\t\tvalue: 'float',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Base64',\n\t\t\t\t\t\t\t\tvalue: 'base64',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tthis.logger.debug('Supply data for embeddings');\n\t\tconst credentials = await this.getCredentials('openAiApi');\n\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tbaseURL?: string;\n\t\t\tbatchSize?: number;\n\t\t\tstripNewLines?: boolean;\n\t\t\ttimeout?: number;\n\t\t\tdimensions?: number | undefined;\n\t\t\tencodingFormat?: 'float' | 'base64' | undefined;\n\t\t};\n\n\t\tif (options.timeout === -1) {\n\t\t\toptions.timeout = undefined;\n\t\t}\n\n\t\tconst { openAiDefaultHeaders: defaultHeaders } = Container.get(AiConfig);\n\n\t\tconst configuration: ClientOptions = {\n\t\t\tdefaultHeaders,\n\t\t};\n\t\tif (options.baseURL) {\n\t\t\tconfiguration.baseURL = options.baseURL;\n\t\t} else if (credentials.url) {\n\t\t\tconfiguration.baseURL = credentials.url as string;\n\t\t}\n\n\t\tconfiguration.fetchOptions = {\n\t\t\tdispatcher: getProxyAgent(configuration.baseURL ?? 'https://api.openai.com/v1', {}),\n\t\t};\n\n\t\tconst embeddings = new OpenAIEmbeddings({\n\t\t\tmodel: this.getNodeParameter('model', itemIndex, 'text-embedding-3-small') as string,\n\t\t\tapiKey: credentials.apiKey as string,\n\t\t\t...options,\n\t\t\tconfiguration,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,0BAOO;AAGP,wBAA2B;AAE3B,4BAA8B;AAC9B,0BAA6C;AAC7C,gBAA0B;AAC1B,oBAAyB;AAEzB,MAAM,iBAAkC;AAAA,EACvC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aACC;AAAA,EACD,aAAa;AAAA,IACZ,aAAa;AAAA,MACZ,SAAS;AAAA,QACR,SAAS;AAAA,UACR,QAAQ;AAAA,UACR,KAAK;AAAA,QACN;AAAA,QACA,QAAQ;AAAA,UACP,aAAa;AAAA,YACZ;AAAA,cACC,MAAM;AAAA,cACN,YAAY;AAAA,gBACX,UAAU;AAAA,cACX;AAAA,YACD;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,YAAY;AAAA;AAAA,gBAEX,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,cAKP;AAAA,YACD;AAAA,YACA;AAAA,cACC,MAAM;AAAA,cACN,YAAY;AAAA,gBACX,MAAM;AAAA,gBACN,OAAO;AAAA,cACR;AAAA,YACD;AAAA,YACA;AAAA,cACC,MAAM;A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