@tiledesk/tiledesk-tybot-connector 0.2.99 → 0.2.100
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/CHANGELOG.md
CHANGED
|
@@ -17,8 +17,10 @@ available on:
|
|
|
17
17
|
- Added flowError on JSONCondition when result = null
|
|
18
18
|
- Added fix on Filler -->
|
|
19
19
|
|
|
20
|
-
# v0.2.
|
|
20
|
+
# v0.2.100 -> test
|
|
21
21
|
- Added "chatbotToken" to RESERVED attributes
|
|
22
|
+
- Added UUID, UUIDv4 dynamic attributes
|
|
23
|
+
- Remove console.error from Filler liquidJS catch clause
|
|
22
24
|
|
|
23
25
|
# v0.2.98
|
|
24
26
|
- Support for MAX_EXECUTION_TIME (total execution time of a flow without user interaction)
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
var { Liquid } = require('liquidjs');
|
|
2
2
|
var engine = new Liquid();
|
|
3
|
+
const { v4: uuidv4 } = require('uuid');
|
|
3
4
|
|
|
4
5
|
class Filler {
|
|
5
6
|
|
|
6
7
|
fill(text, parameters) {
|
|
7
8
|
// create dynamic attributes
|
|
8
|
-
if (parameters) {
|
|
9
|
-
parameters
|
|
10
|
-
parameters["now"] = new Date(); // type Object
|
|
9
|
+
if (!parameters) {
|
|
10
|
+
parameters = {};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
parameters["timestamp"] = Date.now(); // type number
|
|
14
|
+
parameters["now"] = new Date(); // type Object
|
|
15
|
+
parameters["UUID"] = uuidv4().replace(/-/g, '');
|
|
16
|
+
parameters["UUIDv4"] = uuidv4();
|
|
17
|
+
|
|
13
18
|
// legacy parser first
|
|
14
19
|
if (text == null || text == undefined || typeof text !== 'string') {
|
|
15
20
|
// console.log("Skip filling. 'text' is null or not a string");
|
|
@@ -22,13 +27,13 @@ class Filler {
|
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
// then post process with new LiquidJS!
|
|
25
|
-
let result;
|
|
30
|
+
let result = text;
|
|
26
31
|
try {
|
|
27
32
|
result = engine
|
|
28
33
|
.parseAndRenderSync(text, parameters, null);
|
|
29
34
|
}
|
|
30
35
|
catch(e) {
|
|
31
|
-
|
|
36
|
+
// console.error(e)
|
|
32
37
|
}
|
|
33
38
|
return result;
|
|
34
39
|
}
|
|
@@ -240,11 +240,13 @@ class DirAskGPTV2 {
|
|
|
240
240
|
console.log("DirAskGPT error: ", err);
|
|
241
241
|
}
|
|
242
242
|
if (this.log) { console.log("DirAskGPT resbody:", resbody); }
|
|
243
|
-
|
|
244
|
-
let
|
|
245
|
-
|
|
243
|
+
|
|
244
|
+
// let answer = resbody.answer;
|
|
245
|
+
// let source = resbody.source;
|
|
246
|
+
// await this.#assignAttributes(action, answer, source);
|
|
246
247
|
|
|
247
248
|
if (err) {
|
|
249
|
+
await this.#assignAttributes(action, answer, source);
|
|
248
250
|
if (callback) {
|
|
249
251
|
if (falseIntent) {
|
|
250
252
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
@@ -257,6 +259,7 @@ class DirAskGPTV2 {
|
|
|
257
259
|
}
|
|
258
260
|
else if (resbody.success === true) {
|
|
259
261
|
|
|
262
|
+
await this.#assignAttributes(action, resbody.answer, resbody.source);
|
|
260
263
|
if (publicKey === true) {
|
|
261
264
|
let tokens_usage = {
|
|
262
265
|
tokens: resbody.prompt_token_size,
|
|
@@ -273,6 +276,7 @@ class DirAskGPTV2 {
|
|
|
273
276
|
callback();
|
|
274
277
|
return;
|
|
275
278
|
} else {
|
|
279
|
+
await this.#assignAttributes(action, answer, source);
|
|
276
280
|
if (falseIntent) {
|
|
277
281
|
await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
278
282
|
callback(true);
|