@aiteza/n8n-nodes-aiteza 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1854,6 +1854,14 @@ class Aiteza {
|
|
|
1854
1854
|
default: [],
|
|
1855
1855
|
description: 'Datarooms to use as context. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
1856
1856
|
},
|
|
1857
|
+
{
|
|
1858
|
+
displayName: 'Timeout (Minutes)',
|
|
1859
|
+
name: 'timeoutMinutes',
|
|
1860
|
+
type: 'number',
|
|
1861
|
+
default: 60,
|
|
1862
|
+
typeOptions: { minValue: 1 },
|
|
1863
|
+
description: 'Maximum time in minutes to wait for the AI response. Increase for complex or long-running queries.',
|
|
1864
|
+
},
|
|
1857
1865
|
{
|
|
1858
1866
|
displayName: 'File IDs',
|
|
1859
1867
|
name: 'fileIds',
|
|
@@ -1946,6 +1954,14 @@ class Aiteza {
|
|
|
1946
1954
|
default: [],
|
|
1947
1955
|
description: 'Datarooms to search for context. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
1948
1956
|
},
|
|
1957
|
+
{
|
|
1958
|
+
displayName: 'Timeout (Minutes)',
|
|
1959
|
+
name: 'timeoutMinutes',
|
|
1960
|
+
type: 'number',
|
|
1961
|
+
default: 60,
|
|
1962
|
+
typeOptions: { minValue: 1 },
|
|
1963
|
+
description: 'Maximum time in minutes to wait for the AI response. Increase for complex or long-running queries.',
|
|
1964
|
+
},
|
|
1949
1965
|
{
|
|
1950
1966
|
displayName: 'File IDs',
|
|
1951
1967
|
name: 'fileIds',
|
|
@@ -2216,7 +2232,7 @@ class Aiteza {
|
|
|
2216
2232
|
async execute() {
|
|
2217
2233
|
const items = this.getInputData();
|
|
2218
2234
|
const returnData = [];
|
|
2219
|
-
const CHAT_REQUEST_TIMEOUT_MS =
|
|
2235
|
+
const CHAT_REQUEST_TIMEOUT_MS = 60 * 60 * 1000;
|
|
2220
2236
|
const resource = this.getNodeParameter('resource', 0);
|
|
2221
2237
|
const operation = this.getNodeParameter('operation', 0);
|
|
2222
2238
|
const authMode = this.getNodeParameter('authSource', 0, 'credentials');
|
|
@@ -2853,6 +2869,9 @@ class Aiteza {
|
|
|
2853
2869
|
const prompt = this.getNodeParameter('prompt', i);
|
|
2854
2870
|
const model = this.getNodeParameter('model', i);
|
|
2855
2871
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
2872
|
+
const timeoutMs = additionalFields.timeoutMinutes
|
|
2873
|
+
? additionalFields.timeoutMinutes * 60 * 1000
|
|
2874
|
+
: CHAT_REQUEST_TIMEOUT_MS;
|
|
2856
2875
|
const form = new form_data_1.default();
|
|
2857
2876
|
form.append('prompt', prompt);
|
|
2858
2877
|
form.append('model', model);
|
|
@@ -2877,7 +2896,7 @@ class Aiteza {
|
|
|
2877
2896
|
method: 'POST',
|
|
2878
2897
|
url: `${baseUrl}/api/chat/${chatId}/generate`,
|
|
2879
2898
|
body: form,
|
|
2880
|
-
timeout:
|
|
2899
|
+
timeout: timeoutMs,
|
|
2881
2900
|
returnFullResponse: true,
|
|
2882
2901
|
});
|
|
2883
2902
|
responseData =
|
|
@@ -2893,6 +2912,9 @@ class Aiteza {
|
|
|
2893
2912
|
const prompt = this.getNodeParameter('prompt', i);
|
|
2894
2913
|
const model = this.getNodeParameter('model', i);
|
|
2895
2914
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
2915
|
+
const timeoutMs = additionalFields.timeoutMinutes
|
|
2916
|
+
? additionalFields.timeoutMinutes * 60 * 1000
|
|
2917
|
+
: CHAT_REQUEST_TIMEOUT_MS;
|
|
2896
2918
|
const form = new form_data_1.default();
|
|
2897
2919
|
form.append('prompt', prompt);
|
|
2898
2920
|
form.append('model', model);
|
|
@@ -2917,13 +2939,16 @@ class Aiteza {
|
|
|
2917
2939
|
method: 'POST',
|
|
2918
2940
|
url: `${baseUrl}/api/chat/estimate`,
|
|
2919
2941
|
body: form,
|
|
2920
|
-
timeout:
|
|
2942
|
+
timeout: timeoutMs,
|
|
2921
2943
|
});
|
|
2922
2944
|
}
|
|
2923
2945
|
else if (operation === 'tempChat') {
|
|
2924
2946
|
const prompt = this.getNodeParameter('prompt', i);
|
|
2925
2947
|
const model = this.getNodeParameter('model', i);
|
|
2926
2948
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
2949
|
+
const timeoutMs = additionalFields.timeoutMinutes
|
|
2950
|
+
? additionalFields.timeoutMinutes * 60 * 1000
|
|
2951
|
+
: CHAT_REQUEST_TIMEOUT_MS;
|
|
2927
2952
|
const form = new form_data_1.default();
|
|
2928
2953
|
form.append('prompt', prompt);
|
|
2929
2954
|
form.append('model', model);
|
|
@@ -2948,7 +2973,7 @@ class Aiteza {
|
|
|
2948
2973
|
method: 'POST',
|
|
2949
2974
|
url: `${baseUrl}/api/chat/temp`,
|
|
2950
2975
|
body: form,
|
|
2951
|
-
timeout:
|
|
2976
|
+
timeout: timeoutMs,
|
|
2952
2977
|
});
|
|
2953
2978
|
if (typeof responseData === 'string') {
|
|
2954
2979
|
responseData = { result: responseData };
|
|
@@ -2977,8 +3002,7 @@ class Aiteza {
|
|
|
2977
3002
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
2978
3003
|
const body = { query };
|
|
2979
3004
|
const dataroomIds = toIdArray(dataroomIdsRaw);
|
|
2980
|
-
|
|
2981
|
-
body.dataroomIds = dataroomIds;
|
|
3005
|
+
body.dataroomIds = dataroomIds;
|
|
2982
3006
|
for (const key of [
|
|
2983
3007
|
'topK',
|
|
2984
3008
|
'vectorThreshold',
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AitezaTrigger = void 0;
|
|
4
|
+
function timingSafeEqual(a, b) {
|
|
5
|
+
if (a.length !== b.length)
|
|
6
|
+
return false;
|
|
7
|
+
let diff = 0;
|
|
8
|
+
for (let i = 0; i < a.length; i++) {
|
|
9
|
+
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
10
|
+
}
|
|
11
|
+
return diff === 0;
|
|
12
|
+
}
|
|
13
|
+
async function getWebhookApiKey(ctx) {
|
|
14
|
+
try {
|
|
15
|
+
const credentials = await ctx.getCredentials('aitezaWebhookApi');
|
|
16
|
+
return (credentials?.apiKey ?? '').trim();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
4
22
|
class AitezaTrigger {
|
|
5
23
|
description = {
|
|
6
24
|
displayName: 'AITEZA Trigger',
|
|
@@ -12,7 +30,12 @@ class AitezaTrigger {
|
|
|
12
30
|
defaults: { name: 'AITEZA Trigger' },
|
|
13
31
|
inputs: [],
|
|
14
32
|
outputs: ['main'],
|
|
15
|
-
credentials: [
|
|
33
|
+
credentials: [
|
|
34
|
+
{
|
|
35
|
+
name: 'aitezaWebhookApi',
|
|
36
|
+
required: false,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
16
39
|
webhooks: [
|
|
17
40
|
{
|
|
18
41
|
name: 'default',
|
|
@@ -71,6 +94,12 @@ class AitezaTrigger {
|
|
|
71
94
|
const userBearer = user.bearerToken ?? '';
|
|
72
95
|
const authHeader = headers.authorization || headers.Authorization || '';
|
|
73
96
|
const headerToken = authHeader.replace(/^Bearer\s+/i, '');
|
|
97
|
+
const expectedApiKey = await getWebhookApiKey(this);
|
|
98
|
+
if (expectedApiKey && !timingSafeEqual(headerToken, expectedApiKey)) {
|
|
99
|
+
const res = this.getResponseObject();
|
|
100
|
+
res.status(401).json({ error: 'Unauthorized' });
|
|
101
|
+
return { noWebhookResponse: true };
|
|
102
|
+
}
|
|
74
103
|
const authToken = userBearer || headerToken;
|
|
75
104
|
const baseUrl = this.getNodeParameter('baseUrl', '').replace(/\/+$/, '');
|
|
76
105
|
const outputData = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiteza/n8n-nodes-aiteza",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "n8n Community Node for the AITEZA REST API (Datarooms, Files, Chat, Search, Workflows)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"n8n": {
|
|
31
31
|
"n8nNodesApiVersion": 1,
|
|
32
32
|
"credentials": [
|
|
33
|
-
"dist/credentials/AitezaOAuth2Api.credentials.js"
|
|
33
|
+
"dist/credentials/AitezaOAuth2Api.credentials.js",
|
|
34
|
+
"dist/credentials/AitezaWebhookApi.credentials.js"
|
|
34
35
|
],
|
|
35
36
|
"nodes": [
|
|
36
37
|
"dist/nodes/Aiteza/Aiteza.node.js",
|