@n8n/n8n-nodes-langchain 1.91.1 → 1.92.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/credentials/AnthropicApi.credentials.js +8 -1
  2. package/dist/credentials/AnthropicApi.credentials.js.map +1 -1
  3. package/dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js +150 -0
  4. package/dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js.map +1 -0
  5. package/dist/known/credentials.json +10 -0
  6. package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js +5 -1
  7. package/dist/nodes/llms/LMChatAnthropic/LmChatAnthropic.node.js.map +1 -1
  8. package/dist/nodes/llms/LMChatAnthropic/methods/searchModels.js +3 -1
  9. package/dist/nodes/llms/LMChatAnthropic/methods/searchModels.js.map +1 -1
  10. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +63 -123
  11. package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -1
  12. package/dist/nodes/llms/LmChatAzureOpenAi/credentials/N8nOAuth2TokenCredential.js +61 -0
  13. package/dist/nodes/llms/LmChatAzureOpenAi/credentials/N8nOAuth2TokenCredential.js.map +1 -0
  14. package/dist/nodes/llms/LmChatAzureOpenAi/credentials/api-key.js +53 -0
  15. package/dist/nodes/llms/LmChatAzureOpenAi/credentials/api-key.js.map +1 -0
  16. package/dist/nodes/llms/LmChatAzureOpenAi/credentials/oauth2.js +54 -0
  17. package/dist/nodes/llms/LmChatAzureOpenAi/credentials/oauth2.js.map +1 -0
  18. package/dist/nodes/llms/LmChatAzureOpenAi/properties.js +155 -0
  19. package/dist/nodes/llms/LmChatAzureOpenAi/properties.js.map +1 -0
  20. package/dist/nodes/llms/LmChatAzureOpenAi/types.js +42 -0
  21. package/dist/nodes/llms/LmChatAzureOpenAi/types.js.map +1 -0
  22. package/dist/types/credentials.json +2 -1
  23. package/dist/types/nodes.json +1 -1
  24. package/package.json +7 -4
@@ -34,6 +34,13 @@ class AnthropicApi {
34
34
  typeOptions: { password: true },
35
35
  required: true,
36
36
  default: ""
37
+ },
38
+ {
39
+ displayName: "Base URL",
40
+ name: "url",
41
+ type: "string",
42
+ default: "https://api.anthropic.com",
43
+ description: "Override the default base URL for the API"
37
44
  }
38
45
  ];
