@tiledesk/tiledesk-tybot-connector 2.0.44 → 2.0.46

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.
@@ -0,0 +1,57 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const modelMap = {
5
+ "gpt-3.5-turbo": "gpt-3.5.txt",
6
+ "gpt-4": "gpt-4.txt",
7
+ "gpt-4-turbo-preview": "gpt-4.txt",
8
+ "gpt-4o": "gpt-4o.txt",
9
+ "gpt-4o-mini": "gpt-4o.txt",
10
+ "gpt-4.1": "gpt-4.1.txt",
11
+ "gpt-4.1-mini": "gpt-4.1.txt",
12
+ "gpt-4.1-nano": "gpt-4.1.txt",
13
+ "gpt-5": "gpt-5.txt",
14
+ "gpt-5-mini": "gpt-5.txt",
15
+ "gpt-5-nano": "gpt-5.txt",
16
+ "gpt-5.1": "gpt-5.x.txt",
17
+ "gpt-5.2": "gpt-5.x.txt",
18
+ "gpt-5.3-chat-latest": "gpt-5.x.txt",
19
+ "gpt-5.4": "gpt-5.x.txt",
20
+ "gpt-5.4-mini": "gpt-5.x.txt",
21
+ "gpt-5.4-nano": "gpt-5.x.txt",
22
+ "general": "general.txt"
23
+ }
24
+
25
+
26
+ class PromptManager {
27
+
28
+ constructor(basePath) {
29
+ this.basePath = basePath;
30
+ this.cache = new Map();
31
+ }
32
+
33
+ getPrompt(name) {
34
+ if (this.cache.has(name)) {
35
+ return this.cache.get(name);
36
+ }
37
+
38
+ const fileName = modelMap[name] || modelMap["general"];
39
+ const filePath = path.join(this.basePath, fileName);
40
+
41
+ let content;
42
+ try {
43
+ content = fs.readFileSync(filePath, 'utf-8');
44
+ } catch (err) {
45
+ content = fs.readFileSync(
46
+ path.join(this.basePath, modelMap["general"]),
47
+ 'utf-8'
48
+ );
49
+ }
50
+
51
+ this.cache.set(name, content);
52
+ return content;
53
+ }
54
+ }
55
+
56
+ PromptManager.modelMap = modelMap;
57
+ module.exports = PromptManager;
@@ -0,0 +1,9 @@
1
+ You are an helpful assistant for question-answering tasks. Follow these steps carefully:
2
+
3
+ 1. Answer in the same language of the user question, regardless of the retrieved context language
4
+ 2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.
5
+ 3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer.
6
+
7
+ ==Retrieved context start==
8
+ {context}
9
+ ==Retrieved context end==
@@ -0,0 +1,9 @@
1
+ You are an helpful assistant for question-answering tasks.
2
+
3
+ Use ONLY the pieces of retrieved context delimited by #### and the chat history to answer the question.
4
+
5
+ If you don't know the answer, just say: "I don't know<NOANS>"
6
+
7
+ ####
8
+ {context}
9
+ ####
@@ -0,0 +1,9 @@
1
+ You are an helpful assistant for question-answering tasks. Follow these steps carefully:
2
+
3
+ 1. Answer in the same language of the user question, regardless of the retrieved context language
4
+ 2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.
5
+ 3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, append <NOANS> at the end of the answer
6
+
7
+ ==Retrieved context start==
8
+ {context}
9
+ ==Retrieved context end==
@@ -0,0 +1,11 @@
1
+ You are an helpful assistant for question-answering tasks.
2
+
3
+ Use ONLY the pieces of retrieved context delimited by #### and the chat history to answer the question.
4
+
5
+ If you don't know the answer, just say that you don't know.
6
+
7
+ If and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>
8
+
9
+ ####
10
+ {context}
11
+ ####
@@ -0,0 +1,9 @@
1
+ You are an helpful assistant for question-answering tasks. Follow these steps carefully:
2
+
3
+ 1. Answer in the same language of the user question, regardless of the retrieved context language
4
+ 2. Use ONLY the pieces of the retrieved context and the chat history to answer the question.
5
+ 3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>.
6
+
7
+ ==Retrieved context start==
8
+ {context}
9
+ ==Retrieved context end==
@@ -0,0 +1,32 @@
1
+ # ROLE
2
+ You are an AI assistant that answers the user's question using only the information contained in the provided context.
3
+
4
+ # LANGUAGE
5
+ Answer in the same language as the user's question.
6
+
7
+ # CONTEXT
8
+ You will receive a context delimited by ######:
9
+ ######
10
+ {context}
11
+ ######
12
+
13
+ # INSTRUCTIONS
14
+ - Use only the information explicitly contained in the context.
15
+ - Answer the user's question directly, as a human assistant would.
16
+ - Do not mention the context, the document, the source, or the fact that information was provided.
17
+ - Do not say phrases such as:
18
+ - "according to the context"
19
+ - "in the provided context"
20
+ - "the document says"
21
+ - "based on the information provided"
22
+ - Do not explain your reasoning.
23
+ - Do not repeat the question.
24
+ - Keep the answer concise, clear, and natural.
25
+ - Do not add assumptions, external knowledge, or details not supported by the context.
26
+
27
+ # FALLBACK
28
+ If the context does not contain enough information to answer the question, reply with exactly:
29
+ <NOANS>
30
+
31
+ # OUTPUT
32
+ Return only the final answer, with no preamble and no meta-commentary.
@@ -0,0 +1,32 @@
1
+ # ROLE
2
+ You are an AI assistant that answers the user's question using only the information contained in the provided context.
3
+
4
+ # LANGUAGE
5
+ Answer in the same language as the user's question.
6
+
7
+ # CONTEXT
8
+ You will receive a context delimited by ######:
9
+ ######
10
+ {context}
11
+ ######
12
+
13
+ # INSTRUCTIONS
14
+ - Use only the information explicitly contained in the context.
15
+ - Answer the user's question directly, as a human assistant would.
16
+ - Do not mention the context, the document, the source, or the fact that information was provided.
17
+ - Do not say phrases such as:
18
+ - "according to the context"
19
+ - "in the provided context"
20
+ - "the document says"
21
+ - "based on the information provided"
22
+ - Do not explain your reasoning.
23
+ - Do not repeat the question.
24
+ - Keep the answer concise, clear, and natural.
25
+ - Do not add assumptions, external knowledge, or details not supported by the context.
26
+
27
+ # FALLBACK
28
+ If the context does not contain enough information to answer the question, reply with exactly:
29
+ <NOANS>
30
+
31
+ # OUTPUT
32
+ Return only the final answer, with no preamble and no meta-commentary.
package/logs/app.log CHANGED
@@ -1409,3 +1409,95 @@ error: Axios error response data: <!DOCTYPE html>
1409
1409
  </html>
