@tiledesk/tiledesk-tybot-connector 2.0.3 → 2.0.4-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -99,7 +99,7 @@ class DirAssistant {
|
|
|
99
99
|
assistantId = filler.fill(_assistantId, requestAttributes);
|
|
100
100
|
}
|
|
101
101
|
catch(error) {
|
|
102
|
-
winston.
|
|
102
|
+
winston.error("(DirAssistant) Error while filling assistantId:", error);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
let prompt = _prompt;
|
|
@@ -107,7 +107,7 @@ class DirAssistant {
|
|
|
107
107
|
prompt = filler.fill(_prompt, requestAttributes);
|
|
108
108
|
}
|
|
109
109
|
catch(error) {
|
|
110
|
-
winston.
|
|
110
|
+
winston.error("(DirAssistant) Error while filling prompt:", error);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
winston.debug("(DirAssistant) settings ok");
|
|
@@ -129,7 +129,7 @@ class DirAssistant {
|
|
|
129
129
|
let apikey = await this.getGPT_APIKEY();
|
|
130
130
|
if (!apikey) {
|
|
131
131
|
const reply = "OpenAI APIKEY is mandatory for ChatGPT Assistants. Add your personal OpenAI APIKEY in Settings > Integrations";
|
|
132
|
-
winston.
|
|
132
|
+
winston.error("(DirAssistant) Error: " + reply)
|
|
133
133
|
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, assignErrorTo, reply);
|
|
134
134
|
if (falseIntent) {
|
|
135
135
|
await this.#executeCondition(false, trueIntent, null, falseIntent, null);
|
|
@@ -193,7 +193,7 @@ class DirAssistant {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
catch (error) {
|
|
196
|
-
winston.
|
|
196
|
+
winston.error("(DirAssistant) error:", error);
|
|
197
197
|
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, assignErrorTo, error);
|
|
198
198
|
if (falseIntent) {
|
|
199
199
|
await this.#executeCondition(false, trueIntent, null, falseIntent, null);
|
|
@@ -286,19 +286,14 @@ class DirAssistant {
|
|
|
286
286
|
winston.debug("(DirAssistant) DirAssistant HttpRequest", HTTPREQUEST);
|
|
287
287
|
httpUtils.request(
|
|
288
288
|
HTTPREQUEST, async (err, res) => {
|
|
289
|
-
|
|
289
|
+
|
|
290
290
|
if (err) {
|
|
291
291
|
winston.error("(DirAssistant) error: ", err);
|
|
292
292
|
reject(err);
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
resolve(thread)
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
reject(new Error("Thread creation status != 200:", status));
|
|
301
|
-
}
|
|
294
|
+
let thread = res;
|
|
295
|
+
winston.debug("(DirAssistant) got threadid res: ", res);
|
|
296
|
+
resolve(thread)
|
|
302
297
|
}
|
|
303
298
|
);
|
|
304
299
|
});
|
|
@@ -346,19 +341,13 @@ class DirAssistant {
|
|
|
346
341
|
winston.debug("(DirAssistant) HttpRequest: ", HTTPREQUEST);
|
|
347
342
|
httpUtils.request(
|
|
348
343
|
HTTPREQUEST, async (err, res) => {
|
|
349
|
-
|
|
344
|
+
|
|
350
345
|
if (err) {
|
|
351
346
|
winston.error("(DirAssistant) error: ", err);
|
|
352
347
|
reject(err);
|
|
353
348
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
// let return_body = res.data;
|
|
357
|
-
resolve();
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
reject(new Error("Message add status != 200:", status));
|
|
361
|
-
}
|
|
349
|
+
winston.debug("(DirAssistant) got response data: ", res);
|
|
350
|
+
resolve();
|
|
362
351
|
}
|
|
363
352
|
);
|
|
364
353
|
});
|
|
@@ -411,15 +400,8 @@ class DirAssistant {
|
|
|
411
400
|
winston.error("(DirAssistant) error: ", err);
|
|
412
401
|
reject(err);
|
|
413
402
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
// let return_body = res.data;
|
|
417
|
-
resolve(res.data);
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
let status = res?.status;
|
|
421
|
-
reject(new Error("Message add status != 200:", status));
|
|
422
|
-
}
|
|
403
|
+
winston.debug("(DirAddTags) got response data: ", res);
|
|
404
|
+
resolve(res);
|
|
423
405
|
}
|
|
424
406
|
);
|
|
425
407
|
});
|
|
@@ -446,15 +428,8 @@ class DirAssistant {
|
|
|
446
428
|
winston.error("(DirAssistant) error: ", err);
|
|
447
429
|
reject(err);
|
|
448
430
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
// let return_body = res.data;
|
|
452
|
-
resolve(res.data);
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
let status = res?.status;
|
|
456
|
-
reject(new Error("Message add status != 200:", status));
|
|
457
|
-
}
|
|
431
|
+
winston.debug("(DirAddTags) got response data: ", res);
|
|
432
|
+
resolve(res);
|
|
458
433
|
}
|
|
459
434
|
);
|
|
460
435
|
});
|
|
@@ -481,15 +456,8 @@ class DirAssistant {
|
|
|
481
456
|
winston.error("(DirAssistant) error: ", err);
|
|
482
457
|
reject(err);
|
|
483
458
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
// let return_body = res.data;
|
|
487
|
-
resolve(res.data);
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
let status = res?.status;
|
|
491
|
-
reject(new Error("Message add status != 200:", status));
|
|
492
|
-
}
|
|
459
|
+
winston.debug("(DirAddTags) got response data: ", res);
|
|
460
|
+
resolve(res);
|
|
493
461
|
}
|
|
494
462
|
);
|
|
495
463
|
});
|
package/utils/HttpUtils.js
CHANGED
|
@@ -24,19 +24,19 @@ class HttpUtils {
|
|
|
24
24
|
}
|
|
25
25
|
axios(axios_options)
|
|
26
26
|
.then((res) => {
|
|
27
|
-
if (res && res.status
|
|
27
|
+
if (res && (res.status >= 200 && res.status <= 299) && res.data) {
|
|
28
28
|
if (callback) {
|
|
29
29
|
callback(null, res.data);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
if (callback) {
|
|
34
|
-
callback(new Error("Response status is not
|
|
34
|
+
callback(new Error("Response status is not 2xx"), null);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
})
|
|
38
38
|
.catch((error) => {
|
|
39
|
-
if (error.response
|
|
39
|
+
if (error.response?.data) {
|
|
40
40
|
if (typeof error.response.data === 'string') {
|
|
41
41
|
winston.error("Axios error response data: " + error.response.data);
|
|
42
42
|
} else {
|