@tiledesk/tiledesk-tybot-connector 2.0.37 → 2.0.38

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.37",
3
+ "version": "2.0.38",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -91,7 +91,6 @@ class KBService {
91
91
 
92
92
  httpUtils.request(http_request, (err, response) => {
93
93
  if (err) {
94
- winston.error("Error adding unanswered question:", err);
95
94
  reject(err);
96
95
  } else {
97
96
  resolve(response);
@@ -85,9 +85,9 @@ class DirAskGPTV2 {
85
85
  let skip_unanswered;
86
86
 
87
87
  let contexts = {
88
- "gpt-3.5-turbo": process.env.GPT_3_5_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say: \"I don't know<NOANS>\"\n\n####{context}####",
89
- "gpt-4": process.env.GPT_4_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
90
- "gpt-4-turbo-preview": process.env.GPT_4T_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
88
+ "gpt-3.5-turbo": process.env.GPT_3_5_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### and the chat history to answer the question.\nIf you don't know the answer, just say: \"I don't know<NOANS>\"\n\n####{context}####",
89
+ "gpt-4": process.env.GPT_4_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### and the chat history to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
90
+ "gpt-4-turbo-preview": process.env.GPT_4T_CONTEXT || "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### and the chat history to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
91
91
  "gpt-4o": process.env.GPT_4O_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
92
92
  "gpt-4o-mini": process.env.GPT_4O_MINI_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
93
93
  "gpt-4.1": process.env.GPT_4_1_CONTEXT || "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
@@ -147,6 +147,9 @@ class DirAskGPTV2 {
147
147
  if (action.reranking) {
148
148
  reranking = action.reranking;
149
149
  }
150
+ if (action.skip_unanswered) {
151
+ skip_unanswered = action.skip_unanswered;
152
+ }
150
153
 
151
154
  let requestVariables = null;
152
155
  requestVariables =
@@ -339,6 +342,12 @@ class DirAskGPTV2 {
339
342
  if (ns.hybrid === true) {
340
343
  json.search_type = 'hybrid';
341
344
  json.alpha = alpha;
345
+
346
+ if (reranking === true) {
347
+ json.reranking = true;
348
+ json.reranking_multiplier = 3;
349
+ json.reranker_model = "cross-encoder/ms-marco-MiniLM-L-6-v2";
350
+ }
342
351
  }
343
352
 
344
353
  if (!action.advancedPrompt) {
@@ -356,12 +365,6 @@ class DirAskGPTV2 {
356
365
  json.chat_history_dict = await this.transcriptToLLM(transcript);
357
366
  }
358
367
 
359
- if (reranking === true) {
360
- json.reranking = true;
361
- json.reranking_multiplier = 3;
362
- json.reranker_model = "cross-encoder/ms-marco-MiniLM-L-6-v2";
363
- }
364
-
365
368
  winston.debug("DirAskGPTV2 json:", json);
366
369
 
367
370
  let kb_endpoint = process.env.KB_ENDPOINT_QA;
@@ -385,7 +388,11 @@ class DirAskGPTV2 {
385
388
  HTTPREQUEST, async (err, resbody) => {
386
389
 
387
390
  if (err) {
388
- winston.error("DirAskGPTV2 error: ", err?.response);
391
+ winston.error("DirAskGPTV2 error: ", {
392
+ status: err.response?.status,
393
+ statusText: err.response?.statusText,
394
+ data: err.response?.data,
395
+ });
389
396
  this.logger.error(`[Ask Knowledge Base] Error getting answer`);
390
397
  await this.#assignAttributes(action, answer, source);
391
398
  if (callback) {
@@ -434,7 +441,11 @@ class DirAskGPTV2 {
434
441
  await this.#assignAttributes(action, answer, source);
435
442
  if (!skip_unanswered) {
436
443
  kbService.addUnansweredQuestion(this.projectId, json.namespace, json.question, this.token).catch((err) => {
437
- winston.error("DirAskGPTV2 - Error adding unanswered question: ", err);
444
+ winston.error("DirAskGPTV2 - Error adding unanswered question: ", {
445
+ status: err.response?.status,
446
+ statusText: err.response?.statusText,
447
+ data: err.response?.data,
448
+ });
438
449
  this.logger.warn("[Ask Knowledge Base] Unable to add unanswered question", json.question, "to namespacae", json.namespace);
439
450
  })
440
451
  }