@tiledesk/tiledesk-tybot-connector 2.0.16-rc1 → 2.0.16-rc3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "2.0.16-rc1",
3
+ "version": "2.0.16-rc3",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "@tiledesk/tiledesk-chatbot-client": "^0.5.30",
16
16
  "@tiledesk/tiledesk-chatbot-util": "^0.8.39",
17
17
  "@tiledesk/tiledesk-client": "^0.10.13",
18
- "@tiledesk/tiledesk-multi-worker": "^0.3.1",
18
+ "@tiledesk/tiledesk-multi-worker": "^0.3.2",
19
19
  "accept-language-parser": "^1.5.0",
20
20
  "app-root-path": "^3.1.0",
21
21
  "axios": "^1.7.7",
@@ -75,8 +75,10 @@ class DirAskGPTV2 {
75
75
  let temperature;
76
76
  let max_tokens;
77
77
  let top_k;
78
+ let alpha;
78
79
  let transcript;
79
80
  let citations = false;
81
+ let chunks_only = false;
80
82
  let engine;
81
83
  //let default_context = "You are an helpful assistant for question-answering tasks.\nUse ONLY the following pieces of retrieved context to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf none of the retrieved context answer the question, add this word to the end <NOANS>\n\n{context}";
82
84
 
@@ -123,10 +125,18 @@ class DirAskGPTV2 {
123
125
  max_tokens = action.max_tokens;
124
126
  }
125
127
 
128
+ if (action.alpha) {
129
+ alpha = action.alpha;
130
+ }
131
+
126
132
  if (action.citations) {
127
133
  citations = action.citations;
128
134
  }
129
135
 
136
+ if (action.chunks_only) {
137
+ chunks_only = action.chunks_only;
138
+ }
139
+
130
140
  let requestVariables = null;
131
141
  requestVariables =
132
142
  await TiledeskChatbot.allParametersStatic(
@@ -185,7 +195,7 @@ class DirAskGPTV2 {
185
195
  return;
186
196
  }
187
197
 
188
- if (publicKey === true) {
198
+ if (publicKey === true && !chunks_only) {
189
199
  let keep_going = await this.checkQuoteAvailability();
190
200
  if (keep_going === false) {
191
201
  this.logger.warn("[Ask Knowledge Base] Tokens quota exceeded. Skip the action")
@@ -199,6 +209,7 @@ class DirAskGPTV2 {
199
209
 
200
210
  let ns;
201
211
 
212
+ console.log("namespace: ", namespace)
202
213
  if (action.namespaceAsName) {
203
214
  // Namespace could be an attribute
204
215
  const filled_namespace = filler.fill(action.namespace, requestVariables)
@@ -209,6 +220,7 @@ class DirAskGPTV2 {
209
220
  } else {
210
221
  this.logger.native("[Ask Knowledge Base] Searching namespace by id ", namespace);
211
222
  ns = await this.getNamespace(null, namespace);
223
+ console.log("ns ?: ", ns)
212
224
  }
213
225
 
214
226
  if (!ns) {
@@ -259,7 +271,16 @@ class DirAskGPTV2 {
259
271
  if (max_tokens) {
260
272
  json.max_tokens = max_tokens;
261
273
  }
262
-
274
+
275
+ if (engine.type === 'serverless') {
276
+ json.search_type = 'hybrid';
277
+ json.alpha = alpha;
278
+ }
279
+
280
+ if (chunks_only && chunks_only === true) {
281
+ json.search_type = 'chunks';
282
+ }
283
+
263
284
  if (!action.advancedPrompt) {
264
285
  if (filled_context) {
265
286
  json.system_context = filled_context + "\n" + contexts[model];
@@ -305,22 +326,34 @@ class DirAskGPTV2 {
305
326
  }
306
327
  else if (resbody.success === true) {
307
328
  winston.debug("DirAskGPTV2 resbody: ", resbody);
308
- await this.#assignAttributes(action, resbody.answer, resbody.source, resbody.content_chunks);
309
- if (publicKey === true) {
310
- let tokens_usage = {
311
- tokens: resbody.prompt_token_size,
312
- model: json.model
329
+ if (chunks_only) {
330
+ await this.#assignAttributes(action, resbody.answer, resbody.source, resbody.chunks);
331
+ if (trueIntent) {
332
+ await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
333
+ callback(true);
334
+ return;
313
335
  }
314
- this.updateQuote(tokens_usage);
315
- }
336
+ callback();
337
+ return;
316
338
 
317
- if (trueIntent) {
318
- await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
319
- callback(true);
339
+ } else {
340
+ await this.#assignAttributes(action, resbody.answer, resbody.source, resbody.content_chunks);
341
+ if (publicKey === true) {
342
+ let tokens_usage = {
343
+ tokens: resbody.prompt_token_size,
344
+ model: json.model
345
+ }
346
+ this.updateQuote(tokens_usage);
347
+ }
348
+
349
+ if (trueIntent) {
350
+ await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
351
+ callback(true);
352
+ return;
353
+ }
354
+ callback();
320
355
  return;
321
356
  }
322
- callback();
323
- return;
324
357
  } else {
325
358
  await this.#assignAttributes(action, answer, source);
326
359
  if (falseIntent) {
@@ -74,11 +74,11 @@ class DirFlowLog {
74
74
  }
75
75
  else if (level === 'info') {
76
76
  winston.verbose("Adding log '" + filled_log + "' with level " + level);
77
- this.logger.native(filled_log);
77
+ this.logger.info(filled_log);
78
78
  }
79
79
  else if (level === 'debug') {
80
80
  winston.verbose("Adding log '" + filled_log + "' with level " + level);
81
- this.logger.native(filled_log);
81
+ this.logger.debug(filled_log);
82
82
  }
83
83
 
84
84
  callback();