39
46
  this.authenticate = {
@@ -46,7 +53,7 @@ class AnthropicApi {
46
53
  };
47
54
  this.test = {
48
55
  request: {
49
- baseURL: "https://api.anthropic.com",
56
+ baseURL: "={{$credentials?.url}}",
50
57
  url: "/v1/messages",
51
58
  method: "POST",
52
59
  headers: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../credentials/AnthropicApi.credentials.ts"],"sourcesContent":["import type {\n\tIAuthenticateGeneric,\n\tICredentialTestRequest,\n\tICredentialType,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nexport class AnthropicApi implements ICredentialType {\n\tname = 'anthropicApi';\n\n\tdisplayName = 'Anthropic';\n\n\tdocumentationUrl = 'anthropic';\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\trequired: true,\n\t\t\tdefault: '',\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-api-key': '={{$credentials.apiKey}}',\n\t\t\t},\n\t\t},\n\t};\n\n\ttest: ICredentialTestRequest = {\n\t\trequest: {\n\t\t\tbaseURL: 'https://api.anthropic.com',\n\t\t\turl: '/v1/messages',\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'anthropic-version': '2023-06-01',\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tmodel: 'claude-3-haiku-20240307',\n\t\t\t\tmessages: [{ role: 'user', content: 'Hey' }],\n\t\t\t\tmax_tokens: 1,\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,aAAwC;AAAA,EAA9C;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,UAAU;AAAA,QACV,SAAS;AAAA,MACV;AAAA,IACD;AAEA,wBAAqC;AAAA,MACpC,MAAM;AAAA,MACN,YAAY;AAAA,QACX,SAAS;AAAA,UACR,aAAa;AAAA,QACd;AAAA,MACD;AAAA,IACD;AAEA,gBAA+B;AAAA,MAC9B,SAAS;AAAA,QACR,SAAS;AAAA,QACT,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,UACR,qBAAqB;AAAA,QACtB;AAAA,QACA,MAAM;AAAA,UACL,OAAO;AAAA,UACP,UAAU,CAAC,EAAE,MAAM,QAAQ,SAAS,MAAM,CAAC;AAAA,UAC3C,YAAY;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAAA;AACD;","names":[]}
1
+ {"version":3,"sources":["../../credentials/AnthropicApi.credentials.ts"],"sourcesContent":["import type {\n\tIAuthenticateGeneric,\n\tICredentialTestRequest,\n\tICredentialType,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nexport class AnthropicApi implements ICredentialType {\n\tname = 'anthropicApi';\n\n\tdisplayName = 'Anthropic';\n\n\tdocumentationUrl = 'anthropic';\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\trequired: true,\n\t\t\tdefault: '',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Base URL',\n\t\t\tname: 'url',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'https://api.anthropic.com',\n\t\t\tdescription: 'Override the default base URL for the API',\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-api-key': '={{$credentials.apiKey}}',\n\t\t\t},\n\t\t},\n\t};\n\n\ttest: ICredentialTestRequest = {\n\t\trequest: {\n\t\t\tbaseURL: '={{$credentials?.url}}',\n\t\t\turl: '/v1/messages',\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'anthropic-version': '2023-06-01',\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tmodel: 'claude-3-haiku-20240307',\n\t\t\t\tmessages: [{ role: 'user', content: 'Hey' }],\n\t\t\t\tmax_tokens: 1,\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,MAAM,aAAwC;AAAA,EAA9C;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,UAAU;AAAA,QACV,SAAS;AAAA,MACV;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,MACd;AAAA,IACD;AAEA,wBAAqC;AAAA,MACpC,MAAM;AAAA,MACN,YAAY;AAAA,QACX,SAAS;AAAA,UACR,aAAa;AAAA,QACd;AAAA,MACD;AAAA,IACD;AAEA,gBAA+B;AAAA,MAC9B,SAAS;AAAA,QACR,SAAS;AAAA,QACT,KAAK;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,UACR,qBAAqB;AAAA,QACtB;AAAA,QACA,MAAM;AAAA,UACL,OAAO;AAAA,UACP,UAAU,CAAC,EAAE,MAAM,QAAQ,SAAS,MAAM,CAAC;AAAA,UAC3C,YAAY;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAAA;AACD;","names":[]}
@@ -0,0 +1,150 @@
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 AzureEntraCognitiveServicesOAuth2Api_credentials_exports = {};
20
+ __export(AzureEntraCognitiveServicesOAuth2Api_credentials_exports, {
21
+ AzureEntraCognitiveServicesOAuth2Api: () => AzureEntraCognitiveServicesOAuth2Api
22
+ });
23
+ module.exports = __toCommonJS(AzureEntraCognitiveServicesOAuth2Api_credentials_exports);
24
+ const defaultScopes = ["openid", "offline_access"];
25
+ class AzureEntraCognitiveServicesOAuth2Api {
26
+ constructor() {
27
+ this.name = "azureEntraCognitiveServicesOAuth2Api";
28
+ // eslint-disable-next-line n8n-nodes-base/cred-class-field-display-name-missing-oauth2
29
+ this.displayName = "Azure Entra ID (Azure Active Directory) API";
30
+ this.extends = ["oAuth2Api"];
31
+ this.documentationUrl = "azureEntraCognitiveServicesOAuth2Api";
32
+ this.properties = [
33
+ {
34
+ displayName: "Grant Type",
35
+ name: "grantType",
36
+ type: "hidden",
37
+ default: "authorizationCode"
38
+ },
39
+ {
40
+ displayName: "Resource Name",
41
+ name: "resourceName",
42
+ type: "string",
43
+ required: true,
44
+ default: ""
45
+ },
46
+ {
47
+ displayName: "API Version",
48
+ name: "apiVersion",
49
+ type: "string",
50
+ required: true,
51
+ default: "2024-12-01-preview"
52
+ },
53
+ {
54
+ displayName: "Endpoint",
55
+ name: "endpoint",
56
+ type: "string",
57
+ default: void 0,
58
+ placeholder: "https://westeurope.api.cognitive.microsoft.com"
59
+ },
60
+ {
61
+ displayName: "Tenant ID",
62
+ name: "tenantId",
63
+ type: "string",
64
+ default: "common",
65
+ description: 'Enter your Azure Tenant ID (Directory ID) or keep "common" for multi-tenant apps. Using a specific Tenant ID is generally recommended and required for certain authentication flows.',
66
+ placeholder: "e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or common"
67
+ },
68
+ {
69
+ displayName: "Authorization URL",
70
+ name: "authUrl",
71
+ type: "string",
72
+ default: "https://login.microsoftonline.com/$TENANT_ID/oauth2/authorize"
73
+ },
74
+ {
75
+ displayName: "Access Token URL",
76
+ name: "accessTokenUrl",
77
+ type: "string",
78
+ default: "https://login.microsoftonline.com/$TENANT_ID/oauth2/token"
79
+ },
80
+ {
81
+ displayName: "Client ID",
82
+ name: "clientId",
83
+ type: "string",
84
+ required: true,
85
+ default: "",
86
+ description: "Client ID obtained from the Azure AD App Registration"
87
+ },
88
+ {
89
+ displayName: "Client Secret",
90
+ name: "clientSecret",
91
+ type: "string",
92
+ required: true,
93
+ typeOptions: { password: true },
94
+ default: "",
95
+ description: "Client Secret obtained from the Azure AD App Registration"
96
+ },
97
+ {
98
+ displayName: "Additional Body Properties",
99
+ name: "additionalBodyProperties",
100
+ type: "hidden",
101
+ default: '{"grant_type": "client_credentials", "resource": "https://cognitiveservices.azure.com/"}'
102
+ },
103
+ {
104
+ displayName: "Authentication",
105
+ name: "authentication",
106
+ type: "hidden",
107
+ default: "body"
108
+ },
109
+ {
110
+ displayName: "Custom Scopes",
111
+ name: "customScopes",
112
+ type: "boolean",
113
+ default: false,
114
+ description: 'Define custom scopes. You might need this if the default scopes are not sufficient or if you want to minimize permissions. Ensure you include "openid" and "offline_access".'
115
+ },
116
+ {
117
+ displayName: "Auth URI Query Parameters",
118
+ name: "authQueryParameters",
119
+ type: "hidden",
120
+ default: "",
121
+ description: "For some services additional query parameters have to be set which can be defined here",
122
+ placeholder: ""
123
+ },
124
+ {
125
+ displayName: "Enabled Scopes",
126
+ name: "enabledScopes",
127
+ type: "string",
128
+ displayOptions: {
129
+ show: {
130
+ customScopes: [true]
131
+ }
132
+ },
133
+ default: defaultScopes.join(" "),
134
+ placeholder: "openid offline_access",
135
+ description: "Space-separated list of scopes to request."
136
+ },
137
+ {
138
+ displayName: "Scope",
139
+ name: "scope",
140
+ type: "hidden",
141
+ default: '={{ $self.customScopes ? $self.enabledScopes : "' + defaultScopes.join(" ") + '"}}'
142
+ }
143
+ ];
144
+ }
145
+ }
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ AzureEntraCognitiveServicesOAuth2Api
149
+ });
150
+ //# sourceMappingURL=AzureEntraCognitiveServicesOAuth2Api.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.ts"],"sourcesContent":["import type { ICredentialType, INodeProperties } from 'n8n-workflow';\n\nconst defaultScopes = ['openid', 'offline_access'];\n\nexport class AzureEntraCognitiveServicesOAuth2Api implements ICredentialType {\n\tname = 'azureEntraCognitiveServicesOAuth2Api';\n\n\t// eslint-disable-next-line n8n-nodes-base/cred-class-field-display-name-missing-oauth2\n\tdisplayName = 'Azure Entra ID (Azure Active Directory) API';\n\n\textends = ['oAuth2Api'];\n\n\tdocumentationUrl = 'azureEntraCognitiveServicesOAuth2Api';\n\n\tproperties: INodeProperties[] = [\n\t\t{\n\t\t\tdisplayName: 'Grant Type',\n\t\t\tname: 'grantType',\n\t\t\ttype: 'hidden',\n\t\t\tdefault: 'authorizationCode',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Resource Name',\n\t\t\tname: 'resourceName',\n\t\t\ttype: 'string',\n\t\t\trequired: true,\n\t\t\tdefault: '',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'API Version',\n\t\t\tname: 'apiVersion',\n\t\t\ttype: 'string',\n\t\t\trequired: true,\n\t\t\tdefault: '2024-12-01-preview',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Endpoint',\n\t\t\tname: 'endpoint',\n\t\t\ttype: 'string',\n\t\t\tdefault: undefined,\n\t\t\tplaceholder: 'https://westeurope.api.cognitive.microsoft.com',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Tenant ID',\n\t\t\tname: 'tenantId',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'common',\n\t\t\tdescription:\n\t\t\t\t'Enter your Azure Tenant ID (Directory ID) or keep \"common\" for multi-tenant apps. Using a specific Tenant ID is generally recommended and required for certain authentication flows.',\n\t\t\tplaceholder: 'e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or common',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Authorization URL',\n\t\t\tname: 'authUrl',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'https://login.microsoftonline.com/$TENANT_ID/oauth2/authorize',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Access Token URL',\n\t\t\tname: 'accessTokenUrl',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'https://login.microsoftonline.com/$TENANT_ID/oauth2/token',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Client ID',\n\t\t\tname: 'clientId',\n\t\t\ttype: 'string',\n\t\t\trequired: true,\n\t\t\tdefault: '',\n\t\t\tdescription: 'Client ID obtained from the Azure AD App Registration',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Client Secret',\n\t\t\tname: 'clientSecret',\n\t\t\ttype: 'string',\n\t\t\trequired: true,\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\tdescription: 'Client Secret obtained from the Azure AD App Registration',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Additional Body Properties',\n\t\t\tname: 'additionalBodyProperties',\n\t\t\ttype: 'hidden',\n\t\t\tdefault:\n\t\t\t\t'{\"grant_type\": \"client_credentials\", \"resource\": \"https://cognitiveservices.azure.com/\"}',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Authentication',\n\t\t\tname: 'authentication',\n\t\t\ttype: 'hidden',\n\t\t\tdefault: 'body',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Custom Scopes',\n\t\t\tname: 'customScopes',\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t\tdescription:\n\t\t\t\t'Define custom scopes. You might need this if the default scopes are not sufficient or if you want to minimize permissions. Ensure you include \"openid\" and \"offline_access\".',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Auth URI Query Parameters',\n\t\t\tname: 'authQueryParameters',\n\t\t\ttype: 'hidden',\n\t\t\tdefault: '',\n\t\t\tdescription:\n\t\t\t\t'For some services additional query parameters have to be set which can be defined here',\n\t\t\tplaceholder: '',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Enabled Scopes',\n\t\t\tname: 'enabledScopes',\n\t\t\ttype: 'string',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tcustomScopes: [true],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdefault: defaultScopes.join(' '),\n\t\t\tplaceholder: 'openid offline_access',\n\t\t\tdescription: 'Space-separated list of scopes to request.',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Scope',\n\t\t\tname: 'scope',\n\t\t\ttype: 'hidden',\n\t\t\tdefault: '={{ $self.customScopes ? $self.enabledScopes : \"' + defaultScopes.join(' ') + '\"}}',\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,gBAAgB,CAAC,UAAU,gBAAgB;A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A,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,MACV;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aACC;AAAA,MACF;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aACC;AAAA,QACD,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,gBAAgB;AAAA,UACf,MAAM;AAAA,YACL,cAAc,CAAC,IAAI;AAAA,UACpB;AAAA,QACD;AAAA,QACA,SAAS,cAAc,KAAK,GAAG;AAAA,QAC/B,aAAa;AAAA,QACb,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS,qDAAqD,cAAc,KAAK,GAAG,IAAI;AAAA,MACzF;AAAA,IACD;AAAA;AACD;","names":[]}
@@ -14,6 +14,16 @@
14
14
  "lmChatAzureOpenAi"
15
15
  ]
16
16
  },
17
+ "azureEntraCognitiveServicesOAuth2Api": {
18
+ "className": "AzureEntraCognitiveServicesOAuth2Api",
19
+ "sourcePath": "dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js",
20
+ "extends": [
21
+ "oAuth2Api"
22
+ ],
23
+ "supportedNodes": [
24
+ "lmChatAzureOpenAi"
25
+ ]
26
+ },
17
27
  "cohereApi": {
18
28
  "className": "CohereApi",
19
29
  "sourcePath": "dist/credentials/CohereApi.credentials.js",
@@ -269,7 +269,10 @@ class LmChatAnthropic {
269
269
  };
270
270
  }
271
271
  async supplyData(itemIndex) {
272
- const credentials = await this.getCredentials("anthropicApi");
272
+ const credentials = await this.getCredentials(
273
+ "anthropicApi"
274
+ );
275
+ const baseURL = credentials.url ?? "https://api.anthropic.com";
273
276
  const version = this.getNode().typeVersion;
274
277
  const modelName = version >= 1.3 ? this.getNodeParameter("model.value", itemIndex) : this.getNodeParameter("model", itemIndex);
275
278
  const options = this.getNodeParameter("options", itemIndex, {});
@@ -307,6 +310,7 @@ class LmChatAnthropic {
307
310
  const model = new import_anthropic.ChatAnthropic({
308
311
  anthropicApiKey: credentials.apiKey,
309
312
  modelName,
313
+ anthropicApiUrl: baseURL,
310
314
  maxTokens: options.maxTokensToSample,
311
315
  temperature: options.temperature,
312
316
  topK: options.topK,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/llms/LMChatAnthropic/LmChatAnthropic.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\n\nimport { ChatAnthropic } from '@langchain/anthropic';\nimport type { LLMResult } from '@langchain/core/outputs';\nimport {\n\tNodeConnectionTypes,\n\ttype INodePropertyOptions,\n\ttype INodeProperties,\n\ttype ISupplyDataFunctions,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { searchModels } from './methods/searchModels';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nconst modelField: INodeProperties = {\n\tdisplayName: 'Model',\n\tname: 'model',\n\ttype: 'options',\n\t// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items\n\toptions: [\n\t\t{\n\t\t\tname: 'Claude 3.5 Sonnet(20241022)',\n\t\t\tvalue: 'claude-3-5-sonnet-20241022',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3 Opus(20240229)',\n\t\t\tvalue: 'claude-3-opus-20240229',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3.5 Sonnet(20240620)',\n\t\t\tvalue: 'claude-3-5-sonnet-20240620',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3 Sonnet(20240229)',\n\t\t\tvalue: 'claude-3-sonnet-20240229',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3.5 Haiku(20241022)',\n\t\t\tvalue: 'claude-3-5-haiku-20241022',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3 Haiku(20240307)',\n\t\t\tvalue: 'claude-3-haiku-20240307',\n\t\t},\n\t\t{\n\t\t\tname: 'LEGACY: Claude 2',\n\t\t\tvalue: 'claude-2',\n\t\t},\n\t\t{\n\t\t\tname: 'LEGACY: Claude 2.1',\n\t\t\tvalue: 'claude-2.1',\n\t\t},\n\t\t{\n\t\t\tname: 'LEGACY: Claude Instant 1.2',\n\t\t\tvalue: 'claude-instant-1.2',\n\t\t},\n\t\t{\n\t\t\tname: 'LEGACY: Claude Instant 1',\n\t\t\tvalue: 'claude-instant-1',\n\t\t},\n\t],\n\tdescription:\n\t\t'The model which will generate the completion. <a href=\"https://docs.anthropic.com/claude/docs/models-overview\">Learn more</a>.',\n\tdefault: 'claude-2',\n};\n\nconst MIN_THINKING_BUDGET = 1024;\nconst DEFAULT_MAX_TOKENS = 4096;\nexport class LmChatAnthropic implements INodeType {\n\tmethods = {\n\t\tlistSearch: {\n\t\t\tsearchModels,\n\t\t},\n\t};\n\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Anthropic Chat Model',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-name-miscased\n\t\tname: 'lmChatAnthropic',\n\t\ticon: 'file:anthropic.svg',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdefaultVersion: 1.3,\n\t\tdescription: 'Language Model Anthropic',\n\t\tdefaults: {\n\t\t\tname: 'Anthropic Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\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.lmchatanthropic/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\talias: ['claude', 'sonnet', 'opus'],\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'anthropicApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiChain]),\n\t\t\t{\n\t\t\t\t...modelField,\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...modelField,\n\t\t\t\tdefault: 'claude-3-sonnet-20240229',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.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...modelField,\n\t\t\t\tdefault: 'claude-3-5-sonnet-20240620',\n\t\t\t\toptions: (modelField.options ?? []).filter(\n\t\t\t\t\t(o): o is INodePropertyOptions => 'name' in o && !o.name.toString().startsWith('LEGACY'),\n\t\t\t\t),\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: {\n\t\t\t\t\tmode: 'list',\n\t\t\t\t\tvalue: 'claude-3-7-sonnet-20250219',\n\t\t\t\t\tcachedResultName: 'Claude 3.7 Sonnet',\n\t\t\t\t},\n\t\t\t\trequired: true,\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\tplaceholder: 'Select a model...',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'searchModels',\n\t\t\t\t\t\t\tsearchable: true,\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: 'ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tplaceholder: 'Claude Sonnet',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdescription:\n\t\t\t\t\t'The model. Choose from the list, or specify an ID. <a href=\"https://docs.anthropic.com/claude/docs/models-overview\">Learn more</a>.',\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\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: 'Maximum Number of Tokens',\n\t\t\t\t\t\tname: 'maxTokensToSample',\n\t\t\t\t\t\tdefault: DEFAULT_MAX_TOKENS,\n\t\t\t\t\t\tdescription: 'The maximum number of tokens to generate in the completion',\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: 'Sampling Temperature',\n\t\t\t\t\t\tname: 'temperature',\n\t\t\t\t\t\tdefault: 0.7,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\tthinking: [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\tdisplayName: 'Top K',\n\t\t\t\t\t\tname: 'topK',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: -1, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Used to remove \"long tail\" low probability responses. Defaults to -1, which disables it.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\tthinking: [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\tdisplayName: 'Top P',\n\t\t\t\t\t\tname: 'topP',\n\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\tthinking: [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\tdisplayName: 'Enable Thinking',\n\t\t\t\t\t\tname: 'thinking',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tdescription: 'Whether to enable thinking mode for the model',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Thinking Budget (Tokens)',\n\t\t\t\t\t\tname: 'thinkingBudget',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdefault: MIN_THINKING_BUDGET,\n\t\t\t\t\t\tdescription: 'The maximum number of tokens to use for thinking',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\tthinking: [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\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials('anthropicApi');\n\n\t\tconst version = this.getNode().typeVersion;\n\t\tconst modelName =\n\t\t\tversion >= 1.3\n\t\t\t\t? (this.getNodeParameter('model.value', itemIndex) as string)\n\t\t\t\t: (this.getNodeParameter('model', itemIndex) as string);\n\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tmaxTokensToSample?: number;\n\t\t\ttemperature: number;\n\t\t\ttopK?: number;\n\t\t\ttopP?: number;\n\t\t\tthinking?: boolean;\n\t\t\tthinkingBudget?: number;\n\t\t};\n\t\tlet invocationKwargs = {};\n\n\t\tconst tokensUsageParser = (llmOutput: LLMResult['llmOutput']) => {\n\t\t\tconst usage = (llmOutput?.usage as { input_tokens: number; output_tokens: number }) ?? {\n\t\t\t\tinput_tokens: 0,\n\t\t\t\toutput_tokens: 0,\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tcompletionTokens: usage.output_tokens,\n\t\t\t\tpromptTokens: usage.input_tokens,\n\t\t\t\ttotalTokens: usage.input_tokens + usage.output_tokens,\n\t\t\t};\n\t\t};\n\n\t\tif (options.thinking) {\n\t\t\tinvocationKwargs = {\n\t\t\t\tthinking: {\n\t\t\t\t\ttype: 'enabled',\n\t\t\t\t\t// If thinking is enabled, we need to set a budget.\n\t\t\t\t\t// We fallback to 1024 as that is the minimum\n\t\t\t\t\tbudget_tokens: options.thinkingBudget ?? MIN_THINKING_BUDGET,\n\t\t\t\t},\n\t\t\t\t// The default Langchain max_tokens is -1 (no limit) but Anthropic requires a number\n\t\t\t\t// higher than budget_tokens\n\t\t\t\tmax_tokens: options.maxTokensToSample ?? DEFAULT_MAX_TOKENS,\n\t\t\t\t// These need to be unset when thinking is enabled.\n\t\t\t\t// Because the invocationKwargs will override the model options\n\t\t\t\t// we can pass options to the model and then override them here\n\t\t\t\ttop_k: undefined,\n\t\t\t\ttop_p: undefined,\n\t\t\t\ttemperature: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst model = new ChatAnthropic({\n\t\t\tanthropicApiKey: credentials.apiKey as string,\n\t\t\tmodelName,\n\t\t\tmaxTokens: options.maxTokensToSample,\n\t\t\ttemperature: options.temperature,\n\t\t\ttopK: options.topK,\n\t\t\ttopP: options.topP,\n\t\t\tcallbacks: [new N8nLlmTracing(this, { tokensUsageParser })],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t\tinvocationKwargs,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAA8B;AAE9B,0BAQO;AAEP,0BAA6C;AAE7C,0BAA6B;AAC7B,wCAA+C;AAC/C,2BAA8B;AAE9B,MAAM,aAA8B;AAAA,EACnC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA;AAAA,EAEN,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AAAA,M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;AAAA,MACd,MAAM,QAAQ;AAAA,MACd,WAAW,CAAC,IAAI,mCAAc,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAAA,MAC1D,qBAAiB,kEAA+B,IAAI;AAAA,MACpD;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/llms/LMChatAnthropic/LmChatAnthropic.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\n\nimport { ChatAnthropic } from '@langchain/anthropic';\nimport type { LLMResult } from '@langchain/core/outputs';\nimport {\n\tNodeConnectionTypes,\n\ttype INodePropertyOptions,\n\ttype INodeProperties,\n\ttype ISupplyDataFunctions,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { searchModels } from './methods/searchModels';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nconst modelField: INodeProperties = {\n\tdisplayName: 'Model',\n\tname: 'model',\n\ttype: 'options',\n\t// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items\n\toptions: [\n\t\t{\n\t\t\tname: 'Claude 3.5 Sonnet(20241022)',\n\t\t\tvalue: 'claude-3-5-sonnet-20241022',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3 Opus(20240229)',\n\t\t\tvalue: 'claude-3-opus-20240229',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3.5 Sonnet(20240620)',\n\t\t\tvalue: 'claude-3-5-sonnet-20240620',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3 Sonnet(20240229)',\n\t\t\tvalue: 'claude-3-sonnet-20240229',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3.5 Haiku(20241022)',\n\t\t\tvalue: 'claude-3-5-haiku-20241022',\n\t\t},\n\t\t{\n\t\t\tname: 'Claude 3 Haiku(20240307)',\n\t\t\tvalue: 'claude-3-haiku-20240307',\n\t\t},\n\t\t{\n\t\t\tname: 'LEGACY: Claude 2',\n\t\t\tvalue: 'claude-2',\n\t\t},\n\t\t{\n\t\t\tname: 'LEGACY: Claude 2.1',\n\t\t\tvalue: 'claude-2.1',\n\t\t},\n\t\t{\n\t\t\tname: 'LEGACY: Claude Instant 1.2',\n\t\t\tvalue: 'claude-instant-1.2',\n\t\t},\n\t\t{\n\t\t\tname: 'LEGACY: Claude Instant 1',\n\t\t\tvalue: 'claude-instant-1',\n\t\t},\n\t],\n\tdescription:\n\t\t'The model which will generate the completion. <a href=\"https://docs.anthropic.com/claude/docs/models-overview\">Learn more</a>.',\n\tdefault: 'claude-2',\n};\n\nconst MIN_THINKING_BUDGET = 1024;\nconst DEFAULT_MAX_TOKENS = 4096;\nexport class LmChatAnthropic implements INodeType {\n\tmethods = {\n\t\tlistSearch: {\n\t\t\tsearchModels,\n\t\t},\n\t};\n\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Anthropic Chat Model',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-name-miscased\n\t\tname: 'lmChatAnthropic',\n\t\ticon: 'file:anthropic.svg',\n\t\tgroup: ['transform'],\n\t\tversion: [1, 1.1, 1.2, 1.3],\n\t\tdefaultVersion: 1.3,\n\t\tdescription: 'Language Model Anthropic',\n\t\tdefaults: {\n\t\t\tname: 'Anthropic Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\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.lmchatanthropic/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\talias: ['claude', 'sonnet', 'opus'],\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'anthropicApi',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiChain]),\n\t\t\t{\n\t\t\t\t...modelField,\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...modelField,\n\t\t\t\tdefault: 'claude-3-sonnet-20240229',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [1.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...modelField,\n\t\t\t\tdefault: 'claude-3-5-sonnet-20240620',\n\t\t\t\toptions: (modelField.options ?? []).filter(\n\t\t\t\t\t(o): o is INodePropertyOptions => 'name' in o && !o.name.toString().startsWith('LEGACY'),\n\t\t\t\t),\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'@version': [{ _cnd: { lte: 1.2 } }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Model',\n\t\t\t\tname: 'model',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: {\n\t\t\t\t\tmode: 'list',\n\t\t\t\t\tvalue: 'claude-3-7-sonnet-20250219',\n\t\t\t\t\tcachedResultName: 'Claude 3.7 Sonnet',\n\t\t\t\t},\n\t\t\t\trequired: true,\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\tplaceholder: 'Select a model...',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'searchModels',\n\t\t\t\t\t\t\tsearchable: true,\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: 'ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tplaceholder: 'Claude Sonnet',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdescription:\n\t\t\t\t\t'The model. Choose from the list, or specify an ID. <a href=\"https://docs.anthropic.com/claude/docs/models-overview\">Learn more</a>.',\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\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: 'Maximum Number of Tokens',\n\t\t\t\t\t\tname: 'maxTokensToSample',\n\t\t\t\t\t\tdefault: DEFAULT_MAX_TOKENS,\n\t\t\t\t\t\tdescription: 'The maximum number of tokens to generate in the completion',\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: 'Sampling Temperature',\n\t\t\t\t\t\tname: 'temperature',\n\t\t\t\t\t\tdefault: 0.7,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\tthinking: [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\tdisplayName: 'Top K',\n\t\t\t\t\t\tname: 'topK',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: -1, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Used to remove \"long tail\" low probability responses. Defaults to -1, which disables it.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\tthinking: [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\tdisplayName: 'Top P',\n\t\t\t\t\t\tname: 'topP',\n\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\tthinking: [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\tdisplayName: 'Enable Thinking',\n\t\t\t\t\t\tname: 'thinking',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tdescription: 'Whether to enable thinking mode for the model',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Thinking Budget (Tokens)',\n\t\t\t\t\t\tname: 'thinkingBudget',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\tdefault: MIN_THINKING_BUDGET,\n\t\t\t\t\t\tdescription: 'The maximum number of tokens to use for thinking',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\tthinking: [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\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst credentials = await this.getCredentials<{ url?: string; apiKey?: string }>(\n\t\t\t'anthropicApi',\n\t\t);\n\t\tconst baseURL = credentials.url ?? 'https://api.anthropic.com';\n\t\tconst version = this.getNode().typeVersion;\n\t\tconst modelName =\n\t\t\tversion >= 1.3\n\t\t\t\t? (this.getNodeParameter('model.value', itemIndex) as string)\n\t\t\t\t: (this.getNodeParameter('model', itemIndex) as string);\n\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tmaxTokensToSample?: number;\n\t\t\ttemperature: number;\n\t\t\ttopK?: number;\n\t\t\ttopP?: number;\n\t\t\tthinking?: boolean;\n\t\t\tthinkingBudget?: number;\n\t\t};\n\t\tlet invocationKwargs = {};\n\n\t\tconst tokensUsageParser = (llmOutput: LLMResult['llmOutput']) => {\n\t\t\tconst usage = (llmOutput?.usage as { input_tokens: number; output_tokens: number }) ?? {\n\t\t\t\tinput_tokens: 0,\n\t\t\t\toutput_tokens: 0,\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tcompletionTokens: usage.output_tokens,\n\t\t\t\tpromptTokens: usage.input_tokens,\n\t\t\t\ttotalTokens: usage.input_tokens + usage.output_tokens,\n\t\t\t};\n\t\t};\n\n\t\tif (options.thinking) {\n\t\t\tinvocationKwargs = {\n\t\t\t\tthinking: {\n\t\t\t\t\ttype: 'enabled',\n\t\t\t\t\t// If thinking is enabled, we need to set a budget.\n\t\t\t\t\t// We fallback to 1024 as that is the minimum\n\t\t\t\t\tbudget_tokens: options.thinkingBudget ?? MIN_THINKING_BUDGET,\n\t\t\t\t},\n\t\t\t\t// The default Langchain max_tokens is -1 (no limit) but Anthropic requires a number\n\t\t\t\t// higher than budget_tokens\n\t\t\t\tmax_tokens: options.maxTokensToSample ?? DEFAULT_MAX_TOKENS,\n\t\t\t\t// These need to be unset when thinking is enabled.\n\t\t\t\t// Because the invocationKwargs will override the model options\n\t\t\t\t// we can pass options to the model and then override them here\n\t\t\t\ttop_k: undefined,\n\t\t\t\ttop_p: undefined,\n\t\t\t\ttemperature: undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst model = new ChatAnthropic({\n\t\t\tanthropicApiKey: credentials.apiKey,\n\t\t\tmodelName,\n\t\t\tanthropicApiUrl: baseURL,\n\t\t\tmaxTokens: options.maxTokensToSample,\n\t\t\ttemperature: options.temperature,\n\t\t\ttopK: options.topK,\n\t\t\ttopP: options.topP,\n\t\t\tcallbacks: [new N8nLlmTracing(this, { tokensUsageParser })],\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t\tinvocationKwargs,\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAA8B;AAE9B,0BAQO;AAEP,0BAA6C;AAE7C,0BAA6B;AAC7B,wCAA+C;AAC/C,2BAA8B;AAE9B,MAAM,aAA8B;AAAA,EACnC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA;AAAA,EAEN,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AA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B,WAAW,QAAQ;AAAA,MACnB,aAAa,QAAQ;AAAA,MACrB,MAAM,QAAQ;AAAA,MACd,MAAM,QAAQ;AAAA,MACd,WAAW,CAAC,IAAI,mCAAc,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAAA,MAC1D,qBAAiB,kEAA+B,IAAI;AAAA,MACpD;AAAA,IACD,CAAC;AAED,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
@@ -22,8 +22,10 @@ __export(searchModels_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(searchModels_exports);
24
24
  async function searchModels(filter) {
25
+ const credentials = await this.getCredentials("anthropicApi");
26
+ const baseURL = credentials.url ?? "https://api.anthropic.com";
25
27
  const response = await this.helpers.httpRequestWithAuthentication.call(this, "anthropicApi", {
26
- url: "https://api.anthropic.com/v1/models",
28
+ url: `${baseURL}/v1/models`,
27
29
  headers: {
28
30
  "anthropic-version": "2023-06-01"
29
31
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../nodes/llms/LMChatAnthropic/methods/searchModels.ts"],"sourcesContent":["import type {\n\tILoadOptionsFunctions,\n\tINodeListSearchItems,\n\tINodeListSearchResult,\n} from 'n8n-workflow';\n\nexport interface AnthropicModel {\n\tid: string;\n\tdisplay_name: string;\n\ttype: string;\n\tcreated_at: string;\n}\n\nexport async function searchModels(\n\tthis: ILoadOptionsFunctions,\n\tfilter?: string,\n): Promise<INodeListSearchResult> {\n\tconst response = (await this.helpers.httpRequestWithAuthentication.call(this, 'anthropicApi', {\n\t\turl: 'https://api.anthropic.com/v1/models',\n\t\theaders: {\n\t\t\t'anthropic-version': '2023-06-01',\n\t\t},\n\t})) as { data: AnthropicModel[] };\n\n\tconst models = response.data || [];\n\tlet results: INodeListSearchItems[] = [];\n\n\tif (filter) {\n\t\tfor (const model of models) {\n\t\t\tif (model.id.toLowerCase().includes(filter.toLowerCase())) {\n\t\t\t\tresults.push({\n\t\t\t\t\tname: model.display_name,\n\t\t\t\t\tvalue: model.id,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t} else {\n\t\tresults = models.map((model) => ({\n\t\t\tname: model.display_name,\n\t\t\tvalue: model.id,\n\t\t}));\n\t}\n\n\t// Sort models with more recent ones first (claude-3 before claude-2)\n\tresults = results.sort((a, b) => {\n\t\tconst modelA = models.find((m) => m.id === a.value);\n\t\tconst modelB = models.find((m) => m.id === b.value);\n\n\t\tif (!modelA || !modelB) return 0;\n\n\t\t// Sort by created_at date, most recent first\n\t\tconst dateA = new Date(modelA.created_at);\n\t\tconst dateB = new Date(modelB.created_at);\n\t\treturn dateB.getTime() - dateA.getTime();\n\t});\n\n\treturn {\n\t\tresults,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,eAAsB,aAErB,QACiC;AACjC,QAAM,WAAY,MAAM,KAAK,QAAQ,8BAA8B,KAAK,MAAM,gBAAgB;AAAA,IAC7F,KAAK;AAAA,IACL,SAAS;AAAA,MACR,qBAAqB;AAAA,IACtB;AAAA,EACD,CAAC;AAED,QAAM,SAAS,SAAS,QAAQ,CAAC;AACjC,MAAI,UAAkC,CAAC;AAEvC,MAAI,QAAQ;AACX,eAAW,SAAS,QAAQ;AAC3B,UAAI,MAAM,GAAG,YAAY,EAAE,SAAS,OAAO,YAAY,CAAC,GAAG;AAC1D,gBAAQ,KAAK;AAAA,UACZ,MAAM,MAAM;AAAA,UACZ,OAAO,MAAM;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD,OAAO;AACN,cAAU,OAAO,IAAI,CAAC,WAAW;AAAA,MAChC,MAAM,MAAM;AAAA,MACZ,OAAO,MAAM;AAAA,IACd,EAAE;AAAA,EACH;AAGA,YAAU,QAAQ,KAAK,CAAC,GAAG,MAAM;AAChC,UAAM,SAAS,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAClD,UAAM,SAAS,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAElD,QAAI,CAAC,UAAU,CAAC,OAAQ,QAAO;AAG/B,UAAM,QAAQ,IAAI,KAAK,OAAO,UAAU;AACxC,UAAM,QAAQ,IAAI,KAAK,OAAO,UAAU;AACxC,WAAO,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAAA,EACxC,CAAC;AAED,SAAO;AAAA,IACN;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../../nodes/llms/LMChatAnthropic/methods/searchModels.ts"],"sourcesContent":["import type {\n\tILoadOptionsFunctions,\n\tINodeListSearchItems,\n\tINodeListSearchResult,\n} from 'n8n-workflow';\n\nexport interface AnthropicModel {\n\tid: string;\n\tdisplay_name: string;\n\ttype: string;\n\tcreated_at: string;\n}\n\nexport async function searchModels(\n\tthis: ILoadOptionsFunctions,\n\tfilter?: string,\n): Promise<INodeListSearchResult> {\n\tconst credentials = await this.getCredentials<{ url?: string }>('anthropicApi');\n\n\tconst baseURL = credentials.url ?? 'https://api.anthropic.com';\n\tconst response = (await this.helpers.httpRequestWithAuthentication.call(this, 'anthropicApi', {\n\t\turl: `${baseURL}/v1/models`,\n\t\theaders: {\n\t\t\t'anthropic-version': '2023-06-01',\n\t\t},\n\t})) as { data: AnthropicModel[] };\n\n\tconst models = response.data || [];\n\tlet results: INodeListSearchItems[] = [];\n\n\tif (filter) {\n\t\tfor (const model of models) {\n\t\t\tif (model.id.toLowerCase().includes(filter.toLowerCase())) {\n\t\t\t\tresults.push({\n\t\t\t\t\tname: model.display_name,\n\t\t\t\t\tvalue: model.id,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t} else {\n\t\tresults = models.map((model) => ({\n\t\t\tname: model.display_name,\n\t\t\tvalue: model.id,\n\t\t}));\n\t}\n\n\t// Sort models with more recent ones first (claude-3 before claude-2)\n\tresults = results.sort((a, b) => {\n\t\tconst modelA = models.find((m) => m.id === a.value);\n\t\tconst modelB = models.find((m) => m.id === b.value);\n\n\t\tif (!modelA || !modelB) return 0;\n\n\t\t// Sort by created_at date, most recent first\n\t\tconst dateA = new Date(modelA.created_at);\n\t\tconst dateB = new Date(modelB.created_at);\n\t\treturn dateB.getTime() - dateA.getTime();\n\t});\n\n\treturn {\n\t\tresults,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,eAAsB,aAErB,QACiC;AACjC,QAAM,cAAc,MAAM,KAAK,eAAiC,cAAc;AAE9E,QAAM,UAAU,YAAY,OAAO;AACnC,QAAM,WAAY,MAAM,KAAK,QAAQ,8BAA8B,KAAK,MAAM,gBAAgB;AAAA,IAC7F,KAAK,GAAG,OAAO;AAAA,IACf,SAAS;AAAA,MACR,qBAAqB;AAAA,IACtB;AAAA,EACD,CAAC;AAED,QAAM,SAAS,SAAS,QAAQ,CAAC;AACjC,MAAI,UAAkC,CAAC;AAEvC,MAAI,QAAQ;AACX,eAAW,SAAS,QAAQ;AAC3B,UAAI,MAAM,GAAG,YAAY,EAAE,SAAS,OAAO,YAAY,CAAC,GAAG;AAC1D,gBAAQ,KAAK;AAAA,UACZ,MAAM,MAAM;AAAA,UACZ,OAAO,MAAM;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD;AAAA,EACD,OAAO;AACN,cAAU,OAAO,IAAI,CAAC,WAAW;AAAA,MAChC,MAAM,MAAM;AAAA,MACZ,OAAO,MAAM;AAAA,IACd,EAAE;AAAA,EACH;AAGA,YAAU,QAAQ,KAAK,CAAC,GAAG,MAAM;AAChC,UAAM,SAAS,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAClD,UAAM,SAAS,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAElD,QAAI,CAAC,UAAU,CAAC,OAAQ,QAAO;AAG/B,UAAM,QAAQ,IAAI,KAAK,OAAO,UAAU;AACxC,UAAM,QAAQ,IAAI,KAAK,OAAO,UAAU;AACxC,WAAO,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAAA,EACxC,CAAC;AAED,SAAO;AAAA,IACN;AAAA,EACD;AACD;","names":[]}
@@ -23,7 +23,10 @@ __export(LmChatAzureOpenAi_node_exports, {
23
23
  module.exports = __toCommonJS(LmChatAzureOpenAi_node_exports);
24
24
  var import_openai = require("@langchain/openai");
25
25
  var import_n8n_workflow = require("n8n-workflow");
26
- var import_sharedFields = require("../../../utils/sharedFields");
26
+ var import_api_key = require("./credentials/api-key");
27
+ var import_oauth2 = require("./credentials/oauth2");
28
+ var import_properties = require("./properties");
29
+ var import_types = require("./types");
27
30
  var import_n8nLlmFailedAttemptHandler = require("../n8nLlmFailedAttemptHandler");
28
31
  var import_N8nLlmTracing = require("../N8nLlmTracing");
29
32
  class LmChatAzureOpenAi {
@@ -61,139 +64,76 @@ class LmChatAzureOpenAi {
61
64
  credentials: [
62
65
  {
63
66
  name: "azureOpenAiApi",
64
- required: true
65
- }
66
- ],
67
- properties: [
68
- (0, import_sharedFields.getConnectionHintNoticeField)([import_n8n_workflow.NodeConnectionTypes.AiChain, import_n8n_workflow.NodeConnectionTypes.AiAgent]),
69
- {
70
- displayName: 'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',
71
- name: "notice",
72
- type: "notice",
73
- default: "",
67
+ required: true,
74
68
  displayOptions: {
75
69
  show: {
76
- "/options.responseFormat": ["json_object"]
70
+ authentication: [import_types.AuthenticationType.ApiKey]
77
71
  }
78
72
  }
79
73
  },
80
74
  {
81
- displayName: "Model (Deployment) Name",
82
- name: "model",
83
- type: "string",
84
- description: "The name of the model(deployment) to use",
85
- default: ""
86
- },
87
- {
88
- displayName: "Options",
89
- name: "options",
90
- placeholder: "Add Option",
91
- description: "Additional options to add",
92
- type: "collection",
93
- default: {},
94
- options: [
95
- {
96
- displayName: "Frequency Penalty",
97
- name: "frequencyPenalty",
98
- default: 0,
99
- typeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },
100
- description: "Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim",
101
- type: "number"
102
- },
103
- {
104
- displayName: "Maximum Number of Tokens",
105
- name: "maxTokens",
106
- default: -1,
107
- description: "The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).",
108
- type: "number",
109
- typeOptions: {
110
- maxValue: 32768
111
- }
112
- },
113
- {
114
- displayName: "Response Format",
115
- name: "responseFormat",
116
- default: "text",
117
- type: "options",
118
- options: [
119
- {
120
- name: "Text",
121
- value: "text",
122
- description: "Regular text response"
123
- },
124
- {
125
- name: "JSON",
126
- value: "json_object",
127
- description: "Enables JSON mode, which should guarantee the message the model generates is valid JSON"
128
- }
129
- ]
130
- },
131
- {
132
- displayName: "Presence Penalty",
133
- name: "presencePenalty",
134
- default: 0,
135
- typeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },
136
- description: "Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics",
137
- type: "number"
138
- },
139
- {
140
- displayName: "Sampling Temperature",
141
- name: "temperature",
142
- default: 0.7,
143
- typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
144
- description: "Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.",
145
- type: "number"
146
- },
147
- {
148
- displayName: "Timeout",
149
- name: "timeout",
150
- default: 6e4,
151
- description: "Maximum amount of time a request is allowed to take in milliseconds",
152
- type: "number"
153
- },
154
- {
155
- displayName: "Max Retries",
156
- name: "maxRetries",
157
- default: 2,
158
- description: "Maximum number of retries to attempt",
159
- type: "number"
160
- },
161
- {
162
- displayName: "Top P",
163
- name: "topP",
164
- default: 1,
165
- typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
166
- description: "Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.",
167
- type: "number"
75
+ name: "azureEntraCognitiveServicesOAuth2Api",
76
+ required: true,
77
+ displayOptions: {
78
+ show: {
79
+ authentication: [import_types.AuthenticationType.EntraOAuth2]
168
80
  }
169
- ]
81
+ }
170
82
  }
171
- ]
83
+ ],
84
+ properties: import_properties.properties
172
85
  };
173
86
  }
174
87
  async supplyData(itemIndex) {
175
- const credentials = await this.getCredentials("azureOpenAiApi");
176
- const modelName = this.getNodeParameter("model", itemIndex);
177
- const options = this.getNodeParameter("options", itemIndex, {});
178
- const model = new import_openai.AzureChatOpenAI({
179
- azureOpenAIApiDeploymentName: modelName,
180
- // instance name only needed to set base url
181
- azureOpenAIApiInstanceName: !credentials.endpoint ? credentials.resourceName : void 0,
182
- azureOpenAIApiKey: credentials.apiKey,
183
- azureOpenAIApiVersion: credentials.apiVersion,
184
- azureOpenAIEndpoint: credentials.endpoint,
185
- ...options,
186
- timeout: options.timeout ?? 6e4,
187
- maxRetries: options.maxRetries ?? 2,
188
- callbacks: [new import_N8nLlmTracing.N8nLlmTracing(this)],
189
- modelKwargs: options.responseFormat ? {
190
- response_format: { type: options.responseFormat }
191
- } : void 0,
192
- onFailedAttempt: (0, import_n8nLlmFailedAttemptHandler.makeN8nLlmFailedAttemptHandler)(this)
193
- });
194
- return {
195
- response: model
196
- };
88
+ try {
89
+ const authenticationMethod = this.getNodeParameter(
90
+ "authentication",
91
+ itemIndex
92
+ );
93
+ const modelName = this.getNodeParameter("model", itemIndex);
94
+ const options = this.getNodeParameter("options", itemIndex, {});
95
+ let modelConfig;
96
+ switch (authenticationMethod) {
97
+ case import_types.AuthenticationType.ApiKey:
98
+ modelConfig = await import_api_key.setupApiKeyAuthentication.call(this, "azureOpenAiApi");
99
+ break;
100
+ case import_types.AuthenticationType.EntraOAuth2:
101
+ modelConfig = await import_oauth2.setupOAuth2Authentication.call(
102
+ this,
103
+ "azureEntraCognitiveServicesOAuth2Api"
104
+ );
105
+ break;
106
+ default:
107
+ throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Invalid authentication method");
108
+ }
109
+ this.logger.info(`Instantiating AzureChatOpenAI model with deployment: ${modelName}`);
110
+ const model = new import_openai.AzureChatOpenAI({
111
+ azureOpenAIApiDeploymentName: modelName,
112
+ ...modelConfig,
113
+ ...options,
114
+ timeout: options.timeout ?? 6e4,
115
+ maxRetries: options.maxRetries ?? 2,
116
+ callbacks: [new import_N8nLlmTracing.N8nLlmTracing(this)],
117
+ modelKwargs: options.responseFormat ? {
118
+ response_format: { type: options.responseFormat }
119
+ } : void 0,
120
+ onFailedAttempt: (0, import_n8nLlmFailedAttemptHandler.makeN8nLlmFailedAttemptHandler)(this)
121
+ });
122
+ this.logger.info(`Azure OpenAI client initialized for deployment: ${modelName}`);
123
+ return {
124
+ response: model
125
+ };
126
+ } catch (error) {
127
+ this.logger.error(`Error in LmChatAzureOpenAi.supplyData: ${error.message}`, error);
128
+ if (error instanceof import_n8n_workflow.NodeOperationError) {
129
+ throw error;
130
+ }
131
+ throw new import_n8n_workflow.NodeOperationError(
132
+ this.getNode(),
133
+ `Failed to initialize Azure OpenAI client: ${error.message}`,
134
+ error
135
+ );
136
+ }
197
137
  }
198
138
  }
199
139
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { AzureChatOpenAI } from '@langchain/openai';\nimport {\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmChatAzureOpenAi implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Azure OpenAI Chat Model',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-name-miscased\n\t\tname: 'lmChatAzureOpenAi',\n\t\ticon: 'file:azure.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'For advanced usage with an AI chain',\n\t\tdefaults: {\n\t\t\tname: 'Azure OpenAI Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\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.lmchatazureopenai/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\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\tproperties: [\n\t\t\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'If using JSON response format, you must include word \"json\" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',\n\t\t\t\tname: 'notice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\t'/options.responseFormat': ['json_object'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\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: 'Frequency Penalty',\n\t\t\t\t\t\tname: 'frequencyPenalty',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim\",\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: 'Maximum Number of Tokens',\n\t\t\t\t\t\tname: 'maxTokens',\n\t\t\t\t\t\tdefault: -1,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).',\n\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tmaxValue: 32768,\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: 'Response Format',\n\t\t\t\t\t\tname: 'responseFormat',\n\t\t\t\t\t\tdefault: 'text',\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: 'Text',\n\t\t\t\t\t\t\t\tvalue: 'text',\n\t\t\t\t\t\t\t\tdescription: 'Regular text response',\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: 'JSON',\n\t\t\t\t\t\t\t\tvalue: 'json_object',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'Enables JSON mode, which should guarantee the message the model generates is valid JSON',\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: 'Presence Penalty',\n\t\t\t\t\t\tname: 'presencePenalty',\n\t\t\t\t\t\tdefault: 0,\n\t\t\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics\",\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: 'Sampling Temperature',\n\t\t\t\t\t\tname: 'temperature',\n\t\t\t\t\t\tdefault: 0.7,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',\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: 'Timeout',\n\t\t\t\t\t\tname: 'timeout',\n\t\t\t\t\t\tdefault: 60000,\n\t\t\t\t\t\tdescription: 'Maximum amount of time a request is allowed to take in milliseconds',\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: 'Max Retries',\n\t\t\t\t\t\tname: 'maxRetries',\n\t\t\t\t\t\tdefault: 2,\n\t\t\t\t\t\tdescription: 'Maximum number of retries to attempt',\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: 'Top P',\n\t\t\t\t\t\tname: 'topP',\n\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',\n\t\t\t\t\t\ttype: 'number',\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\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\n\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as {\n\t\t\tfrequencyPenalty?: number;\n\t\t\tmaxTokens?: number;\n\t\t\tmaxRetries: number;\n\t\t\ttimeout: number;\n\t\t\tpresencePenalty?: number;\n\t\t\ttemperature?: number;\n\t\t\ttopP?: number;\n\t\t\tresponseFormat?: 'text' | 'json_object';\n\t\t};\n\n\t\tconst model = new AzureChatOpenAI({\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\tazureOpenAIEndpoint: credentials.endpoint,\n\t\t\t...options,\n\t\t\ttimeout: options.timeout ?? 60000,\n\t\t\tmaxRetries: options.maxRetries ?? 2,\n\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\tmodelKwargs: options.responseFormat\n\t\t\t\t? {\n\t\t\t\t\t\tresponse_format: { type: options.responseFormat },\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t});\n\n\t\treturn {\n\t\t\tresponse: model,\n\t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A,cACC,aAAa;AAAA,cACb,MAAM;AAAA,cACN,SAAS;AAAA,cACT,aAAa,EAAE,UAAU,GAAG,UAAU,GAAG,iBAAiB,EAAE;AAAA,cAC5D,aACC;AAAA,cACD,MAAM;AAAA,YACP;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,WAAuC,WAAwC;AACpF,UAAM,cAAc,MAAM,KAAK,eAK5B,gBAAgB;AAEnB,UAAM,YAAY,KAAK,iBAAiB,SAAS,SAAS;AAC1D,UAAM,UAAU,KAAK,iBAAiB,WAAW,WAAW,CAAC,CAAC;AAW9D,UAAM,QAAQ,IAAI,8BAAgB;AAAA,MACjC,8BAA8B;AAAA;AAAA,MAE9B,4BAA4B,CAAC,YAAY,WAAW,YAAY,eAAe;AAAA,MAC/E,mBAAmB,YAAY;AAAA,MAC/B,uBAAuB,YAAY;AAAA,MACnC,qBAAqB,YAAY;AAAA,MACjC,GAAG;AAAA,MACH,SAAS,QAAQ,WAAW;AAAA,MAC5B,YAAY,QAAQ,cAAc;AAAA,MAClC,WAAW,CAAC,IAAI,mCAAc,IAAI,CAAC;AAAA,MACnC,aAAa,QAAQ,iBAClB;AAAA,QACA,iBAAiB,EAAE,MAAM,QAAQ,eAAe;AAAA,MACjD,IACC;AAAA,MACH,qBAAiB,kEAA+B,IAAI;AAAA,IACrD,CAAC;AAED,WAAO;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;","names":[]}
1
+ {"version":3,"sources":["../../../../nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.ts"],"sourcesContent":["/* eslint-disable n8n-nodes-base/node-execute-block-wrong-error-thrown */\n/* eslint-disable n8n-nodes-base/node-dirname-against-convention */\nimport { AzureChatOpenAI } from '@langchain/openai';\nimport {\n\tNodeOperationError,\n\tNodeConnectionTypes,\n\ttype INodeType,\n\ttype INodeTypeDescription,\n\ttype ISupplyDataFunctions,\n\ttype SupplyData,\n} from 'n8n-workflow';\n\nimport { setupApiKeyAuthentication } from './credentials/api-key';\nimport { setupOAuth2Authentication } from './credentials/oauth2';\nimport { properties } from './properties';\nimport { AuthenticationType } from './types';\nimport type {\n\tAzureOpenAIApiKeyModelConfig,\n\tAzureOpenAIOAuth2ModelConfig,\n\tAzureOpenAIOptions,\n} from './types';\nimport { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';\nimport { N8nLlmTracing } from '../N8nLlmTracing';\n\nexport class LmChatAzureOpenAi implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Azure OpenAI Chat Model',\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-name-miscased\n\t\tname: 'lmChatAzureOpenAi',\n\t\ticon: 'file:azure.svg',\n\t\tgroup: ['transform'],\n\t\tversion: 1,\n\t\tdescription: 'For advanced usage with an AI chain',\n\t\tdefaults: {\n\t\t\tname: 'Azure OpenAI Chat Model',\n\t\t},\n\t\tcodex: {\n\t\t\tcategories: ['AI'],\n\t\t\tsubcategories: {\n\t\t\t\tAI: ['Language Models', 'Root Nodes'],\n\t\t\t\t'Language Models': ['Chat Models (Recommended)'],\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.lmchatazureopenai/',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node\n\t\tinputs: [],\n\t\t// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong\n\t\toutputs: [NodeConnectionTypes.AiLanguageModel],\n\t\toutputNames: ['Model'],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'azureOpenAiApi',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: [AuthenticationType.ApiKey],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'azureEntraCognitiveServicesOAuth2Api',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: [AuthenticationType.EntraOAuth2],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tproperties,\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\ttry {\n\t\t\tconst authenticationMethod = this.getNodeParameter(\n\t\t\t\t'authentication',\n\t\t\t\titemIndex,\n\t\t\t) as AuthenticationType;\n\t\t\tconst modelName = this.getNodeParameter('model', itemIndex) as string;\n\t\t\tconst options = this.getNodeParameter('options', itemIndex, {}) as AzureOpenAIOptions;\n\n\t\t\t// Set up Authentication based on selection and get configuration\n\t\t\tlet modelConfig: AzureOpenAIApiKeyModelConfig | AzureOpenAIOAuth2ModelConfig;\n\t\t\tswitch (authenticationMethod) {\n\t\t\t\tcase AuthenticationType.ApiKey:\n\t\t\t\t\tmodelConfig = await setupApiKeyAuthentication.call(this, 'azureOpenAiApi');\n\t\t\t\t\tbreak;\n\t\t\t\tcase AuthenticationType.EntraOAuth2:\n\t\t\t\t\tmodelConfig = await setupOAuth2Authentication.call(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\t'azureEntraCognitiveServicesOAuth2Api',\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Invalid authentication method');\n\t\t\t}\n\n\t\t\tthis.logger.info(`Instantiating AzureChatOpenAI model with deployment: ${modelName}`);\n\n\t\t\t// Create and return the model\n\t\t\tconst model = new AzureChatOpenAI({\n\t\t\t\tazureOpenAIApiDeploymentName: modelName,\n\t\t\t\t...modelConfig,\n\t\t\t\t...options,\n\t\t\t\ttimeout: options.timeout ?? 60000,\n\t\t\t\tmaxRetries: options.maxRetries ?? 2,\n\t\t\t\tcallbacks: [new N8nLlmTracing(this)],\n\t\t\t\tmodelKwargs: options.responseFormat\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tresponse_format: { type: options.responseFormat },\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tonFailedAttempt: makeN8nLlmFailedAttemptHandler(this),\n\t\t\t});\n\n\t\t\tthis.logger.info(`Azure OpenAI client initialized for deployment: ${modelName}`);\n\n\t\t\treturn {\n\t\t\t\tresponse: model,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Error in LmChatAzureOpenAi.supplyData: ${error.message}`, error);\n\n\t\t\t// Re-throw NodeOperationError directly, wrap others\n\t\t\tif (error instanceof NodeOperationError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`Failed to initialize Azure OpenAI client: ${error.message}`,\n\t\t\t\terror,\n\t\t\t);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAgC;AAChC,0BAOO;AAEP,qBAA0C;AAC1C,oBAA0C;AAC1C,wBAA2B;AAC3B,mBAAmC;AAMnC,wCAA+C;AAC/C,2BAA8B;AAEvB,MAAM,kBAAuC;AAAA,EAA7C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA;AAAA,MAEb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,WAAW;AAAA,MACnB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,OAAO;AAAA,QACN,YAAY,CAAC,IAAI;AAAA,QACjB,eAAe;AAAA,UACd,IAAI,CAAC,mBAAmB,YAAY;AAAA,UACpC,mBAAmB,CAAC,2BAA2B;AAAA,QAChD;AAAA,QACA,WAAW;AAAA,UACV,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AAQ,cAAc;AAAA,QAClC,WAAW,CAAC,IAAI,mCAAc,IAAI,CAAC;AAAA,QACnC,aAAa,QAAQ,iBAClB;AAAA,UACA,iBAAiB,EAAE,MAAM,QAAQ,eAAe;AAAA,QACjD,IACC;AAAA,QACH,qBAAiB,kEAA+B,IAAI;AAAA,MACrD,CAAC;AAED,WAAK,OAAO,KAAK,mDAAmD,SAAS,EAAE;AAE/E,aAAO;AAAA,QACN,UAAU;AAAA,MACX;AAAA,IACD,SAAS,OAAO;AACf,WAAK,OAAO,MAAM,0CAA0C,MAAM,OAAO,IAAI,KAAK;AAGlF,UAAI,iBAAiB,wCAAoB;AACxC,cAAM;AAAA,MACP;AAEA,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb,6CAA6C,MAAM,OAAO;AAAA,QAC1D;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
@@ -0,0 +1,61 @@
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 N8nOAuth2TokenCredential_exports = {};
20
+ __export(N8nOAuth2TokenCredential_exports, {
21
+ N8nOAuth2TokenCredential: () => N8nOAuth2TokenCredential
22
+ });
23
+ module.exports = __toCommonJS(N8nOAuth2TokenCredential_exports);
24
+ var import_n8n_workflow = require("n8n-workflow");
25
+ class N8nOAuth2TokenCredential {
26
+ constructor(node, credential) {
27
+ this.node = node;
28
+ this.credential = credential;
29
+ }
30
+ /**
31
+ * Gets an access token from OAuth credential
32
+ */
33
+ async getToken() {
34
+ try {
35
+ if (!this.credential?.oauthTokenData?.access_token) {
36
+ throw new import_n8n_workflow.NodeOperationError(this.node, "Failed to retrieve access token");
37
+ }
38
+ return {
39
+ token: this.credential.oauthTokenData.access_token,
40
+ expiresOnTimestamp: this.credential.oauthTokenData.expires_on
41
+ };
42
+ } catch (error) {
43
+ throw new import_n8n_workflow.NodeOperationError(this.node, "Failed to retrieve OAuth2 access token", error);
44
+ }
45
+ }
46
+ /**
47
+ * Gets the deployment details from the credential
48
+ */
49
+ async getDeploymentDetails() {
50
+ return {
51
+ apiVersion: this.credential.apiVersion,
52
+ endpoint: this.credential.endpoint,
53
+ resourceName: this.credential.resourceName
54
+ };
55
+ }
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ N8nOAuth2TokenCredential
60
+ });
61
+ //# sourceMappingURL=N8nOAuth2TokenCredential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../nodes/llms/LmChatAzureOpenAi/credentials/N8nOAuth2TokenCredential.ts"],"sourcesContent":["import type { TokenCredential, AccessToken } from '@azure/identity';\nimport type { INode } from 'n8n-workflow';\nimport { NodeOperationError } from 'n8n-workflow';\n\nimport type { AzureEntraCognitiveServicesOAuth2ApiCredential } from '../types';\n/**\n * Adapts n8n's credential retrieval into the TokenCredential interface expected by @azure/identity\n */\nexport class N8nOAuth2TokenCredential implements TokenCredential {\n\tconstructor(\n\t\tprivate node: INode,\n\t\tprivate credential: AzureEntraCognitiveServicesOAuth2ApiCredential,\n\t) {}\n\n\t/**\n\t * Gets an access token from OAuth credential\n\t */\n\tasync getToken(): Promise<AccessToken | null> {\n\t\ttry {\n\t\t\tif (!this.credential?.oauthTokenData?.access_token) {\n\t\t\t\tthrow new NodeOperationError(this.node, 'Failed to retrieve access token');\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttoken: this.credential.oauthTokenData.access_token,\n\t\t\t\texpiresOnTimestamp: this.credential.oauthTokenData.expires_on,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\t// Re-throw with better error message\n\t\t\tthrow new NodeOperationError(this.node, 'Failed to retrieve OAuth2 access token', error);\n\t\t}\n\t}\n\n\t/**\n\t * Gets the deployment details from the credential\n\t */\n\tasync getDeploymentDetails() {\n\t\treturn {\n\t\t\tapiVersion: this.credential.apiVersion,\n\t\t\tendpoint: this.credential.endpoint,\n\t\t\tresourceName: this.credential.resourceName,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,0BAAmC;AAM5B,MAAM,yBAAoD;AAAA,EAChE,YACS,MACA,YACP;AAFO;AACA;AAAA,EACN;AAAA;AAAA;AAAA;AAAA,EAKH,MAAM,WAAwC;AAC7C,QAAI;AACH,UAAI,CAAC,KAAK,YAAY,gBAAgB,cAAc;AACnD,cAAM,IAAI,uCAAmB,KAAK,MAAM,iCAAiC;AAAA,MAC1E;AAEA,aAAO;AAAA,QACN,OAAO,KAAK,WAAW,eAAe;AAAA,QACtC,oBAAoB,KAAK,WAAW,eAAe;AAAA,MACpD;AAAA,IACD,SAAS,OAAO;AAEf,YAAM,IAAI,uCAAmB,KAAK,MAAM,0CAA0C,KAAK;AAAA,IACxF;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,uBAAuB;AAC5B,WAAO;AAAA,MACN,YAAY,KAAK,WAAW;AAAA,MAC5B,UAAU,KAAK,WAAW;AAAA,MAC1B,cAAc,KAAK,WAAW;AAAA,IAC/B;AAAA,EACD;AACD;","names":[]}
@@ -0,0 +1,53 @@
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 api_key_exports = {};
20
+ __export(api_key_exports, {
21
+ setupApiKeyAuthentication: () => setupApiKeyAuthentication
22
+ });
23
+ module.exports = __toCommonJS(api_key_exports);
24
+ var import_n8n_workflow = require("n8n-workflow");
25
+ async function setupApiKeyAuthentication(credentialName) {
26
+ try {
27
+ const configCredentials = await this.getCredentials(credentialName);
28
+ if (!configCredentials.apiKey) {
29
+ throw new import_n8n_workflow.NodeOperationError(
30
+ this.getNode(),
31
+ "API Key is missing in the selected Azure OpenAI API credential. Please configure the API Key or choose Entra ID authentication."
32
+ );
33
+ }
34
+ this.logger.info("Using API Key authentication for Azure OpenAI.");
35
+ return {
36
+ azureOpenAIApiKey: configCredentials.apiKey,
37
+ azureOpenAIApiInstanceName: configCredentials.resourceName,
38
+ azureOpenAIApiVersion: configCredentials.apiVersion,
39
+ azureOpenAIEndpoint: configCredentials.endpoint
40
+ };
41
+ } catch (error) {
42
+ if (error instanceof import_n8n_workflow.OperationalError) {
43
+ throw error;
44
+ }
45
+ this.logger.error(`Error setting up API Key authentication: ${error.message}`, error);
46
+ throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Failed to retrieve API Key", error);
47
+ }
48
+ }
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ setupApiKeyAuthentication
52
+ });
53
+ //# sourceMappingURL=api-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../nodes/llms/LmChatAzureOpenAi/credentials/api-key.ts"],"sourcesContent":["import { NodeOperationError, OperationalError, type ISupplyDataFunctions } from 'n8n-workflow';\n\nimport type { AzureOpenAIApiKeyModelConfig } from '../types';\n\n/**\n * Handles API Key authentication setup for Azure OpenAI\n */\nexport async function setupApiKeyAuthentication(\n\tthis: ISupplyDataFunctions,\n\tcredentialName: string,\n): Promise<AzureOpenAIApiKeyModelConfig> {\n\ttry {\n\t\t// Get Azure OpenAI Config (Endpoint, Version, etc.)\n\t\tconst configCredentials = 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}>(credentialName);\n\n\t\tif (!configCredentials.apiKey) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'API Key is missing in the selected Azure OpenAI API credential. Please configure the API Key or choose Entra ID authentication.',\n\t\t\t);\n\t\t}\n\n\t\tthis.logger.info('Using API Key authentication for Azure OpenAI.');\n\n\t\treturn {\n\t\t\tazureOpenAIApiKey: configCredentials.apiKey,\n\t\t\tazureOpenAIApiInstanceName: configCredentials.resourceName,\n\t\t\tazureOpenAIApiVersion: configCredentials.apiVersion,\n\t\t\tazureOpenAIEndpoint: configCredentials.endpoint,\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof OperationalError) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tthis.logger.error(`Error setting up API Key authentication: ${error.message}`, error);\n\n\t\tthrow new NodeOperationError(this.getNode(), 'Failed to retrieve API Key', error);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgF;AAOhF,eAAsB,0BAErB,gBACwC;AACxC,MAAI;AAEH,UAAM,oBAAoB,MAAM,KAAK,eAKlC,cAAc;AAEjB,QAAI,CAAC,kBAAkB,QAAQ;AAC9B,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAEA,SAAK,OAAO,KAAK,gDAAgD;AAEjE,WAAO;AAAA,MACN,mBAAmB,kBAAkB;AAAA,MACrC,4BAA4B,kBAAkB;AAAA,MAC9C,uBAAuB,kBAAkB;AAAA,MACzC,qBAAqB,kBAAkB;AAAA,IACxC;AAAA,EACD,SAAS,OAAO;AACf,QAAI,iBAAiB,sCAAkB;AACtC,YAAM;AAAA,IACP;AAEA,SAAK,OAAO,MAAM,4CAA4C,MAAM,OAAO,IAAI,KAAK;AAEpF,UAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,8BAA8B,KAAK;AAAA,EACjF;AACD;","names":[]}
@@ -0,0 +1,54 @@
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 oauth2_exports = {};
20
+ __export(oauth2_exports, {
21
+ setupOAuth2Authentication: () => setupOAuth2Authentication
22
+ });
23
+ module.exports = __toCommonJS(oauth2_exports);
24
+ var import_identity = require("@azure/identity");
25
+ var import_n8n_workflow = require("n8n-workflow");
26
+ var import_N8nOAuth2TokenCredential = require("./N8nOAuth2TokenCredential");
27
+ const AZURE_OPENAI_SCOPE = "https://cognitiveservices.azure.com/.default";
28
+ async function setupOAuth2Authentication(credentialName) {
29
+ try {
30
+ const credential = await this.getCredentials(credentialName);
31
+ const entraTokenCredential = new import_N8nOAuth2TokenCredential.N8nOAuth2TokenCredential(this.getNode(), credential);
32
+ const deploymentDetails = await entraTokenCredential.getDeploymentDetails();
33
+ const azureADTokenProvider = (0, import_identity.getBearerTokenProvider)(entraTokenCredential, AZURE_OPENAI_SCOPE);
34
+ this.logger.debug("Successfully created Azure AD Token Provider.");
35
+ return {
36
+ azureADTokenProvider,
37
+ azureOpenAIApiInstanceName: deploymentDetails.resourceName,
38
+ azureOpenAIApiVersion: deploymentDetails.apiVersion,
39
+ azureOpenAIEndpoint: deploymentDetails.endpoint
40
+ };
41
+ } catch (error) {
42
+ this.logger.error(`Error setting up Entra ID authentication: ${error.message}`, error);
43
+ throw new import_n8n_workflow.NodeOperationError(
44
+ this.getNode(),
45
+ `Error setting up Entra ID authentication: ${error.message}`,
46
+ error
47
+ );
48
+ }
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ setupOAuth2Authentication
53
+ });
54
+ //# sourceMappingURL=oauth2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../nodes/llms/LmChatAzureOpenAi/credentials/oauth2.ts"],"sourcesContent":["import { getBearerTokenProvider } from '@azure/identity';\nimport { NodeOperationError, type ISupplyDataFunctions } from 'n8n-workflow';\n\nimport { N8nOAuth2TokenCredential } from './N8nOAuth2TokenCredential';\nimport type {\n\tAzureEntraCognitiveServicesOAuth2ApiCredential,\n\tAzureOpenAIOAuth2ModelConfig,\n} from '../types';\n\nconst AZURE_OPENAI_SCOPE = 'https://cognitiveservices.azure.com/.default';\n/**\n * Creates Entra ID (OAuth2) authentication for Azure OpenAI\n */\nexport async function setupOAuth2Authentication(\n\tthis: ISupplyDataFunctions,\n\tcredentialName: string,\n): Promise<AzureOpenAIOAuth2ModelConfig> {\n\ttry {\n\t\tconst credential =\n\t\t\tawait this.getCredentials<AzureEntraCognitiveServicesOAuth2ApiCredential>(credentialName);\n\t\t// Create a TokenCredential\n\t\tconst entraTokenCredential = new N8nOAuth2TokenCredential(this.getNode(), credential);\n\t\tconst deploymentDetails = await entraTokenCredential.getDeploymentDetails();\n\n\t\t// Use getBearerTokenProvider to create the function LangChain expects\n\t\t// Pass the required scope for Azure Cognitive Services\n\t\tconst azureADTokenProvider = getBearerTokenProvider(entraTokenCredential, AZURE_OPENAI_SCOPE);\n\n\t\tthis.logger.debug('Successfully created Azure AD Token Provider.');\n\n\t\treturn {\n\t\t\tazureADTokenProvider,\n\t\t\tazureOpenAIApiInstanceName: deploymentDetails.resourceName,\n\t\t\tazureOpenAIApiVersion: deploymentDetails.apiVersion,\n\t\t\tazureOpenAIEndpoint: deploymentDetails.endpoint,\n\t\t};\n\t} catch (error) {\n\t\tthis.logger.error(`Error setting up Entra ID authentication: ${error.message}`, error);\n\n\t\tthrow new NodeOperationError(\n\t\t\tthis.getNode(),\n\t\t\t`Error setting up Entra ID authentication: ${error.message}`,\n\t\t\terror,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuC;AACvC,0BAA8D;AAE9D,sCAAyC;AAMzC,MAAM,qBAAqB;AAI3B,eAAsB,0BAErB,gBACwC;AACxC,MAAI;AACH,UAAM,aACL,MAAM,KAAK,eAA+D,cAAc;AAEzF,UAAM,uBAAuB,IAAI,yDAAyB,KAAK,QAAQ,GAAG,UAAU;AACpF,UAAM,oBAAoB,MAAM,qBAAqB,qBAAqB;AAI1E,UAAM,2BAAuB,wCAAuB,sBAAsB,kBAAkB;AAE5F,SAAK,OAAO,MAAM,+CAA+C;AAEjE,WAAO;AAAA,MACN;AAAA,MACA,4BAA4B,kBAAkB;AAAA,MAC9C,uBAAuB,kBAAkB;AAAA,MACzC,qBAAqB,kBAAkB;AAAA,IACxC;AAAA,EACD,SAAS,OAAO;AACf,SAAK,OAAO,MAAM,6CAA6C,MAAM,OAAO,IAAI,KAAK;AAErF,UAAM,IAAI;AAAA,MACT,KAAK,QAAQ;AAAA,MACb,6CAA6C,MAAM,OAAO;AAAA,MAC1D;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
@@ -0,0 +1,155 @@
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 properties_exports = {};
20
+ __export(properties_exports, {
21
+ properties: () => properties
22
+ });
23
+ module.exports = __toCommonJS(properties_exports);
24
+ var import_n8n_workflow = require("n8n-workflow");
25
+ var import_sharedFields = require("../../../utils/sharedFields");
26
+ var import_types = require("./types");
27
+ const properties = [
28
+ // eslint-disable-next-line n8n-nodes-base/node-param-default-missing
29
+ {
30
+ displayName: "Authentication",
31
+ name: "authentication",
32
+ type: "options",
33
+ default: import_types.AuthenticationType.ApiKey,
34
+ options: [
35
+ {
36
+ name: "API Key",
37
+ value: import_types.AuthenticationType.ApiKey
38
+ },
39
+ {
40
+ name: "Azure Entra ID (OAuth2)",
41
+ value: import_types.AuthenticationType.EntraOAuth2
42
+ }
43
+ ]
44
+ },
45
+ (0, import_sharedFields.getConnectionHintNoticeField)([import_n8n_workflow.NodeConnectionTypes.AiChain, import_n8n_workflow.NodeConnectionTypes.AiAgent]),
46
+ {
47
+ displayName: 'If using JSON response format, you must include word "json" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',
48
+ name: "notice",
49
+ type: "notice",
50
+ default: "",
51
+ displayOptions: {
52
+ show: {
53
+ "/options.responseFormat": ["json_object"]
54
+ }
55
+ }
56
+ },
57
+ {
58
+ displayName: "Model (Deployment) Name",
59
+ name: "model",
60
+ type: "string",
61
+ description: "The name of the model(deployment) to use (e.g., gpt-4, gpt-35-turbo)",
62
+ required: true,
63
+ default: ""
64
+ },
65
+ {
66
+ displayName: "Options",
67
+ name: "options",
68
+ placeholder: "Add Option",
69
+ description: "Additional options to add",
70
+ type: "collection",
71
+ default: {},
72
+ options: [
73
+ {
74
+ displayName: "Frequency Penalty",
75
+ name: "frequencyPenalty",
76
+ default: 0,
77
+ typeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },
78
+ description: "Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim",
79
+ type: "number"
80
+ },
81
+ {
82
+ displayName: "Maximum Number of Tokens",
83
+ name: "maxTokens",
84
+ default: -1,
85
+ description: "The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768). Use -1 for default.",
86
+ type: "number",
87
+ typeOptions: {
88
+ maxValue: 128e3
89
+ }
90
+ },
91
+ {
92
+ displayName: "Response Format",
93
+ name: "responseFormat",
94
+ default: "text",
95
+ type: "options",
96
+ options: [
97
+ {
98
+ name: "Text",
99
+ value: "text",
100
+ description: "Regular text response"
101
+ },
102
+ {
103
+ name: "JSON",
104
+ value: "json_object",
105
+ description: "Enables JSON mode, which should guarantee the message the model generates is valid JSON"
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ displayName: "Presence Penalty",
111
+ name: "presencePenalty",
112
+ default: 0,
113
+ typeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },
114
+ description: "Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics",
115
+ type: "number"
116
+ },
117
+ {
118
+ displayName: "Sampling Temperature",
119
+ name: "temperature",
120
+ default: 0.7,
121
+ typeOptions: { maxValue: 2, minValue: 0, numberPrecision: 1 },
122
+ // Max temp can be 2
123
+ description: "Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.",
124
+ type: "number"
125
+ },
126
+ {
127
+ displayName: "Timeout (Ms)",
128
+ name: "timeout",
129
+ default: 6e4,
130
+ description: "Maximum amount of time a request is allowed to take in milliseconds",
131
+ type: "number"
132
+ },
133
+ {
134
+ displayName: "Max Retries",
135
+ name: "maxRetries",
136
+ default: 2,
137
+ description: "Maximum number of retries to attempt on failure",
138
+ type: "number"
139
+ },
140
+ {
141
+ displayName: "Top P",
142
+ name: "topP",
143
+ default: 1,
144
+ typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
145
+ description: "Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.",
146
+ type: "number"
147
+ }
148
+ ]
149
+ }
150
+ ];
151
+ // Annotate the CommonJS export names for ESM import in node:
152
+ 0 && (module.exports = {
153
+ properties
154
+ });
155
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../nodes/llms/LmChatAzureOpenAi/properties.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\nimport { NodeConnectionTypes } from 'n8n-workflow';\n\nimport { getConnectionHintNoticeField } from '@utils/sharedFields';\n\nimport { AuthenticationType } from './types';\n\nexport const properties: INodeProperties[] = [\n\t// eslint-disable-next-line n8n-nodes-base/node-param-default-missing\n\t{\n\t\tdisplayName: 'Authentication',\n\t\tname: 'authentication',\n\t\ttype: 'options',\n\t\tdefault: AuthenticationType.ApiKey,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'API Key',\n\t\t\t\tvalue: AuthenticationType.ApiKey,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Azure Entra ID (OAuth2)',\n\t\t\t\tvalue: AuthenticationType.EntraOAuth2,\n\t\t\t},\n\t\t],\n\t},\n\tgetConnectionHintNoticeField([NodeConnectionTypes.AiChain, NodeConnectionTypes.AiAgent]),\n\t{\n\t\tdisplayName:\n\t\t\t'If using JSON response format, you must include word \"json\" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.',\n\t\tname: 'notice',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\t'/options.responseFormat': ['json_object'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Model (Deployment) Name',\n\t\tname: 'model',\n\t\ttype: 'string',\n\t\tdescription: 'The name of the model(deployment) to use (e.g., gpt-4, gpt-35-turbo)',\n\t\trequired: true,\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: 'Frequency Penalty',\n\t\t\t\tname: 'frequencyPenalty',\n\t\t\t\tdefault: 0,\n\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t\"Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim\",\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Maximum Number of Tokens',\n\t\t\t\tname: 'maxTokens',\n\t\t\t\tdefault: -1,\n\t\t\t\tdescription:\n\t\t\t\t\t'The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768). Use -1 for default.',\n\t\t\t\ttype: 'number',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tmaxValue: 128000,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Response Format',\n\t\t\t\tname: 'responseFormat',\n\t\t\t\tdefault: 'text',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Text',\n\t\t\t\t\t\tvalue: 'text',\n\t\t\t\t\t\tdescription: 'Regular text response',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'JSON',\n\t\t\t\t\t\tvalue: 'json_object',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Enables JSON mode, which should guarantee the message the model generates is valid JSON',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Presence Penalty',\n\t\t\t\tname: 'presencePenalty',\n\t\t\t\tdefault: 0,\n\t\t\t\ttypeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t\"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics\",\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Sampling Temperature',\n\t\t\t\tname: 'temperature',\n\t\t\t\tdefault: 0.7,\n\t\t\t\ttypeOptions: { maxValue: 2, minValue: 0, numberPrecision: 1 }, // Max temp can be 2\n\t\t\t\tdescription:\n\t\t\t\t\t'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Timeout (Ms)',\n\t\t\t\tname: 'timeout',\n\t\t\t\tdefault: 60000,\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: '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 on failure',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Top P',\n\t\t\t\tname: 'topP',\n\t\t\t\tdefault: 1,\n\t\t\t\ttypeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },\n\t\t\t\tdescription:\n\t\t\t\t\t'Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t],\n\t},\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAoC;AAEpC,0BAA6C;AAE7C,mBAAmC;AAE5B,MAAM,aAAgC;AAAA;AAAA,EAE5C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS,gCAAmB;AAAA,IAC5B,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO,gCAAmB;AAAA,MAC3B;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO,gCAAmB;AAAA,MAC3B;AAAA,IACD;AAAA,EACD;AAAA,MACA,kDAA6B,CAAC,wCAAoB,SAAS,wCAAoB,OAAO,CAAC;AAAA,EACvF;AAAA,IACC,aACC;AAAA,IACD,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,2BAA2B,CAAC,aAAa;AAAA,MAC1C;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,IACV,SAAS;AAAA,EACV;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa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AA,QAC5D,aACC;AAAA,QACD,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var types_exports = {};
20
+ __export(types_exports, {
21
+ AuthenticationType: () => AuthenticationType,
22
+ AzureOpenAIErrorType: () => AzureOpenAIErrorType
23
+ });
24
+ module.exports = __toCommonJS(types_exports);
25
+ var AuthenticationType = /* @__PURE__ */ ((AuthenticationType2) => {
26
+ AuthenticationType2["ApiKey"] = "azureOpenAiApi";
27
+ AuthenticationType2["EntraOAuth2"] = "azureEntraCognitiveServicesOAuth2Api";
28
+ return AuthenticationType2;
29
+ })(AuthenticationType || {});
30
+ var AzureOpenAIErrorType = /* @__PURE__ */ ((AzureOpenAIErrorType2) => {
31
+ AzureOpenAIErrorType2["AuthenticationError"] = "AuthenticationError";
32
+ AzureOpenAIErrorType2["ConfigurationError"] = "ConfigurationError";
33
+ AzureOpenAIErrorType2["APIError"] = "APIError";
34
+ AzureOpenAIErrorType2["UnknownError"] = "UnknownError";
35
+ return AzureOpenAIErrorType2;
36
+ })(AzureOpenAIErrorType || {});
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ AuthenticationType,
40
+ AzureOpenAIErrorType
41
+ });
42
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../nodes/llms/LmChatAzureOpenAi/types.ts"],"sourcesContent":["import type { OAuth2CredentialData } from '@n8n/client-oauth2';\n/**\n * Common interfaces for Azure OpenAI configuration\n */\n\n/**\n * Basic Azure OpenAI API configuration options\n */\nexport interface AzureOpenAIConfig {\n\tapiVersion: string;\n\tresourceName: string;\n\tendpoint?: string;\n}\n\n/**\n * Configuration for API Key authentication\n */\nexport interface AzureOpenAIApiKeyConfig extends AzureOpenAIConfig {\n\tapiKey: string;\n}\n\n/**\n * Azure OpenAI node options\n */\nexport interface AzureOpenAIOptions {\n\tfrequencyPenalty?: number;\n\tmaxTokens?: number;\n\tmaxRetries?: number;\n\ttimeout?: number;\n\tpresencePenalty?: number;\n\ttemperature?: number;\n\ttopP?: number;\n\tresponseFormat?: 'text' | 'json_object';\n}\n\n/**\n * Base model configuration that can be passed to AzureChatOpenAI constructor\n */\nexport interface AzureOpenAIBaseModelConfig {\n\tazureOpenAIApiInstanceName: string;\n\tazureOpenAIApiVersion: string;\n\tazureOpenAIEndpoint?: string;\n}\n\n/**\n * API Key model configuration that can be passed to AzureChatOpenAI constructor\n */\nexport interface AzureOpenAIApiKeyModelConfig extends AzureOpenAIBaseModelConfig {\n\tazureOpenAIApiKey: string;\n\tazureADTokenProvider?: undefined;\n}\n\n/**\n * OAuth2 model configuration that can be passed to AzureChatOpenAI constructor\n */\nexport interface AzureOpenAIOAuth2ModelConfig extends AzureOpenAIBaseModelConfig {\n\tazureOpenAIApiKey?: undefined;\n\tazureADTokenProvider: () => Promise<string>;\n}\n\n/**\n * Authentication types supported by Azure OpenAI node\n */\nexport const enum AuthenticationType {\n\tApiKey = 'azureOpenAiApi',\n\tEntraOAuth2 = 'azureEntraCognitiveServicesOAuth2Api',\n}\n\n/**\n * Error types for Azure OpenAI node\n */\nexport const enum AzureOpenAIErrorType {\n\tAuthenticationError = 'AuthenticationError',\n\tConfigurationError = 'ConfigurationError',\n\tAPIError = 'APIError',\n\tUnknownError = 'UnknownError',\n}\n\n/**\n * OAuth2 credential type used by Azure OpenAI node\n */\ntype TokenData = OAuth2CredentialData['oauthTokenData'] & {\n\texpires_on: number;\n\text_expires_on: number;\n};\nexport type AzureEntraCognitiveServicesOAuth2ApiCredential = OAuth2CredentialData & {\n\tcustomScopes: boolean;\n\tauthentication: string;\n\tapiVersion: string;\n\tendpoint: string;\n\tresourceName: string;\n\ttenantId: string;\n\toauthTokenData: TokenData;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+DO,IAAW,qBAAX,kBAAWA,wBAAX;AACN,EAAAA,oBAAA,YAAS;AACT,EAAAA,oBAAA,iBAAc;AAFG,SAAAA;AAAA,GAAA;AAQX,IAAW,uBAAX,kBAAWC,0BAAX;AACN,EAAAA,sBAAA,yBAAsB;AACtB,EAAAA,sBAAA,wBAAqB;AACrB,EAAAA,sBAAA,cAAW;AACX,EAAAA,sBAAA,kBAAe;AAJE,SAAAA;AAAA,GAAA;","names":["AuthenticationType","AzureOpenAIErrorType"]}
@@ -1,6 +1,7 @@
1
1
  [
2
- {"name":"anthropicApi","displayName":"Anthropic","documentationUrl":"anthropic","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""}],"authenticate":{"type":"generic","properties":{"headers":{"x-api-key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"https://api.anthropic.com","url":"/v1/messages","method":"POST","headers":{"anthropic-version":"2023-06-01"},"body":{"model":"claude-3-haiku-20240307","messages":[{"role":"user","content":"Hey"}],"max_tokens":1}}},"supportedNodes":["lmChatAnthropic"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LMChatAnthropic/anthropic.svg"},
2
+ {"name":"anthropicApi","displayName":"Anthropic","documentationUrl":"anthropic","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Base URL","name":"url","type":"string","default":"https://api.anthropic.com","description":"Override the default base URL for the API"}],"authenticate":{"type":"generic","properties":{"headers":{"x-api-key":"={{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{$credentials?.url}}","url":"/v1/messages","method":"POST","headers":{"anthropic-version":"2023-06-01"},"body":{"model":"claude-3-haiku-20240307","messages":[{"role":"user","content":"Hey"}],"max_tokens":1}}},"supportedNodes":["lmChatAnthropic"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LMChatAnthropic/anthropic.svg"},
3
3
  {"name":"azureOpenAiApi","displayName":"Azure Open AI","documentationUrl":"azureopenai","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Resource Name","name":"resourceName","type":"string","required":true,"default":""},{"displayName":"API Version","name":"apiVersion","type":"string","required":true,"default":"2023-07-01-preview"},{"displayName":"Endpoint","name":"endpoint","type":"string","placeholder":"https://westeurope.api.cognitive.microsoft.com"}],"authenticate":{"type":"generic","properties":{"headers":{"api-key":"={{$credentials.apiKey}}"}}},"supportedNodes":["embeddingsAzureOpenAi","lmChatAzureOpenAi"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsAzureOpenAi/azure.svg"},
4
+ {"name":"azureEntraCognitiveServicesOAuth2Api","displayName":"Azure Entra ID (Azure Active Directory) API","extends":["oAuth2Api"],"documentationUrl":"azureEntraCognitiveServicesOAuth2Api","properties":[{"displayName":"Grant Type","name":"grantType","type":"hidden","default":"authorizationCode"},{"displayName":"Resource Name","name":"resourceName","type":"string","required":true,"default":""},{"displayName":"API Version","name":"apiVersion","type":"string","required":true,"default":"2024-12-01-preview"},{"displayName":"Endpoint","name":"endpoint","type":"string","placeholder":"https://westeurope.api.cognitive.microsoft.com"},{"displayName":"Tenant ID","name":"tenantId","type":"string","default":"common","description":"Enter your Azure Tenant ID (Directory ID) or keep \"common\" for multi-tenant apps. Using a specific Tenant ID is generally recommended and required for certain authentication flows.","placeholder":"e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or common"},{"displayName":"Authorization URL","name":"authUrl","type":"string","default":"https://login.microsoftonline.com/$TENANT_ID/oauth2/authorize"},{"displayName":"Access Token URL","name":"accessTokenUrl","type":"string","default":"https://login.microsoftonline.com/$TENANT_ID/oauth2/token"},{"displayName":"Client ID","name":"clientId","type":"string","required":true,"default":"","description":"Client ID obtained from the Azure AD App Registration"},{"displayName":"Client Secret","name":"clientSecret","type":"string","required":true,"typeOptions":{"password":true},"default":"","description":"Client Secret obtained from the Azure AD App Registration"},{"displayName":"Additional Body Properties","name":"additionalBodyProperties","type":"hidden","default":"{\"grant_type\": \"client_credentials\", \"resource\": \"https://cognitiveservices.azure.com/\"}"},{"displayName":"Authentication","name":"authentication","type":"hidden","default":"body"},{"displayName":"Custom Scopes","name":"customScopes","type":"boolean","default":false,"description":"Define custom scopes. You might need this if the default scopes are not sufficient or if you want to minimize permissions. Ensure you include \"openid\" and \"offline_access\"."},{"displayName":"Auth URI Query Parameters","name":"authQueryParameters","type":"hidden","default":"","description":"For some services additional query parameters have to be set which can be defined here","placeholder":""},{"displayName":"Enabled Scopes","name":"enabledScopes","type":"string","displayOptions":{"show":{"customScopes":[true]}},"default":"openid offline_access","placeholder":"openid offline_access","description":"Space-separated list of scopes to request."},{"displayName":"Scope","name":"scope","type":"hidden","default":"={{ $self.customScopes ? $self.enabledScopes : \"openid offline_access\"}}"}],"supportedNodes":["lmChatAzureOpenAi"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatAzureOpenAi/azure.svg"},
4
5
  {"name":"cohereApi","displayName":"CohereApi","documentationUrl":"cohere","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.cohere.ai","url":"/v1/models?page_size=1"}},"supportedNodes":["embeddingsCohere","lmCohere"],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsCohere/cohere.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsCohere/cohere.dark.svg"}},
5
6
  {"name":"deepSeekApi","displayName":"DeepSeek","documentationUrl":"deepseek","properties":[{"displayName":"API Key","name":"apiKey","type":"string","typeOptions":{"password":true},"required":true,"default":""},{"displayName":"Base URL","name":"url","type":"hidden","default":"https://api.deepseek.com"}],"authenticate":{"type":"generic","properties":{"headers":{"Authorization":"=Bearer {{$credentials.apiKey}}"}}},"test":{"request":{"baseURL":"={{ $credentials.url }}","url":"/models"}},"supportedNodes":["lmChatDeepSeek"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatDeepSeek/deepseek.svg"},
6
7
  {"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":["embeddingsGoogleGemini","lmChatGoogleGemini"],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsGoogleGemini/google.svg"},
@@ -24,7 +24,7 @@
24
24
  {"displayName":"Embeddings OpenAI","name":"embeddingsOpenAi","credentials":[{"name":"openAiApi","required":true}],"group":["transform"],"version":[1,1.1,1.2],"description":"Use Embeddings OpenAI","defaults":{"name":"Embeddings OpenAI"},"codex":{"categories":["AI"],"subcategories":{"AI":["Embeddings"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsopenai/"}]}},"inputs":[],"outputs":["ai_embedding"],"outputNames":["Embeddings"],"requestDefaults":{"ignoreHttpStatusErrors":true,"baseURL":"={{ $parameter.options?.baseURL?.split(\"/\").slice(0,-1).join(\"/\") || $credentials.url?.split(\"/\").slice(0,-1).join(\"/\") || \"https://api.openai.com\" }}"},"properties":[{"displayName":"This node must be connected to a vector store. <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='ai_vectorStore'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"}},{"displayName":"Model","name":"model","type":"options","description":"The model which will generate the embeddings. <a href=\"https://platform.openai.com/docs/models/overview\">Learn more</a>.","typeOptions":{"loadOptions":{"routing":{"request":{"method":"GET","url":"={{ $parameter.options?.baseURL?.split(\"/\").slice(-1).pop() || $credentials?.url?.split(\"/\").slice(-1).pop() || \"v1\" }}/models"},"output":{"postReceive":[{"type":"rootProperty","properties":{"property":"data"}},{"type":"filter","properties":{"pass":"={{ $responseItem.id.includes('embed') }}"}},{"type":"setKeyValue","properties":{"name":"={{$responseItem.id}}","value":"={{$responseItem.id}}"}},{"type":"sort","properties":{"key":"name"}}]}}}},"routing":{"send":{"type":"body","property":"model"}},"default":"text-embedding-ada-002","displayOptions":{"show":{"@version":[1]}}},{"displayName":"Model","name":"model","type":"options","description":"The model which will generate the embeddings. <a href=\"https://platform.openai.com/docs/models/overview\">Learn more</a>.","typeOptions":{"loadOptions":{"routing":{"request":{"method":"GET","url":"={{ $parameter.options?.baseURL?.split(\"/\").slice(-1).pop() || $credentials?.url?.split(\"/\").slice(-1).pop() || \"v1\" }}/models"},"output":{"postReceive":[{"type":"rootProperty","properties":{"property":"data"}},{"type":"filter","properties":{"pass":"={{ $responseItem.id.includes('embed') }}"}},{"type":"setKeyValue","properties":{"name":"={{$responseItem.id}}","value":"={{$responseItem.id}}"}},{"type":"sort","properties":{"key":"name"}}]}}}},"routing":{"send":{"type":"body","property":"model"}},"default":"text-embedding-3-small","displayOptions":{"hide":{"@version":[1]}}},{"displayName":"Options","name":"options","placeholder":"Add Option","description":"Additional options to add","type":"collection","default":{},"options":[{"displayName":"Dimensions","name":"dimensions","description":"The number of dimensions the resulting output embeddings should have. Only supported in text-embedding-3 and later models.","type":"options","options":[{"name":"256","value":256},{"name":"512","value":512},{"name":"1024","value":1024},{"name":"1536","value":1536},{"name":"3072","value":3072}]},{"displayName":"Base URL","name":"baseURL","default":"https://api.openai.com/v1","description":"Override the default base URL for the API","type":"string","displayOptions":{"hide":{"@version":[{"_cnd":{"gte":1.2}}]}}},{"displayName":"Batch Size","name":"batchSize","default":512,"typeOptions":{"maxValue":2048},"description":"Maximum number of documents to send in each request","type":"number"},{"displayName":"Strip New Lines","name":"stripNewLines","default":true,"description":"Whether to strip new lines from the input text","type":"boolean"},{"displayName":"Timeout","name":"timeout","default":-1,"description":"Maximum amount of time a request is allowed to take in seconds. Set to -1 for no timeout.","type":"number"}]}],"iconUrl":{"light":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsOpenAI/openAiLight.svg","dark":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsOpenAI/openAiLight.dark.svg"}},
25
25
  {"displayName":"Embeddings Ollama","name":"embeddingsOllama","group":["transform"],"version":1,"description":"Use Ollama Embeddings","defaults":{"name":"Embeddings Ollama"},"credentials":[{"name":"ollamaApi","required":true}],"requestDefaults":{"ignoreHttpStatusErrors":true,"baseURL":"={{ $credentials.baseUrl.replace(new RegExp(\"/$\"), \"\") }}"},"codex":{"categories":["AI"],"subcategories":{"AI":["Embeddings"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsollama/"}]}},"inputs":[],"outputs":["ai_embedding"],"outputNames":["Embeddings"],"properties":[{"displayName":"This node must be connected to a vector store. <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='ai_vectorStore'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"}},{"displayName":"Model","name":"model","type":"options","default":"llama3.2","description":"The model which will generate the completion. To download models, visit <a href=\"https://ollama.ai/library\">Ollama Models Library</a>.","typeOptions":{"loadOptions":{"routing":{"request":{"method":"GET","url":"/api/tags"},"output":{"postReceive":[{"type":"rootProperty","properties":{"property":"models"}},{"type":"setKeyValue","properties":{"name":"={{$responseItem.name}}","value":"={{$responseItem.name}}"}},{"type":"sort","properties":{"key":"name"}}]}}}},"routing":{"send":{"type":"body","property":"model"}},"required":true}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/embeddings/EmbeddingsOllama/ollama.svg"},
26
26
  {"displayName":"Anthropic Chat Model","name":"lmChatAnthropic","group":["transform"],"version":[1,1.1,1.2,1.3],"defaultVersion":1.3,"description":"Language Model Anthropic","defaults":{"name":"Anthropic Chat Model"},"codex":{"categories":["AI"],"subcategories":{"AI":["Language Models","Root Nodes"],"Language Models":["Chat Models (Recommended)"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatanthropic/"}]},"alias":["claude","sonnet","opus"]},"inputs":[],"outputs":["ai_languageModel"],"outputNames":["Model"],"credentials":[{"name":"anthropicApi","required":true}],"properties":[{"displayName":"This node must be connected to an AI chain. <a data-action='openSelectiveNodeCreator' data-action-parameter-creatorview='AI'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"}},{"displayName":"Model","name":"model","type":"options","options":[{"name":"Claude 3.5 Sonnet(20241022)","value":"claude-3-5-sonnet-20241022"},{"name":"Claude 3 Opus(20240229)","value":"claude-3-opus-20240229"},{"name":"Claude 3.5 Sonnet(20240620)","value":"claude-3-5-sonnet-20240620"},{"name":"Claude 3 Sonnet(20240229)","value":"claude-3-sonnet-20240229"},{"name":"Claude 3.5 Haiku(20241022)","value":"claude-3-5-haiku-20241022"},{"name":"Claude 3 Haiku(20240307)","value":"claude-3-haiku-20240307"},{"name":"LEGACY: Claude 2","value":"claude-2"},{"name":"LEGACY: Claude 2.1","value":"claude-2.1"},{"name":"LEGACY: Claude Instant 1.2","value":"claude-instant-1.2"},{"name":"LEGACY: Claude Instant 1","value":"claude-instant-1"}],"description":"The model which will generate the completion. <a href=\"https://docs.anthropic.com/claude/docs/models-overview\">Learn more</a>.","default":"claude-2","displayOptions":{"show":{"@version":[1]}}},{"displayName":"Model","name":"model","type":"options","options":[{"name":"Claude 3.5 Sonnet(20241022)","value":"claude-3-5-sonnet-20241022"},{"name":"Claude 3 Opus(20240229)","value":"claude-3-opus-20240229"},{"name":"Claude 3.5 Sonnet(20240620)","value":"claude-3-5-sonnet-20240620"},{"name":"Claude 3 Sonnet(20240229)","value":"claude-3-sonnet-20240229"},{"name":"Claude 3.5 Haiku(20241022)","value":"claude-3-5-haiku-20241022"},{"name":"Claude 3 Haiku(20240307)","value":"claude-3-haiku-20240307"},{"name":"LEGACY: Claude 2","value":"claude-2"},{"name":"LEGACY: Claude 2.1","value":"claude-2.1"},{"name":"LEGACY: Claude Instant 1.2","value":"claude-instant-1.2"},{"name":"LEGACY: Claude Instant 1","value":"claude-instant-1"}],"description":"The model which will generate the completion. <a href=\"https://docs.anthropic.com/claude/docs/models-overview\">Learn more</a>.","default":"claude-3-sonnet-20240229","displayOptions":{"show":{"@version":[1.1]}}},{"displayName":"Model","name":"model","type":"options","options":[{"name":"Claude 3.5 Sonnet(20241022)","value":"claude-3-5-sonnet-20241022"},{"name":"Claude 3 Opus(20240229)","value":"claude-3-opus-20240229"},{"name":"Claude 3.5 Sonnet(20240620)","value":"claude-3-5-sonnet-20240620"},{"name":"Claude 3 Sonnet(20240229)","value":"claude-3-sonnet-20240229"},{"name":"Claude 3.5 Haiku(20241022)","value":"claude-3-5-haiku-20241022"},{"name":"Claude 3 Haiku(20240307)","value":"claude-3-haiku-20240307"}],"description":"The model which will generate the completion. <a href=\"https://docs.anthropic.com/claude/docs/models-overview\">Learn more</a>.","default":"claude-3-5-sonnet-20240620","displayOptions":{"show":{"@version":[{"_cnd":{"lte":1.2}}]}}},{"displayName":"Model","name":"model","type":"resourceLocator","default":{"mode":"list","value":"claude-3-7-sonnet-20250219","cachedResultName":"Claude 3.7 Sonnet"},"required":true,"modes":[{"displayName":"From List","name":"list","type":"list","placeholder":"Select a model...","typeOptions":{"searchListMethod":"searchModels","searchable":true}},{"displayName":"ID","name":"id","type":"string","placeholder":"Claude Sonnet"}],"description":"The model. Choose from the list, or specify an ID. <a href=\"https://docs.anthropic.com/claude/docs/models-overview\">Learn more</a>.","displayOptions":{"show":{"@version":[{"_cnd":{"gte":1.3}}]}}},{"displayName":"Options","name":"options","placeholder":"Add Option","description":"Additional options to add","type":"collection","default":{},"options":[{"displayName":"Maximum Number of Tokens","name":"maxTokensToSample","default":4096,"description":"The maximum number of tokens to generate in the completion","type":"number"},{"displayName":"Sampling Temperature","name":"temperature","default":0.7,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.","type":"number","displayOptions":{"hide":{"thinking":[true]}}},{"displayName":"Top K","name":"topK","default":-1,"typeOptions":{"maxValue":1,"minValue":-1,"numberPrecision":1},"description":"Used to remove \"long tail\" low probability responses. Defaults to -1, which disables it.","type":"number","displayOptions":{"hide":{"thinking":[true]}}},{"displayName":"Top P","name":"topP","default":1,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.","type":"number","displayOptions":{"hide":{"thinking":[true]}}},{"displayName":"Enable Thinking","name":"thinking","type":"boolean","default":false,"description":"Whether to enable thinking mode for the model"},{"displayName":"Thinking Budget (Tokens)","name":"thinkingBudget","type":"number","default":1024,"description":"The maximum number of tokens to use for thinking","displayOptions":{"show":{"thinking":[true]}}}]}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LMChatAnthropic/anthropic.svg"},
27
- {"displayName":"Azure OpenAI Chat Model","name":"lmChatAzureOpenAi","group":["transform"],"version":1,"description":"For advanced usage with an AI chain","defaults":{"name":"Azure OpenAI Chat Model"},"codex":{"categories":["AI"],"subcategories":{"AI":["Language Models","Root Nodes"],"Language Models":["Chat Models (Recommended)"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatazureopenai/"}]}},"inputs":[],"outputs":["ai_languageModel"],"outputNames":["Model"],"credentials":[{"name":"azureOpenAiApi","required":true}],"properties":[{"displayName":"This node must be connected to an AI chain. <a data-action='openSelectiveNodeCreator' data-action-parameter-creatorview='AI'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"}},{"displayName":"If using JSON response format, you must include word \"json\" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.","name":"notice","type":"notice","default":"","displayOptions":{"show":{"/options.responseFormat":["json_object"]}}},{"displayName":"Model (Deployment) Name","name":"model","type":"string","description":"The name of the model(deployment) to use","default":""},{"displayName":"Options","name":"options","placeholder":"Add Option","description":"Additional options to add","type":"collection","default":{},"options":[{"displayName":"Frequency Penalty","name":"frequencyPenalty","default":0,"typeOptions":{"maxValue":2,"minValue":-2,"numberPrecision":1},"description":"Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim","type":"number"},{"displayName":"Maximum Number of Tokens","name":"maxTokens","default":-1,"description":"The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).","type":"number","typeOptions":{"maxValue":32768}},{"displayName":"Response Format","name":"responseFormat","default":"text","type":"options","options":[{"name":"Text","value":"text","description":"Regular text response"},{"name":"JSON","value":"json_object","description":"Enables JSON mode, which should guarantee the message the model generates is valid JSON"}]},{"displayName":"Presence Penalty","name":"presencePenalty","default":0,"typeOptions":{"maxValue":2,"minValue":-2,"numberPrecision":1},"description":"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics","type":"number"},{"displayName":"Sampling Temperature","name":"temperature","default":0.7,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.","type":"number"},{"displayName":"Timeout","name":"timeout","default":60000,"description":"Maximum amount of time a request is allowed to take in milliseconds","type":"number"},{"displayName":"Max Retries","name":"maxRetries","default":2,"description":"Maximum number of retries to attempt","type":"number"},{"displayName":"Top P","name":"topP","default":1,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.","type":"number"}]}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatAzureOpenAi/azure.svg"},
27
+ {"displayName":"Azure OpenAI Chat Model","name":"lmChatAzureOpenAi","group":["transform"],"version":1,"description":"For advanced usage with an AI chain","defaults":{"name":"Azure OpenAI Chat Model"},"codex":{"categories":["AI"],"subcategories":{"AI":["Language Models","Root Nodes"],"Language Models":["Chat Models (Recommended)"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatazureopenai/"}]}},"inputs":[],"outputs":["ai_languageModel"],"outputNames":["Model"],"credentials":[{"name":"azureOpenAiApi","required":true,"displayOptions":{"show":{"authentication":["azureOpenAiApi"]}}},{"name":"azureEntraCognitiveServicesOAuth2Api","required":true,"displayOptions":{"show":{"authentication":["azureEntraCognitiveServicesOAuth2Api"]}}}],"properties":[{"displayName":"Authentication","name":"authentication","type":"options","default":"azureOpenAiApi","options":[{"name":"API Key","value":"azureOpenAiApi"},{"name":"Azure Entra ID (OAuth2)","value":"azureEntraCognitiveServicesOAuth2Api"}]},{"displayName":"This node must be connected to an AI chain. <a data-action='openSelectiveNodeCreator' data-action-parameter-creatorview='AI'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"}},{"displayName":"If using JSON response format, you must include word \"json\" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.","name":"notice","type":"notice","default":"","displayOptions":{"show":{"/options.responseFormat":["json_object"]}}},{"displayName":"Model (Deployment) Name","name":"model","type":"string","description":"The name of the model(deployment) to use (e.g., gpt-4, gpt-35-turbo)","required":true,"default":""},{"displayName":"Options","name":"options","placeholder":"Add Option","description":"Additional options to add","type":"collection","default":{},"options":[{"displayName":"Frequency Penalty","name":"frequencyPenalty","default":0,"typeOptions":{"maxValue":2,"minValue":-2,"numberPrecision":1},"description":"Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim","type":"number"},{"displayName":"Maximum Number of Tokens","name":"maxTokens","default":-1,"description":"The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768). Use -1 for default.","type":"number","typeOptions":{"maxValue":128000}},{"displayName":"Response Format","name":"responseFormat","default":"text","type":"options","options":[{"name":"Text","value":"text","description":"Regular text response"},{"name":"JSON","value":"json_object","description":"Enables JSON mode, which should guarantee the message the model generates is valid JSON"}]},{"displayName":"Presence Penalty","name":"presencePenalty","default":0,"typeOptions":{"maxValue":2,"minValue":-2,"numberPrecision":1},"description":"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics","type":"number"},{"displayName":"Sampling Temperature","name":"temperature","default":0.7,"typeOptions":{"maxValue":2,"minValue":0,"numberPrecision":1},"description":"Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.","type":"number"},{"displayName":"Timeout (Ms)","name":"timeout","default":60000,"description":"Maximum amount of time a request is allowed to take in milliseconds","type":"number"},{"displayName":"Max Retries","name":"maxRetries","default":2,"description":"Maximum number of retries to attempt on failure","type":"number"},{"displayName":"Top P","name":"topP","default":1,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.","type":"number"}]}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatAzureOpenAi/azure.svg"},
28
28
  {"displayName":"AWS Bedrock Chat Model","name":"lmChatAwsBedrock","group":["transform"],"version":1,"description":"Language Model AWS Bedrock","defaults":{"name":"AWS Bedrock Chat Model"},"codex":{"categories":["AI"],"subcategories":{"AI":["Language Models","Root Nodes"],"Language Models":["Chat Models (Recommended)"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatawsbedrock/"}]}},"inputs":[],"outputs":["ai_languageModel"],"outputNames":["Model"],"credentials":[{"name":"aws","required":true}],"requestDefaults":{"ignoreHttpStatusErrors":true,"baseURL":"=https://bedrock.{{$credentials?.region ?? \"eu-central-1\"}}.amazonaws.com"},"properties":[{"displayName":"This node must be connected to an AI chain. <a data-action='openSelectiveNodeCreator' data-action-parameter-creatorview='AI'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"}},{"displayName":"Model","name":"model","type":"options","description":"The model which will generate the completion. <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/foundation-models.html\">Learn more</a>.","typeOptions":{"loadOptions":{"routing":{"request":{"method":"GET","url":"/foundation-models?&byOutputModality=TEXT&byInferenceType=ON_DEMAND"},"output":{"postReceive":[{"type":"rootProperty","properties":{"property":"modelSummaries"}},{"type":"setKeyValue","properties":{"name":"={{$responseItem.modelName}}","description":"={{$responseItem.modelArn}}","value":"={{$responseItem.modelId}}"}},{"type":"sort","properties":{"key":"name"}}]}}}},"routing":{"send":{"type":"body","property":"model"}},"default":""},{"displayName":"Options","name":"options","placeholder":"Add Option","description":"Additional options to add","type":"collection","default":{},"options":[{"displayName":"Maximum Number of Tokens","name":"maxTokensToSample","default":2000,"description":"The maximum number of tokens to generate in the completion","type":"number"},{"displayName":"Sampling Temperature","name":"temperature","default":0.7,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.","type":"number"}]}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatAwsBedrock/bedrock.svg"},
29
29
  {"displayName":"DeepSeek Chat Model","name":"lmChatDeepSeek","group":["transform"],"version":[1],"description":"For advanced usage with an AI chain","defaults":{"name":"DeepSeek Chat Model"},"codex":{"categories":["AI"],"subcategories":{"AI":["Language Models","Root Nodes"],"Language Models":["Chat Models (Recommended)"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatdeepseek/"}]}},"inputs":[],"outputs":["ai_languageModel"],"outputNames":["Model"],"credentials":[{"name":"deepSeekApi","required":true}],"requestDefaults":{"ignoreHttpStatusErrors":true,"baseURL":"={{ $credentials?.url }}"},"properties":[{"displayName":"This node must be connected to an AI chain. <a data-action='openSelectiveNodeCreator' data-action-parameter-creatorview='AI'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"}},{"displayName":"If using JSON response format, you must include word \"json\" in the prompt in your chain or agent. Also, make sure to select latest models released post November 2023.","name":"notice","type":"notice","default":"","displayOptions":{"show":{"/options.responseFormat":["json_object"]}}},{"displayName":"Model","name":"model","type":"options","description":"The model which will generate the completion. <a href=\"https://api-docs.deepseek.com/quick_start/pricing\">Learn more</a>.","typeOptions":{"loadOptions":{"routing":{"request":{"method":"GET","url":"/models"},"output":{"postReceive":[{"type":"rootProperty","properties":{"property":"data"}},{"type":"setKeyValue","properties":{"name":"={{$responseItem.id}}","value":"={{$responseItem.id}}"}},{"type":"sort","properties":{"key":"name"}}]}}}},"routing":{"send":{"type":"body","property":"model"}},"default":"deepseek-chat"},{"displayName":"Options","name":"options","placeholder":"Add Option","description":"Additional options to add","type":"collection","default":{},"options":[{"displayName":"Frequency Penalty","name":"frequencyPenalty","default":0,"typeOptions":{"maxValue":2,"minValue":-2,"numberPrecision":1},"description":"Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim","type":"number"},{"displayName":"Maximum Number of Tokens","name":"maxTokens","default":-1,"description":"The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).","type":"number","typeOptions":{"maxValue":32768}},{"displayName":"Response Format","name":"responseFormat","default":"text","type":"options","options":[{"name":"Text","value":"text","description":"Regular text response"},{"name":"JSON","value":"json_object","description":"Enables JSON mode, which should guarantee the message the model generates is valid JSON"}]},{"displayName":"Presence Penalty","name":"presencePenalty","default":0,"typeOptions":{"maxValue":2,"minValue":-2,"numberPrecision":1},"description":"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics","type":"number"},{"displayName":"Sampling Temperature","name":"temperature","default":0.7,"typeOptions":{"maxValue":2,"minValue":0,"numberPrecision":1},"description":"Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.","type":"number"},{"displayName":"Timeout","name":"timeout","default":360000,"description":"Maximum amount of time a request is allowed to take in milliseconds","type":"number"},{"displayName":"Max Retries","name":"maxRetries","default":2,"description":"Maximum number of retries to attempt","type":"number"},{"displayName":"Top P","name":"topP","default":1,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.","type":"number"}]}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatDeepSeek/deepseek.svg"},
30
30
  {"displayName":"Google Gemini Chat Model","name":"lmChatGoogleGemini","group":["transform"],"version":1,"description":"Chat Model Google Gemini","defaults":{"name":"Google Gemini Chat Model"},"codex":{"categories":["AI"],"subcategories":{"AI":["Language Models","Root Nodes"],"Language Models":["Chat Models (Recommended)"]},"resources":{"primaryDocumentation":[{"url":"https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatgooglegemini/"}]}},"inputs":[],"outputs":["ai_languageModel"],"outputNames":["Model"],"credentials":[{"name":"googlePalmApi","required":true}],"requestDefaults":{"ignoreHttpStatusErrors":true,"baseURL":"={{ $credentials.host }}"},"properties":[{"displayName":"This node must be connected to an AI chain. <a data-action='openSelectiveNodeCreator' data-action-parameter-creatorview='AI'>Insert one</a>","name":"notice","type":"notice","default":"","typeOptions":{"containerClass":"ndv-connection-hint-notice"}},{"displayName":"Model","name":"modelName","type":"options","description":"The model which will generate the completion. <a href=\"https://developers.generativeai.google/api/rest/generativelanguage/models/list\">Learn more</a>.","typeOptions":{"loadOptions":{"routing":{"request":{"method":"GET","url":"/v1beta/models"},"output":{"postReceive":[{"type":"rootProperty","properties":{"property":"models"}},{"type":"filter","properties":{"pass":"={{ !$responseItem.name.includes('embedding') }}"}},{"type":"setKeyValue","properties":{"name":"={{$responseItem.name}}","value":"={{$responseItem.name}}","description":"={{$responseItem.description}}"}},{"type":"sort","properties":{"key":"name"}}]}}}},"routing":{"send":{"type":"body","property":"model"}},"default":"models/gemini-1.0-pro"},{"displayName":"Options","name":"options","placeholder":"Add Option","description":"Additional options to add","type":"collection","default":{},"options":[{"displayName":"Maximum Number of Tokens","name":"maxOutputTokens","default":2048,"description":"The maximum number of tokens to generate in the completion","type":"number"},{"displayName":"Sampling Temperature","name":"temperature","default":0.4,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.","type":"number"},{"displayName":"Top K","name":"topK","default":32,"typeOptions":{"maxValue":40,"minValue":-1,"numberPrecision":1},"description":"Used to remove \"long tail\" low probability responses. Defaults to -1, which disables it.","type":"number"},{"displayName":"Top P","name":"topP","default":1,"typeOptions":{"maxValue":1,"minValue":0,"numberPrecision":1},"description":"Controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.","type":"number"},{"displayName":"Safety Settings","name":"safetySettings","type":"fixedCollection","typeOptions":{"multipleValues":true},"default":{"values":{"category":"HARM_CATEGORY_HARASSMENT","threshold":"HARM_BLOCK_THRESHOLD_UNSPECIFIED"}},"placeholder":"Add Option","options":[{"name":"values","displayName":"Values","values":[{"displayName":"Safety Category","name":"category","type":"options","description":"The category of harmful content to block","default":"HARM_CATEGORY_UNSPECIFIED","options":[{"value":"HARM_CATEGORY_HARASSMENT","name":"HARM_CATEGORY_HARASSMENT","description":"Harassment content"},{"value":"HARM_CATEGORY_HATE_SPEECH","name":"HARM_CATEGORY_HATE_SPEECH","description":"Hate speech and content"},{"value":"HARM_CATEGORY_SEXUALLY_EXPLICIT","name":"HARM_CATEGORY_SEXUALLY_EXPLICIT","description":"Sexually explicit content"},{"value":"HARM_CATEGORY_DANGEROUS_CONTENT","name":"HARM_CATEGORY_DANGEROUS_CONTENT","description":"Dangerous content"}]},{"displayName":"Safety Threshold","name":"threshold","type":"options","description":"The threshold of harmful content to block","default":"HARM_BLOCK_THRESHOLD_UNSPECIFIED","options":[{"value":"HARM_BLOCK_THRESHOLD_UNSPECIFIED","name":"HARM_BLOCK_THRESHOLD_UNSPECIFIED","description":"Threshold is unspecified"},{"value":"BLOCK_LOW_AND_ABOVE","name":"BLOCK_LOW_AND_ABOVE","description":"Content with NEGLIGIBLE will be allowed"},{"value":"BLOCK_MEDIUM_AND_ABOVE","name":"BLOCK_MEDIUM_AND_ABOVE","description":"Content with NEGLIGIBLE and LOW will be allowed"},{"value":"BLOCK_ONLY_HIGH","name":"BLOCK_ONLY_HIGH","description":"Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed"},{"value":"BLOCK_NONE","name":"BLOCK_NONE","description":"All content will be allowed"}]}]}]}]}],"iconUrl":"icons/@n8n/n8n-nodes-langchain/dist/nodes/llms/LmChatGoogleGemini/google.svg"},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8n/n8n-nodes-langchain",
3
- "version": "1.91.1",
3
+ "version": "1.92.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -13,6 +13,7 @@
13
13
  "credentials": [
14
14
  "dist/credentials/AnthropicApi.credentials.js",
15
15
  "dist/credentials/AzureOpenAiApi.credentials.js",
16
+ "dist/credentials/AzureEntraCognitiveServicesOAuth2Api.credentials.js",
16
17
  "dist/credentials/CohereApi.credentials.js",
17
18
  "dist/credentials/DeepSeekApi.credentials.js",
18
19
  "dist/credentials/GooglePalmApi.credentials.js",
@@ -133,10 +134,11 @@
133
134
  "@types/sanitize-html": "^2.11.0",
134
135
  "@types/temp": "^0.9.1",
135
136
  "tsup": "^8.4.0",
136
- "n8n-core": "1.90.1"
137
+ "n8n-core": "1.91.0"
137
138
  },
138
139
  "dependencies": {
139
140
  "@aws-sdk/client-sso-oidc": "3.666.0",
141
+ "@azure/identity": "4.3.0",
140
142
  "@getzep/zep-cloud": "1.0.12",
141
143
  "@getzep/zep-js": "0.9.0",
142
144
  "@google-ai/generativelanguage": "2.6.0",
@@ -194,8 +196,9 @@
194
196
  "zod-to-json-schema": "3.23.3",
195
197
  "@n8n/json-schema-to-zod": "1.3.0",
196
198
  "@n8n/typescript-config": "1.2.0",
197
- "n8n-workflow": "1.89.0",
198
- "n8n-nodes-base": "1.90.1"
199
+ "n8n-nodes-base": "1.91.0",
200
+ "@n8n/client-oauth2": "0.24.0",
201
+ "n8n-workflow": "1.90.0"
199
202
  },
200
203
  "license": "SEE LICENSE IN LICENSE.md",
201
204
  "homepage": "https://n8n.io",