1410
1410
 
1411
1411
  error: DirAiPrompt openai err:
1412
+ error: (Tilebot) Redis connection error: connect ECONNREFUSED 127.0.0.1:6379 {"address":"127.0.0.1","code":"ECONNREFUSED","errno":-61,"port":6379,"stack":"Error: connect ECONNREFUSED 127.0.0.1:6379\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16)","syscall":"connect"}
1413
+ error: (Tilebot) Redis connection error: connect ECONNREFUSED 127.0.0.1:6379 {"address":"127.0.0.1","code":"ECONNREFUSED","errno":-61,"port":6379,"stack":"Error: connect ECONNREFUSED 127.0.0.1:6379\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16)","syscall":"connect"}
1414
+ error: Axios error response data: <!DOCTYPE html>
1415
+ <html lang="en">
1416
+ <head>
1417
+ <meta charset="utf-8">
1418
+ <title>Error</title>
1419
+ </head>
1420
+ <body>
1421
+ <pre>AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:<br><br> &nbsp;assert(req.body.model.model === &quot;gemini-2.0&quot;)<br><br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/test/conversation-askgptv2_test.js:276:7<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/body-parser/lib/read.js:137:5<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>
1422
+ </body>
1423
+ </html>
1424
+
1425
+ error: DirAskGPTV2 error: {"data":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:<br><br> &nbsp;assert(req.body.model.model === &quot;gemini-2.0&quot;)<br><br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/test/conversation-askgptv2_test.js:276:7<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/body-parser/lib/read.js:137:5<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>\n</body>\n</html>\n","status":500,"statusText":"Internal Server Error"}
1426
+ error: uncaughtException: listen EADDRINUSE: address already in use 0.0.0.0:10002
1427
+ Error: listen EADDRINUSE: address already in use 0.0.0.0:10002
1428
+ at Server.setupListenHandle [as _listen2] (node:net:1432:16)
1429
+ at listenInCluster (node:net:1480:12)
1430
+ at doListen (node:net:1629:7)
1431
+ at processTicksAndRejections (node:internal/process/task_queues:84:21) {"date":"Thu Apr 02 2026 10:25:31 GMT+0200 (Ora legale dell’Europa centrale)","error":{"address":"0.0.0.0","code":"EADDRINUSE","errno":-48,"port":10002,"syscall":"listen"},"exception":true,"os":{"loadavg":[3.0126953125,3.62158203125,3.65625],"uptime":494332},"process":{"argv":["/Users/johnny/.nvm/versions/node/v16.17.0/bin/node","/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/.bin/mocha","./test/conversation-askgptv2_test.js","--exit"],"cwd":"/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute","execPath":"/Users/johnny/.nvm/versions/node/v16.17.0/bin/node","gid":20,"memoryUsage":{"arrayBuffers":18700570,"external":20253180,"heapTotal":80199680,"heapUsed":48400704,"rss":128106496},"pid":58131,"uid":501,"version":"v16.17.0"},"stack":"Error: listen EADDRINUSE: address already in use 0.0.0.0:10002\n at Server.setupListenHandle [as _listen2] (node:net:1432:16)\n at listenInCluster (node:net:1480:12)\n at doListen (node:net:1629:7)\n at processTicksAndRejections (node:internal/process/task_queues:84:21)","trace":[{"column":16,"file":"node:net","function":"Server.setupListenHandle [as _listen2]","line":1432,"method":"setupListenHandle [as _listen2]","native":false},{"column":12,"file":"node:net","function":"listenInCluster","line":1480,"method":null,"native":false},{"column":7,"file":"node:net","function":"doListen","line":1629,"method":null,"native":false},{"column":21,"file":"node:internal/process/task_queues","function":"processTicksAndRejections","line":84,"method":null,"native":false}]}
1432
+ error: uncaughtException: listen EADDRINUSE: address already in use 0.0.0.0:10002
1433
+ Error: listen EADDRINUSE: address already in use 0.0.0.0:10002
1434
+ at Server.setupListenHandle [as _listen2] (node:net:1432:16)
1435
+ at listenInCluster (node:net:1480:12)
1436
+ at doListen (node:net:1629:7)
1437
+ at processTicksAndRejections (node:internal/process/task_queues:84:21) {"date":"Thu Apr 02 2026 10:25:31 GMT+0200 (Ora legale dell’Europa centrale)","error":{"address":"0.0.0.0","code":"EADDRINUSE","errno":-48,"port":10002,"syscall":"listen"},"exception":true,"os":{"loadavg":[3.0126953125,3.62158203125,3.65625],"uptime":494332},"process":{"argv":["/Users/johnny/.nvm/versions/node/v16.17.0/bin/node","/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/.bin/mocha","./test/conversation-askgptv2_test.js","--exit"],"cwd":"/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute","execPath":"/Users/johnny/.nvm/versions/node/v16.17.0/bin/node","gid":20,"memoryUsage":{"arrayBuffers":18708786,"external":20261436,"heapTotal":80199680,"heapUsed":48475640,"rss":128122880},"pid":58131,"uid":501,"version":"v16.17.0"},"stack":"Error: listen EADDRINUSE: address already in use 0.0.0.0:10002\n at Server.setupListenHandle [as _listen2] (node:net:1432:16)\n at listenInCluster (node:net:1480:12)\n at doListen (node:net:1629:7)\n at processTicksAndRejections (node:internal/process/task_queues:84:21)","trace":[{"column":16,"file":"node:net","function":"Server.setupListenHandle [as _listen2]","line":1432,"method":"setupListenHandle [as _listen2]","native":false},{"column":12,"file":"node:net","function":"listenInCluster","line":1480,"method":null,"native":false},{"column":7,"file":"node:net","function":"doListen","line":1629,"method":null,"native":false},{"column":21,"file":"node:internal/process/task_queues","function":"processTicksAndRejections","line":84,"method":null,"native":false}]}
1438
+ error: Axios error response data: <!DOCTYPE html>
1439
+ <html lang="en">
1440
+ <head>
1441
+ <meta charset="utf-8">
1442
+ <title>Error</title>
1443
+ </head>
1444
+ <body>
1445
+ <pre>AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:<br><br> &nbsp;assert(req.body.system_context === &quot;this is the context: sei un assistente fantastico\nYou 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&#39;t know the answer, just say that you don&#39;t know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end &lt;NOANS&gt;\n\n####{context}####&quot;)<br><br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/test/conversation-askgptv2_test.js:445:7<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/body-parser/lib/read.js:137:5<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>
1446
+ </body>
1447
+ </html>
1448
+
1449
+ error: DirAskGPTV2 error: {"data":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:<br><br> &nbsp;assert(req.body.system_context === &quot;this is the context: sei un assistente fantastico\\nYou 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&#39;t know the answer, just say that you don&#39;t know.\\nIf and only if none of the retrieved context is useful for your task, add this word to the end &lt;NOANS&gt;\\n\\n####{context}####&quot;)<br><br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/test/conversation-askgptv2_test.js:445:7<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/body-parser/lib/read.js:137:5<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>\n</body>\n</html>\n","status":500,"statusText":"Internal Server Error"}
1450
+ error: Axios error response data: <!DOCTYPE html>
1451
+ <html lang="en">
1452
+ <head>
1453
+ <meta charset="utf-8">
1454
+ <title>Error</title>
1455
+ </head>
1456
+ <body>
1457
+ <pre>AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:<br><br> &nbsp;assert(req.body.system_context === &quot;this is the context: sei un assistente fantastico\nYou 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&#39;t know the answer, just say that you don&#39;t know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end &lt;NOANS&gt;\n\n####{context}####&quot;)<br><br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/test/conversation-askgptv2_test.js:446:7<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/body-parser/lib/read.js:137:5<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>
1458
+ </body>
1459
+ </html>
1460
+
1461
+ error: DirAskGPTV2 error: {"data":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:<br><br> &nbsp;assert(req.body.system_context === &quot;this is the context: sei un assistente fantastico\\nYou 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&#39;t know the answer, just say that you don&#39;t know.\\nIf and only if none of the retrieved context is useful for your task, add this word to the end &lt;NOANS&gt;\\n\\n####{context}####&quot;)<br><br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/test/conversation-askgptv2_test.js:446:7<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/body-parser/lib/read.js:137:5<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>\n</body>\n</html>\n","status":500,"statusText":"Internal Server Error"}
1462
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1463
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
1464
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1465
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
1466
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1467
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
1468
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1469
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
1470
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1471
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
1472
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1473
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
1474
+ error: Axios error response data: <!DOCTYPE html>
1475
+ <html lang="en">
1476
+ <head>
1477
+ <meta charset="utf-8">
1478
+ <title>Error</title>
1479
+ </head>
1480
+ <body>
1481
+ <pre>Error: ENOENT: no such file or directory, open &#39;/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/config/kb/prompt/rag/gpt-4.txt&#39;<br> &nbsp; &nbsp;at Object.openSync (node:fs:594:3)<br> &nbsp; &nbsp;at Object.readFileSync (node:fs:462:35)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/test/conversation-askgptv2_test.js:450:34<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/body-parser/lib/read.js:137:5<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>
1482
+ </body>
1483
+ </html>
1484
+
1485
+ error: DirAskGPTV2 error: {"data":"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Error: ENOENT: no such file or directory, open &#39;/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/config/kb/prompt/rag/gpt-4.txt&#39;<br> &nbsp; &nbsp;at Object.openSync (node:fs:594:3)<br> &nbsp; &nbsp;at Object.readFileSync (node:fs:462:35)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/test/conversation-askgptv2_test.js:450:34<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:144:13)<br> &nbsp; &nbsp;at Route.dispatch (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/route.js:114:3)<br> &nbsp; &nbsp;at Layer.handle [as handle_request] (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/layer.js:95:5)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:284:15<br> &nbsp; &nbsp;at Function.process_params (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:346:12)<br> &nbsp; &nbsp;at next (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/express/lib/router/index.js:280:10)<br> &nbsp; &nbsp;at /Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/body-parser/lib/read.js:137:5<br> &nbsp; &nbsp;at AsyncResource.runInAsyncScope (node:async_hooks:203:9)<br> &nbsp; &nbsp;at invokeCallback (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:231:16)<br> &nbsp; &nbsp;at done (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:220:7)<br> &nbsp; &nbsp;at IncomingMessage.onEnd (/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/raw-body/index.js:280:7)<br> &nbsp; &nbsp;at IncomingMessage.emit (node:events:525:35)<br> &nbsp; &nbsp;at endReadableNT (node:internal/streams/readable:1358:12)<br> &nbsp; &nbsp;at processTicksAndRejections (node:internal/process/task_queues:83:21)</pre>\n</body>\n</html>\n","status":500,"statusText":"Internal Server Error"}
1486
+ error: uncaughtException: listen EADDRINUSE: address already in use 0.0.0.0:10002
1487
+ Error: listen EADDRINUSE: address already in use 0.0.0.0:10002
1488
+ at Server.setupListenHandle [as _listen2] (node:net:1432:16)
1489
+ at listenInCluster (node:net:1480:12)
1490
+ at doListen (node:net:1629:7)
1491
+ at processTicksAndRejections (node:internal/process/task_queues:84:21) {"date":"Thu Apr 02 2026 11:01:41 GMT+0200 (Ora legale dell’Europa centrale)","error":{"address":"0.0.0.0","code":"EADDRINUSE","errno":-48,"port":10002,"syscall":"listen"},"exception":true,"os":{"loadavg":[11.45556640625,6.91943359375,4.96435546875],"uptime":496502},"process":{"argv":["/Users/johnny/.nvm/versions/node/v16.17.0/bin/node","/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/.bin/mocha","./test/conversation-askgptv2_test.js","--exit"],"cwd":"/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute","execPath":"/Users/johnny/.nvm/versions/node/v16.17.0/bin/node","gid":20,"memoryUsage":{"arrayBuffers":18707410,"external":20331988,"heapTotal":78626816,"heapUsed":50465376,"rss":127926272},"pid":1425,"uid":501,"version":"v16.17.0"},"stack":"Error: listen EADDRINUSE: address already in use 0.0.0.0:10002\n at Server.setupListenHandle [as _listen2] (node:net:1432:16)\n at listenInCluster (node:net:1480:12)\n at doListen (node:net:1629:7)\n at processTicksAndRejections (node:internal/process/task_queues:84:21)","trace":[{"column":16,"file":"node:net","function":"Server.setupListenHandle [as _listen2]","line":1432,"method":"setupListenHandle [as _listen2]","native":false},{"column":12,"file":"node:net","function":"listenInCluster","line":1480,"method":null,"native":false},{"column":7,"file":"node:net","function":"doListen","line":1629,"method":null,"native":false},{"column":21,"file":"node:internal/process/task_queues","function":"processTicksAndRejections","line":84,"method":null,"native":false}]}
1492
+ error: uncaughtException: listen EADDRINUSE: address already in use 0.0.0.0:10002
1493
+ Error: listen EADDRINUSE: address already in use 0.0.0.0:10002
1494
+ at Server.setupListenHandle [as _listen2] (node:net:1432:16)
1495
+ at listenInCluster (node:net:1480:12)
1496
+ at doListen (node:net:1629:7)
1497
+ at processTicksAndRejections (node:internal/process/task_queues:84:21) {"date":"Thu Apr 02 2026 11:01:41 GMT+0200 (Ora legale dell’Europa centrale)","error":{"address":"0.0.0.0","code":"EADDRINUSE","errno":-48,"port":10002,"syscall":"listen"},"exception":true,"os":{"loadavg":[11.45556640625,6.91943359375,4.96435546875],"uptime":496502},"process":{"argv":["/Users/johnny/.nvm/versions/node/v16.17.0/bin/node","/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute/node_modules/.bin/mocha","./test/conversation-askgptv2_test.js","--exit"],"cwd":"/Users/johnny/Documents/Tiledesk/tiledesk-chatbot/tybotRoute","execPath":"/Users/johnny/.nvm/versions/node/v16.17.0/bin/node","gid":20,"memoryUsage":{"arrayBuffers":18707434,"external":20332052,"heapTotal":78626816,"heapUsed":50540128,"rss":127942656},"pid":1425,"uid":501,"version":"v16.17.0"},"stack":"Error: listen EADDRINUSE: address already in use 0.0.0.0:10002\n at Server.setupListenHandle [as _listen2] (node:net:1432:16)\n at listenInCluster (node:net:1480:12)\n at doListen (node:net:1629:7)\n at processTicksAndRejections (node:internal/process/task_queues:84:21)","trace":[{"column":16,"file":"node:net","function":"Server.setupListenHandle [as _listen2]","line":1432,"method":"setupListenHandle [as _listen2]","native":false},{"column":12,"file":"node:net","function":"listenInCluster","line":1480,"method":null,"native":false},{"column":7,"file":"node:net","function":"doListen","line":1629,"method":null,"native":false},{"column":21,"file":"node:internal/process/task_queues","function":"processTicksAndRejections","line":84,"method":null,"native":false}]}
1498
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1499
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
1500
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1501
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
1502
+ error: Axios error response data: {"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false}
1503
+ error: DirAskGPTV2 error: {"data":{"error":{"answer":"No answer","chat_history_dict":{},"citations":null,"content_chunks":null,"error_message":"IndexError('list index out of range')","id":null,"ids":null,"namespace":"66ec24a028a0c600130baa6a","prompt_token_size":0,"source":null,"sources":null,"success":false},"statusText":"Bad Request","success":false},"status":400,"statusText":"Bad Request"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "2.0.44",
3
+ "version": "2.0.46",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,6 +32,7 @@
32
32
  "mqtt": "^5.10.4",
33
33
  "multer": "^1.4.5-lts.1",
34
34
  "nanoid": "^3.1.25",
35
+ "path": "^0.12.7",
35
36
  "redis": "^4.7.0",
36
37
  "string-argv": "^0.3.2",
37
38
  "uuid": "^3.3.3",
@@ -158,6 +158,10 @@ class DirAddKbContent {
158
158
  name: filled_name,
159
159
  source: filled_name
160
160
  };
161
+
162
+ if (action.tags && Array.isArray(action.tags) && action.tags.every(tag => typeof tag === "string")) {
163
+ json .tags = action.tags;
164
+ }
161
165
 
162
166
  winston.debug("[DirAddKbContent] json:", json);
163
167
 
@@ -80,14 +80,19 @@ class DirAddTags {
80
80
  const filled_tags = filler.fill(action.tags, requestVariables);
81
81
  winston.debug("(DirAddTags) filled_tags: ", filled_tags);
82
82
 
83
+ console.log("action.tags: ", action.tags);
84
+ console.log("filled_tags: ", filled_tags);
85
+
83
86
  /** use case: CONVERSATION */
84
87
  if(target === 'request'){
85
88
 
86
89
  let newTags = filled_tags.split(',').filter(tag => tag !== '').map(el => el.trim())
87
90
  this.logger.native("[Add Tag] Adding following tags to conversation: ", newTags)
91
+ console.log("newTags: ", newTags);
88
92
 
89
93
  if(action.pushToList){
90
94
  newTags.forEach(async (tag) => {
95
+ console.log("add new tag: ", tag);
91
96
  let tags = await this.addNewTag(tag)
92
97
  if(!tags){
93
98
  callback();
@@ -97,6 +102,7 @@ class DirAddTags {
97
102
  }
98
103
 
99
104
  winston.debug('(DirAddTags) UPDATE request with newTags', newTags)
105
+ console.log("update request with newTags: ", newTags);
100
106
  let updatedRequest = await this.updateRequestWithTags(newTags)
101
107
  this.logger.native("[Add Tag] Tags added to conversation")
102
108
  if(!updatedRequest){
@@ -196,7 +202,9 @@ class DirAddTags {
196
202
  return new Promise((resolve) => {
197
203
  let json = []
198
204
  let filteredTags = tags.map((tag) => ({tag: tag, color: '#f0806f'}))
205
+ console.log("tags: ", tags);
199
206
  json.push(...filteredTags)
207
+ console.log("json: ", json);
200
208
  winston.debug('(httprequest) DirAddTags updateRequestWithTags tags: ', json)
201
209
  const HTTPREQUEST = {
202
210
  url: this.API_ENDPOINT + "/" + this.context.projectId + "/requests/" + this.requestId + '/tag',
@@ -2,6 +2,7 @@ const axios = require("axios").default;
2
2
  const { TiledeskChatbot } = require('../../engine/TiledeskChatbot');
3
3
  const { Filler } = require('../Filler');
4
4
  let https = require("https");
5
+ var path = require('path');
5
6
  const { DirIntent } = require("./DirIntent");
6
7
  const { TiledeskChatbotConst } = require("../../engine/TiledeskChatbotConst");
7
8
  const { TiledeskChatbotUtil } = require("../../utils/TiledeskChatbotUtil");
@@ -17,6 +18,39 @@ const aiController = require("../../services/AIController");
17
18
  const default_engine = require('../../config/kb/engine');
18
19
  const default_engine_hybrid = require('../../config/kb/engine.hybrid');
19
20
  const default_embedding = require("../../config/kb/embedding");
21
+ const PromptManager = require('../../config/kb/prompt/rag/PromptManager');
22
+
23
+ //const ragPromptManager = new PromptManager(path.join(__dirname, '../../config/kb/prompt/rag'));
24
+ const ragPromptManager = new PromptManager(path.join(__dirname, '../../config/kb/prompt/rag'));
25
+
26
+ const RAG_CONTEXT_ENV_OVERRIDES = {
27
+ "gpt-3.5-turbo": process.env.GPT_3_5_CONTEXT,
28
+ "gpt-4": process.env.GPT_4_CONTEXT,
29
+ "gpt-4-turbo-preview": process.env.GPT_4T_CONTEXT,
30
+ "gpt-4o": process.env.GPT_4O_CONTEXT,
31
+ "gpt-4o-mini": process.env.GPT_4O_MINI_CONTEXT,
32
+ "gpt-4.1": process.env.GPT_4_1_CONTEXT,
33
+ "gpt-4.1-mini": process.env.GPT_4_1_MINI_CONTEXT,
34
+ "gpt-4.1-nano": process.env.GPT_4_1_NANO_CONTEXT,
35
+ "gpt-5": process.env.GPT_5_CONTEXT,
36
+ "gpt-5-mini": process.env.GPT_5_MINI_CONTEXT,
37
+ "gpt-5-nano": process.env.GPT_5_NANO_CONTEXT,
38
+ "general": process.env.GENERAL_CONTEXT
39
+ };
40
+
41
+ /** RAG system prompt per modello: file in config/kb/prompt/rag, sovrascrivibili via env (come prima). */
42
+ function getRagContextTemplate(modelName) {
43
+ const envOverride = RAG_CONTEXT_ENV_OVERRIDES[modelName];
44
+ if (envOverride) {
45
+ return envOverride;
46
+ }
47
+ if (!PromptManager.modelMap[modelName] && process.env.GENERAL_CONTEXT) {
48
+ return process.env.GENERAL_CONTEXT;
49
+ }
50
+ return ragPromptManager.getPrompt(modelName);
51
+ }
52
+
53
+ const PINECONE_RERANKING = process.env.PINECONE_RERANKING === true || process.env.PINECONE_RERANKING === "true";
20
54
 
21
55
  class DirAskGPTV2 {
22
56
 
@@ -77,9 +111,9 @@ class DirAskGPTV2 {
77
111
  let namespace = this.context.projectId;
78
112
  let llm = "openai";
79
113
  let model;
80
- let temperature;
81
- let max_tokens;
82
- let top_k;
114
+ let temperature = 0.7;
115
+ let max_tokens = 256;
116
+ let top_k = 4;
83
117
  let alpha;
84
118
  let transcript;
85
119
  let citations = false;
@@ -87,24 +121,10 @@ class DirAskGPTV2 {
87
121
  let engine;
88
122
  let embedding;
89
123
  let reranking;
124
+ let reranking_multiplier;
90
125
  let skip_unanswered = false;
91
-
92
- let contexts = {
93
- "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}####",
94
- "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}####",
95
- "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}####",
96
- "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==",
97
- "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==",
98
- "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==",
99
- "gpt-4.1-mini": process.env.GPT_4_1_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, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
100
- "gpt-4.1-nano": process.env.GPT_4_1_NANO_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==",
101
- "gpt-5": process.env.GPT_5_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==",
102
- "gpt-5-mini": process.env.GPT_5_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, append <NOANS> at the end of the answer\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
103
- "gpt-5-nano": process.env.GPT_5_NANO_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==",
104
- "general": process.env.GENERAL_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=="
105
- }
106
-
107
126
  let source = null;
127
+
108
128
  if (!action.llm) {
109
129
  action.llm = "openai";
110
130
  }
@@ -152,6 +172,9 @@ class DirAskGPTV2 {
152
172
  if (action.reranking) {
153
173
  reranking = action.reranking;
154
174
  }
175
+ if (action.reranking_multiplier) {
176
+ reranking_multiplier = action.reranking_multiplier;
177
+ }
155
178
  if (action.skip_unanswered) {
156
179
  skip_unanswered = action.skip_unanswered;
157
180
  }
@@ -321,13 +344,43 @@ class DirAskGPTV2 {
321
344
 
322
345
  if (reranking === true) {
323
346
  json.reranking = true;
324
- json.reranking_multiplier = 3;
347
+ json.reranking_multiplier = reranking_multiplier || 3;
325
348
  json.reranker_model = "cross-encoder/ms-marco-MiniLM-L-6-v2";
349
+
350
+ if ((top_k * reranking_multiplier) > 100) {
351
+ // Find the largest integer reranking_multiplier so that top_k * reranking_multiplier <= 100
352
+ let calculatedRerankingMultiplier = Math.floor(100 / top_k);
353
+ // At least 1 is required
354
+ if (calculatedRerankingMultiplier < 1) {
355
+ calculatedRerankingMultiplier = 1;
356
+ }
357
+ json.reranking_multiplier = calculatedRerankingMultiplier;
358
+ }
359
+ }
360
+ }
361
+
362
+ if (!ns.hybrid && reranking === true && PINECONE_RERANKING) {
363
+ json.reranking = {
364
+ "provider": "pinecone",
365
+ "api_key": process.env.PINECONE_API_KEY,
366
+ "model": process.env.PINECONE_RERANKING_MODEL || process.env.RERANKING_MODEL || "bge-reranker-v2-m3"
367
+ }
368
+
369
+ json.reranking_multiplier = reranking_multiplier || 3;
370
+ if ((top_k * reranking_multiplier) > 100) {
371
+ // Find the largest integer reranking_multiplier so that top_k * reranking_multiplier <= 100
372
+ let calculatedRerankingMultiplier = Math.floor(100 / top_k);
373
+ // At least 1 is required
374
+ if (calculatedRerankingMultiplier < 1) {
375
+ calculatedRerankingMultiplier = 1;
376
+ }
377
+ json.reranking_multiplier = calculatedRerankingMultiplier;
326
378
  }
327
379
  }
328
380
 
329
381
  if (!action.advancedPrompt) {
330
- const contextTemplate = contexts[model.name] || contexts["general"];
382
+ const contextTemplate = getRagContextTemplate(model.name);
383
+
331
384
  if (filled_context) {
332
385
  json.system_context = filled_context + "\n" + contextTemplate;
333
386
  } else {
@@ -341,6 +394,10 @@ class DirAskGPTV2 {
341
394
  json.chat_history_dict = await this.transcriptToLLM(transcript);
342
395
  }
343
396
 
397
+ if (action.tags && Array.isArray(action.tags) && action.tags.every(tag => typeof tag === "string")) {
398
+ json.tags = action.tags;
399
+ }
400
+
344
401
  winston.debug("DirAskGPTV2 json:", json);
345
402
 
346
403
  let kb_endpoint = process.env.KB_ENDPOINT_QA;
@@ -413,6 +470,7 @@ class DirAskGPTV2 {
413
470
  return;
414
471
  }
415
472
  } else {
473
+ winston.info("DirAskGPTV2 resbody else case: ", resbody);
416
474
  await this.#assignAttributes(action, answer, source);
417
475
  if (!skip_unanswered) {
418
476
  kbService.addUnansweredQuestion(this.projectId, json.namespace, json.question, this.token).catch((err) => {