@tiledesk/tiledesk-tybot-connector 0.2.95 → 0.2.96-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/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
+ # v0.2.96-rc1
9
+ - Added support for response_format in GptTask
10
+ - Added namespaceAsName parameter in AskGPTv2
11
+
12
+ # v0.2.97
13
+ - Added a limit in upload and download for WebRequestV2: maxContentLength: 10000000, // max 10mb response size, maxBodyLength: 10000000 // max 10mb request body size
14
+ - Added jsonCondition test on json objects properties
15
+ - Added flowError on JSONCondition when result = null
16
+ - Added fix on Filler
17
+
18
+ # v0.2.96
19
+ - Added timestamp (number) and now (Date Object) attributes
20
+
8
21
  # v0.2.95
9
22
  - If Online Agents V2 - bug fix (If Project Available Agents V2 -> MWeb)
10
23
 
@@ -149,6 +162,9 @@ available on:
149
162
  - added flow attribute "decodedCustomJWT"
150
163
 
151
164
  # v0.2.57
165
+ - Changed env variables for AskGPT actions
166
+ - Added support for temperature, top_k, max_tokens and context for AskGPTV2 action
167
+ - Added support for context with variables for GptTask action
152
168
  - fixed catching reply error in index.js: reply = await chatbot.replyToMessage(message);
153
169
  - Added context and top_k parameter in DirAskGPTV2
154
170
 
@@ -359,7 +359,7 @@ class TiledeskExpression {
359
359
  // console.log("operand1_s:", operand1_s);
360
360
  }
361
361
  else {
362
- console.error("Condition evaluation stopped because of invalid operand", condition.operand1);
362
+ console.error("Condition evaluation stopped because of invalid operand1", condition.operand1);
363
363
  return null;
364
364
  }
365
365
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.95",
3
+ "version": "0.2.96-rc1",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -4,6 +4,12 @@ var engine = new Liquid();
4
4
  class Filler {
5
5
 
6
6
  fill(text, parameters) {
7
+ // create dynamic attributes
8
+ if (parameters) {
9
+ parameters["timestamp"] = Date.now(); // type number
10
+ parameters["now"] = new Date(); // type Object
11
+ }
12
+
7
13
  // legacy parser first
8
14
  if (text == null || text == undefined || typeof text !== 'string') {
9
15
  // console.log("Skip filling. 'text' is null or not a string");
@@ -171,6 +171,21 @@ class DirAskGPTV2 {
171
171
  }
172
172
 
173
173
 
174
+ if (action.namespaceAsName) {
175
+ namespace = await this.getNamespaceIdFromName(server_base_url, action.namespace)
176
+ if (this.log) { console.log("DirAskGPT - Retrieved namespace id from name ", namespace); }
177
+ }
178
+
179
+ if (!namespace) {
180
+ console.log("DirAskGPT - Error: namespace is undefined")
181
+ if (falseIntent) {
182
+ await this.chatbot.addParameter("flowError", "AskGPT Error: namespace is undefined");
183
+ await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
184
+ callback(true);
185
+ return;
186
+ }
187
+ }
188
+
174
189
  let json = {
175
190
  question: filled_question,
176
191
  gptkey: key,
@@ -202,7 +217,7 @@ class DirAskGPTV2 {
202
217
  }
203
218
 
204
219
  if (this.log) { console.log("DirAskGPT json:", json); }
205
-
220
+
206
221
  const HTTPREQUEST = {
207
222
  // url: server_base_url + "/" + this.context.projectId + "/kb/qa",
208
223
  url: kb_endpoint + "/qa",
@@ -546,6 +561,39 @@ class DirAskGPTV2 {
546
561
  return objectTranscript;
547
562
  }
548
563
 
564
+ async getNamespaceIdFromName(server_base_url, name) {
565
+ return new Promise((resolve) => {
566
+
567
+ const HTTPREQUEST = {
568
+ url: server_base_url + "/" + this.context.projectId + "/kb/namespace/all",
569
+ headers: {
570
+ 'Content-Type': 'application/json',
571
+ 'Authorization': 'JWT ' + this.context.token
572
+ },
573
+ method: "GET"
574
+ }
575
+ if (this.log) { console.log("DirAskGPT check quote availability HTTPREQUEST", HTTPREQUEST); }
576
+
577
+ this.#myrequest(
578
+ HTTPREQUEST, async (err, namespaces) => {
579
+ if (err) {
580
+ console.error("(httprequest) DirAskGPT get all namespaces err: ", err);
581
+ resolve(null)
582
+ } else {
583
+ if (this.log) { console.log("(httprequest) DirAskGPT Increment token quote resbody: ", namespaces); }
584
+ console.log("(httprequest) DirAskGPT Increment token quote resbody: ", namespaces);
585
+
586
+ let namespace = namespaces.find(n => n.name === name);
587
+ let namespace_id = namespace.id;
588
+
589
+ resolve(namespace_id);
590
+ }
591
+ }
592
+ )
593
+ })
594
+
595
+ }
596
+
549
597
 
550
598
  }
551
599
 
@@ -168,6 +168,12 @@ class DirGptTask {
168
168
  json.messages.push(message);
169
169
  }
170
170
 
171
+ if (action.format_type) {
172
+ json.response_format = {
173
+ type: action.format_type
174
+ }
175
+ }
176
+
171
177
  if (transcript) {
172
178
  transcript.forEach(msg => {
173
179
  if (!msg.content.startsWith('/')) {
@@ -119,6 +119,9 @@ class DirJSONCondition {
119
119
  }
120
120
  }
121
121
  else {
122
+ if (result === null) {
123
+ await this.chatbot.addParameter("flowError", "An error occurred evaluating condition: result === null");
124
+ }
122
125
  if (falseIntentDirective) {
123
126
  this.intentDir.execute(falseIntentDirective, () => {
124
127
  // console.log("result === false. stopOnConditionMet?", stopOnConditionMet);
@@ -273,7 +273,9 @@ class DirWebRequestV2 {
273
273
  method: options.method,
274
274
  params: options.params,
275
275
  headers: options.headers,
276
- timeout: options.timeout
276
+ timeout: options.timeout,
277
+ maxContentLength: 10000000, // max 10mb response size
278
+ maxBodyLength: 10000000 // max 10mb request body size
277
279
  }
278
280
 
279
281
  if (options.json !== null) {
@@ -40,6 +40,7 @@ class Directives {
40
40
  static HUBSPOT = 'hubspot';
41
41
  static CUSTOMERIO = 'customerio';
42
42
  static BREVO = 'brevo';
43
+ static N8N = 'n8n';
43
44
  /**** VOICE CHANNEL ****/
44
45
  static DTMF_FORM = 'dtmf_form';
45
46
  static DTMF_MENU = 'dtmf_menu';