@tiledesk/tiledesk-tybot-connector 2.0.3 → 2.0.4-rc1
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.data);
|
|
350
|
+
resolve();
|
|
362
351
|
}
|
|
363
352
|
);
|
|
364
353
|
});
|
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 {
|