@tiledesk/tiledesk-server 2.13.22 → 2.13.24
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 +8 -0
- package/config/labels/widget.json +61 -16
- package/package.json +3 -3
- package/pubmodules/events/eventRoute.js +2 -42
- package/routes/faq_kb.js +18 -6
- package/routes/kb.js +64 -9
- package/routes/webhooks.js +2 -2
- package/services/integrationService.js +50 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
|
|
7
7
|
|
|
8
|
+
# 2.13.24
|
|
9
|
+
- Code improvements
|
|
10
|
+
|
|
11
|
+
# 2.13.23
|
|
12
|
+
- Updated whatsapp-connector to 1.0.9
|
|
13
|
+
- Updated messenger-connector to 0.1.28
|
|
14
|
+
- Code improvements
|
|
15
|
+
|
|
8
16
|
# 2.13.22
|
|
9
17
|
- Updated whatsapp-connector to 1.0.9
|
|
10
18
|
|
|
@@ -96,7 +96,10 @@
|
|
|
96
96
|
"SENT_AN_IMAGE": "sent an image",
|
|
97
97
|
|
|
98
98
|
"LABEL_PREVIEW": "Preview",
|
|
99
|
-
"SWITCH_TO":"Or switch to:"
|
|
99
|
+
"SWITCH_TO":"Or switch to:",
|
|
100
|
+
"MAX_ATTACHMENT": "Max allowed size {{file_size_limit}}Mb",
|
|
101
|
+
"MAX_ATTACHMENT_ERROR": "The file exceeds the maximum allowed size",
|
|
102
|
+
"EMOJI": "Emoji"
|
|
100
103
|
}
|
|
101
104
|
},
|
|
102
105
|
{
|
|
@@ -196,7 +199,10 @@
|
|
|
196
199
|
"SENT_AN_IMAGE":"ha inviato un'immagine",
|
|
197
200
|
|
|
198
201
|
"LABEL_PREVIEW": "Anteprima",
|
|
199
|
-
"SWITCH_TO":"Oppure passa a:"
|
|
202
|
+
"SWITCH_TO":"Oppure passa a:",
|
|
203
|
+
"MAX_ATTACHMENT": "Dimensione massima consentita {{file_size_limit}}Mb",
|
|
204
|
+
"MAX_ATTACHMENT_ERROR": "Il file supera la dimensione massima consentita",
|
|
205
|
+
"EMOJI": "Emoji"
|
|
200
206
|
}
|
|
201
207
|
},
|
|
202
208
|
{
|
|
@@ -296,7 +302,10 @@
|
|
|
296
302
|
"SENT_AN_IMAGE": "envoyé une image",
|
|
297
303
|
|
|
298
304
|
"LABEL_PREVIEW": "Aperçu",
|
|
299
|
-
"SWITCH_TO":"Ou passer à:"
|
|
305
|
+
"SWITCH_TO":"Ou passer à:",
|
|
306
|
+
"MAX_ATTACHMENT": "Taille maximale autorisée {{file_size_limit}}Mb",
|
|
307
|
+
"MAX_ATTACHMENT_ERROR": "Le fichier dépasse la taille maximale autorisée",
|
|
308
|
+
"EMOJI": "Emoji"
|
|
300
309
|
}
|
|
301
310
|
},
|
|
302
311
|
{
|
|
@@ -396,7 +405,10 @@
|
|
|
396
405
|
"SENT_AN_IMAGE": "envió una imagen",
|
|
397
406
|
|
|
398
407
|
"LABEL_PREVIEW": "Avance",
|
|
399
|
-
"SWITCH_TO":"O cambiar a:"
|
|
408
|
+
"SWITCH_TO":"O cambiar a:",
|
|
409
|
+
"MAX_ATTACHMENT": "Tamaño máximo permitido {{file_size_limit}}Mb",
|
|
410
|
+
"MAX_ATTACHMENT_ERROR": "El archivo supera el tamaño máximo permitido",
|
|
411
|
+
"EMOJI": "Emoji"
|
|
400
412
|
}
|
|
401
413
|
},
|
|
402
414
|
{
|
|
@@ -496,7 +508,10 @@
|
|
|
496
508
|
"SENT_AN_IMAGE": "ein Bild gesendet",
|
|
497
509
|
|
|
498
510
|
"LABEL_PREVIEW": "Vorschau",
|
|
499
|
-
"SWITCH_TO":"Oder wechseln Sie zu:"
|
|
511
|
+
"SWITCH_TO":"Oder wechseln Sie zu:",
|
|
512
|
+
"MAX_ATTACHMENT": "Maximal zulässige Größe {{file_size_limit}}Mb",
|
|
513
|
+
"MAX_ATTACHMENT_ERROR": "Die Datei überschreitet die maximal zulässige Größe",
|
|
514
|
+
"EMOJI": "Emoji"
|
|
500
515
|
}
|
|
501
516
|
},
|
|
502
517
|
{
|
|
@@ -596,7 +611,10 @@
|
|
|
596
611
|
"SENT_AN_IMAGE": "enviou uma imagem",
|
|
597
612
|
|
|
598
613
|
"LABEL_PREVIEW": "Visualizar",
|
|
599
|
-
"SWITCH_TO":"Ou mude para:"
|
|
614
|
+
"SWITCH_TO":"Ou mude para:",
|
|
615
|
+
"MAX_ATTACHMENT": "Tamanho máximo permitido {{file_size_limit}}Mb",
|
|
616
|
+
"MAX_ATTACHMENT_ERROR": "O arquivo excede o tamanho máximo permitido",
|
|
617
|
+
"EMOJI": "Emoji"
|
|
600
618
|
}
|
|
601
619
|
},
|
|
602
620
|
{
|
|
@@ -696,7 +714,10 @@
|
|
|
696
714
|
"SENT_AN_IMAGE": "отправил изображение",
|
|
697
715
|
|
|
698
716
|
"LABEL_PREVIEW": "Превью",
|
|
699
|
-
"SWITCH_TO":"Или переключитесь на:"
|
|
717
|
+
"SWITCH_TO":"Или переключитесь на:",
|
|
718
|
+
"MAX_ATTACHMENT": "Максимально допустимый размер {{file_size_limit}}Mb",
|
|
719
|
+
"MAX_ATTACHMENT_ERROR": "Файл превышает максимально допустимый размер",
|
|
720
|
+
"EMOJI": "Эмодзи"
|
|
700
721
|
}
|
|
701
722
|
},
|
|
702
723
|
{
|
|
@@ -796,7 +817,10 @@
|
|
|
796
817
|
"SENT_AN_IMAGE": "bir resim gönderdi",
|
|
797
818
|
|
|
798
819
|
"LABEL_PREVIEW": "Ön izleme",
|
|
799
|
-
"SWITCH_TO":"Veya geçiş yapın:"
|
|
820
|
+
"SWITCH_TO":"Veya geçiş yapın:",
|
|
821
|
+
"MAX_ATTACHMENT": "İzin verilen maksimum boyut {{file_size_limit}}Mb",
|
|
822
|
+
"MAX_ATTACHMENT_ERROR": "Dosya izin verilen maksimum boyutu aşıyor",
|
|
823
|
+
"EMOJI": "Emoji"
|
|
800
824
|
}
|
|
801
825
|
},
|
|
802
826
|
|
|
@@ -898,7 +922,10 @@
|
|
|
898
922
|
"SENT_AN_IMAGE":"послао имаге",
|
|
899
923
|
|
|
900
924
|
"LABEL_PREVIEW": "Преглед",
|
|
901
|
-
"SWITCH_TO":"Или пређите на:"
|
|
925
|
+
"SWITCH_TO":"Или пређите на:",
|
|
926
|
+
"MAX_ATTACHMENT": "Максимално дозвољена величина {{file_size_limit}}Mb",
|
|
927
|
+
"MAX_ATTACHMENT_ERROR": "Фајл прелази максимално дозвољену величину",
|
|
928
|
+
"EMOJI": "Емоџи"
|
|
902
929
|
}
|
|
903
930
|
},
|
|
904
931
|
|
|
@@ -1000,7 +1027,10 @@
|
|
|
1000
1027
|
"SENT_AN_IMAGE": "أرسل صورة",
|
|
1001
1028
|
|
|
1002
1029
|
"LABEL_PREVIEW": "معاينة",
|
|
1003
|
-
"SWITCH_TO": "أو قم بالتبديل إلى:"
|
|
1030
|
+
"SWITCH_TO": "أو قم بالتبديل إلى:",
|
|
1031
|
+
"MAX_ATTACHMENT": "الحد الأقصى للحجم المسموح به {{file_size_limit}}Mb",
|
|
1032
|
+
"MAX_ATTACHMENT_ERROR": "الملف يتجاوز الحد الأقصى المسموح به",
|
|
1033
|
+
"EMOJI": "رموز تعبيرية"
|
|
1004
1034
|
}
|
|
1005
1035
|
},
|
|
1006
1036
|
|
|
@@ -1102,7 +1132,10 @@
|
|
|
1102
1132
|
"SENT_AN_IMAGE": "надіслав зображення",
|
|
1103
1133
|
|
|
1104
1134
|
"LABEL_PREVIEW": "Попередній перегляд",
|
|
1105
|
-
"SWITCH_TO": "Або перейдіть на:"
|
|
1135
|
+
"SWITCH_TO": "Або перейдіть на:",
|
|
1136
|
+
"MAX_ATTACHMENT": "Максимально допустимий розмір {{file_size_limit}}Mb",
|
|
1137
|
+
"MAX_ATTACHMENT_ERROR": "Файл перевищує максимально допустимий розмір",
|
|
1138
|
+
"EMOJI": "Емодзі"
|
|
1106
1139
|
}
|
|
1107
1140
|
},
|
|
1108
1141
|
{
|
|
@@ -1203,7 +1236,10 @@
|
|
|
1203
1236
|
"SENT_AN_IMAGE": "skickade en bild",
|
|
1204
1237
|
|
|
1205
1238
|
"LABEL_PREVIEW": "Förhandsvisning",
|
|
1206
|
-
"SWITCH_TO": "Eller byt till:"
|
|
1239
|
+
"SWITCH_TO": "Eller byt till:",
|
|
1240
|
+
"MAX_ATTACHMENT": "Max tillåten storlek {{file_size_limit}}Mb",
|
|
1241
|
+
"MAX_ATTACHMENT_ERROR": "Filen överskrider den maximalt tillåtna storleken",
|
|
1242
|
+
"EMOJI": "Emoji"
|
|
1207
1243
|
}
|
|
1208
1244
|
},
|
|
1209
1245
|
{
|
|
@@ -1304,7 +1340,10 @@
|
|
|
1304
1340
|
"SENT_AN_IMAGE": "сурет жіберді",
|
|
1305
1341
|
|
|
1306
1342
|
"LABEL_PREVIEW": "Алдын ала қарау",
|
|
1307
|
-
"SWITCH_TO": "Немесе келесіге ауысыңыз:"
|
|
1343
|
+
"SWITCH_TO": "Немесе келесіге ауысыңыз:",
|
|
1344
|
+
"MAX_ATTACHMENT": "Максималды рұқсат етілген өлшем {{file_size_limit}}Mb",
|
|
1345
|
+
"MAX_ATTACHMENT_ERROR": "Файл максималды рұқсат етілген өлшемнен асады",
|
|
1346
|
+
"EMOJI": "Эмодзи"
|
|
1308
1347
|
}
|
|
1309
1348
|
},
|
|
1310
1349
|
{
|
|
@@ -1404,8 +1443,11 @@
|
|
|
1404
1443
|
"SENT_AN_ATTACHMENT": "ilova yubordi",
|
|
1405
1444
|
"SENT_AN_IMAGE": "rasm yubordi",
|
|
1406
1445
|
|
|
1407
|
-
"LABEL_PREVIEW": "Ko
|
|
1408
|
-
"SWITCH_TO": "Yoki o'tish:"
|
|
1446
|
+
"LABEL_PREVIEW": "Ko'rib chiqish",
|
|
1447
|
+
"SWITCH_TO": "Yoki o'tish:",
|
|
1448
|
+
"MAX_ATTACHMENT": "Maksimal ruxsat etilgan o'lcham {{file_size_limit}}Mb",
|
|
1449
|
+
"MAX_ATTACHMENT_ERROR": "Fayl maksimal ruxsat etilgan o'lchamdan oshadi",
|
|
1450
|
+
"EMOJI": "Emoji"
|
|
1409
1451
|
}
|
|
1410
1452
|
},
|
|
1411
1453
|
{
|
|
@@ -1506,7 +1548,10 @@
|
|
|
1506
1548
|
"SENT_AN_IMAGE": "şəkil göndərdi",
|
|
1507
1549
|
|
|
1508
1550
|
"LABEL_PREVIEW": "Önizləmə",
|
|
1509
|
-
"SWITCH_TO": "Və ya keçin:"
|
|
1551
|
+
"SWITCH_TO": "Və ya keçin:",
|
|
1552
|
+
"MAX_ATTACHMENT": "Maksimal icazə verilən ölçü {{file_size_limit}}Mb",
|
|
1553
|
+
"MAX_ATTACHMENT_ERROR": "Fayl maksimal icazə verilən ölçünü aşır",
|
|
1554
|
+
"EMOJI": "Emoji"
|
|
1510
1555
|
}
|
|
1511
1556
|
}
|
|
1512
1557
|
]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiledesk/tiledesk-server",
|
|
3
3
|
"description": "The Tiledesk server module",
|
|
4
|
-
"version": "2.13.
|
|
4
|
+
"version": "2.13.24",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "node ./bin/www",
|
|
7
7
|
"pretest": "mongodb-runner start",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@tiledesk/tiledesk-dialogflow-connector": "^1.8.4",
|
|
45
45
|
"@tiledesk/tiledesk-json-rules-engine": "^4.0.3",
|
|
46
46
|
"@tiledesk/tiledesk-kaleyra-proxy": "^0.1.7",
|
|
47
|
-
"@tiledesk/tiledesk-messenger-connector": "^0.1.
|
|
47
|
+
"@tiledesk/tiledesk-messenger-connector": "^0.1.28",
|
|
48
48
|
"@tiledesk/tiledesk-multi-worker": "^0.3.3",
|
|
49
49
|
"@tiledesk/tiledesk-rasa-connector": "^1.0.10",
|
|
50
50
|
"@tiledesk/tiledesk-sms-connector": "^0.1.11",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@tiledesk/tiledesk-tybot-connector": "^2.0.31",
|
|
53
53
|
"@tiledesk/tiledesk-voice-twilio-connector": "^0.1.22",
|
|
54
54
|
"@tiledesk/tiledesk-vxml-connector": "^0.1.78",
|
|
55
|
-
"@tiledesk/tiledesk-whatsapp-connector": "1.0.
|
|
55
|
+
"@tiledesk/tiledesk-whatsapp-connector": "1.0.10",
|
|
56
56
|
"@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.13",
|
|
57
57
|
"amqplib": "^0.5.5",
|
|
58
58
|
"app-root-path": "^3.0.0",
|
|
@@ -33,57 +33,17 @@ router.post('/', [
|
|
|
33
33
|
return res.status(422).json({ errors: errors.array() });
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
36
|
var pu = undefined;
|
|
38
37
|
if (req.projectuser) { //if the bot creates the event -> pu is undefined
|
|
39
38
|
pu = req.projectuser.id
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// // da qui
|
|
45
|
-
|
|
46
|
-
// performance log
|
|
47
|
-
// console.log("************* emit event"+new Date().toISOString());
|
|
48
|
-
|
|
49
|
-
// // message.senderFullname, message.recipient,
|
|
50
|
-
// // message.recipient_fullname, message.text, message.sender, attributes, message.type, message.metadata, timestamp, message.group
|
|
51
|
-
// var recipient = req.body.attributes.request_id;
|
|
52
|
-
// console.log("recipient",recipient);
|
|
53
|
-
// var sender = req.user.id;
|
|
54
|
-
// console.log("sender",sender);
|
|
55
|
-
|
|
56
|
-
// let message = {
|
|
57
|
-
// recipient: recipient,
|
|
58
|
-
// recipient_fullname: "pluto",
|
|
59
|
-
// // sender:"bb0d809b-b093-419b-8b48-11a192cc3619",
|
|
60
|
-
// sender: sender,
|
|
61
|
-
// senderFullname: "Tiledesk",
|
|
62
|
-
// text:"welcome",
|
|
63
|
-
// group: {
|
|
64
|
-
// members: {
|
|
65
|
-
// // "bb0d809b-b093-419b-8b48-11a192cc3619": 1,
|
|
66
|
-
// // sender: 1
|
|
67
|
-
|
|
68
|
-
// }
|
|
69
|
-
// }
|
|
70
|
-
// };
|
|
71
|
-
// message.group.members[sender]= 1;
|
|
72
|
-
// console.log("message", message)
|
|
73
|
-
|
|
74
|
-
// messageEvent.emit("message.test", message);
|
|
75
|
-
// res.json({"event":"1"});
|
|
76
|
-
|
|
77
|
-
// //fino qui
|
|
78
|
-
|
|
79
|
-
|
|
80
40
|
// // emit(name, attributes, id_project, project_user, createdBy, status, user) {
|
|
81
41
|
eventService.emit(req.body.name, req.body.attributes, req.projectid, pu, req.user.id, undefined, req.user).then(function(event) {
|
|
82
42
|
|
|
83
43
|
res.json(event);
|
|
84
44
|
}).catch(function(err) {
|
|
85
|
-
winston.error('Error saving the event
|
|
86
|
-
return res.status(500).send({success: false, msg: 'Error saving the event
|
|
45
|
+
winston.error('Error saving the event', err);
|
|
46
|
+
return res.status(500).send({success: false, msg: 'Error saving the event', error: err.message });
|
|
87
47
|
});
|
|
88
48
|
|
|
89
49
|
});
|
package/routes/faq_kb.js
CHANGED
|
@@ -681,17 +681,29 @@ router.post('/fork/:id_faq_kb', roleChecker.hasRole('admin'), async (req, res) =
|
|
|
681
681
|
|
|
682
682
|
chatbot.template = "empty";
|
|
683
683
|
|
|
684
|
-
let savedChatbot
|
|
685
|
-
|
|
684
|
+
let savedChatbot
|
|
685
|
+
try {
|
|
686
|
+
savedChatbot = await cs.createBot(api_url, token, chatbot, landing_project_id);
|
|
687
|
+
winston.debug("savedChatbot: ", savedChatbot)
|
|
688
|
+
} catch(err) {
|
|
689
|
+
winston.error("Error creating new chatbot: ", err);
|
|
690
|
+
return res.status(500).send({ success: false, message: "An error occurred during chatbot creation"});
|
|
691
|
+
}
|
|
686
692
|
|
|
687
693
|
if (!savedChatbot) {
|
|
688
694
|
return res.status(500).send({ success: false, message: "Unable to create new chatbot" });
|
|
689
695
|
}
|
|
696
|
+
|
|
697
|
+
let import_result
|
|
698
|
+
try {
|
|
699
|
+
import_result = await cs.importFaqs(api_url, savedChatbot._id, token, chatbot, landing_project_id);
|
|
700
|
+
winston.debug("imported: ", import_result);
|
|
701
|
+
} catch(err) {
|
|
702
|
+
winston.error("Error importing intents on new chatbot: ", err);
|
|
703
|
+
return res.status(500).send({ success: false, message: "Error importing intents in the chatbot"});
|
|
704
|
+
}
|
|
690
705
|
|
|
691
|
-
|
|
692
|
-
winston.debug("imported: ", import_result);
|
|
693
|
-
|
|
694
|
-
if (import_result.success == "false") {
|
|
706
|
+
if (import_result?.success == false) {
|
|
695
707
|
return res.status(500).send({ success: false, message: "Unable to import intents in the new chatbot" });
|
|
696
708
|
}
|
|
697
709
|
|
package/routes/kb.js
CHANGED
|
@@ -19,6 +19,7 @@ var parsecsv = require("fast-csv");
|
|
|
19
19
|
|
|
20
20
|
const { MODELS_MULTIPLIER } = require('../utils/aiUtils');
|
|
21
21
|
const { kbTypes } = require('../models/kbConstants');
|
|
22
|
+
const integrationService = require('../services/integrationService');
|
|
22
23
|
|
|
23
24
|
const AMQP_MANAGER_URL = process.env.AMQP_MANAGER_URL;
|
|
24
25
|
const JOB_TOPIC_EXCHANGE = process.env.JOB_TOPIC_EXCHANGE_TRAIN || 'tiledesk-trainer';
|
|
@@ -269,6 +270,8 @@ router.post('/qa', async (req, res) => {
|
|
|
269
270
|
let project_id = req.projectid;
|
|
270
271
|
let publicKey = false;
|
|
271
272
|
let data = req.body;
|
|
273
|
+
let ollama_integration;
|
|
274
|
+
let vllm_integration;
|
|
272
275
|
|
|
273
276
|
let namespaces = await Namespace.find({ id_project: project_id }).catch((err) => {
|
|
274
277
|
winston.error("find namespaces error: ", err)
|
|
@@ -288,16 +291,45 @@ router.post('/qa', async (req, res) => {
|
|
|
288
291
|
|
|
289
292
|
winston.debug("/qa data: ", data);
|
|
290
293
|
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
if (data.llm === 'ollama') {
|
|
295
|
+
data.gptkey = process.env.GPTKEY;
|
|
296
|
+
try {
|
|
297
|
+
ollama_integration = await integrationService.getIntegration(project_id, 'ollama');
|
|
298
|
+
} catch (err) {
|
|
299
|
+
let error_code = err.code || 500;
|
|
300
|
+
let error_message = err.error || `Unable to get integration for ${data.llm}`;
|
|
301
|
+
return res.status(error_code).send({ success: false, error: error_message });
|
|
296
302
|
}
|
|
297
|
-
|
|
298
|
-
|
|
303
|
+
}
|
|
304
|
+
else if (data.llm === 'vllm') {
|
|
305
|
+
data.gptkey = process.env.GPTKEY;
|
|
306
|
+
try {
|
|
307
|
+
vllm_integration = await integrationService.getIntegration(project_id, 'vllm')
|
|
308
|
+
} catch (err) {
|
|
309
|
+
let error_code = err.code || 500;
|
|
310
|
+
let error_message = err.error || `Unable to get integration for ${data.llm}`;
|
|
311
|
+
return res.status(error_code).send({ success: false, error: error_message });
|
|
312
|
+
}
|
|
313
|
+
} else {
|
|
314
|
+
try {
|
|
315
|
+
let key = await integrationService.getKeyFromIntegration(project_id, data.llm);
|
|
316
|
+
|
|
317
|
+
if (!key) {
|
|
318
|
+
if (data.llm === 'openai') {
|
|
319
|
+
data.gptkey = process.env.GPTKEY;
|
|
320
|
+
publicKey = true;
|
|
321
|
+
} else {
|
|
322
|
+
return res.status(404).send({ success: false, error: `Invalid or empty key provided for ${data.llm}` });
|
|
323
|
+
}
|
|
324
|
+
} else {
|
|
325
|
+
data.gptkey = key;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
} catch (err) {
|
|
329
|
+
let error_code = err.code || 500;
|
|
330
|
+
let error_message = err.error || `Unable to get integration for ${data.llm}`;
|
|
331
|
+
return res.status(error_code).send({ success: false, error: error_message });
|
|
299
332
|
}
|
|
300
|
-
data.gptkey = gptkey;
|
|
301
333
|
}
|
|
302
334
|
|
|
303
335
|
let obj = { createdAt: new Date() };
|
|
@@ -326,7 +358,30 @@ router.post('/qa', async (req, res) => {
|
|
|
326
358
|
data.search_type = 'hybrid';
|
|
327
359
|
}
|
|
328
360
|
|
|
329
|
-
|
|
361
|
+
if (data.llm === 'ollama') {
|
|
362
|
+
if (!ollama_integration.value.url) {
|
|
363
|
+
return res.status(422).send({ success: false, error: "Server url for ollama is empty or invalid"})
|
|
364
|
+
}
|
|
365
|
+
data.model = {
|
|
366
|
+
name: data.model,
|
|
367
|
+
url: ollama_integration.value.url,
|
|
368
|
+
provider: 'ollama'
|
|
369
|
+
}
|
|
370
|
+
data.stream = false;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (data.llm === 'vllm') {
|
|
374
|
+
if (!vllm_integration.value.url) {
|
|
375
|
+
return res.status(422).send({ success: false, error: "Server url for ollama is empty or invalid"})
|
|
376
|
+
}
|
|
377
|
+
data.model = {
|
|
378
|
+
name: data.model,
|
|
379
|
+
url: vllm_integration.value.url,
|
|
380
|
+
provider: 'ollama'
|
|
381
|
+
}
|
|
382
|
+
data.stream = false;
|
|
383
|
+
}
|
|
384
|
+
|
|
330
385
|
delete data.advancedPrompt;
|
|
331
386
|
winston.verbose("ask data: ", data);
|
|
332
387
|
|
package/routes/webhooks.js
CHANGED
|
@@ -80,8 +80,8 @@ router.post('/', async (req, res) => {
|
|
|
80
80
|
webhook.save((err, savedWebhook) => {
|
|
81
81
|
if (err) {
|
|
82
82
|
if (err.code === 11000) {
|
|
83
|
-
winston.verbose("Webhook already exists for chatbot " + chatbot_id);
|
|
84
|
-
return res.status(403).send({ success: false, message: "Webhook already exists for chatbot " + chatbot_id });
|
|
83
|
+
winston.verbose("Webhook already exists for chatbot " + webhook.chatbot_id);
|
|
84
|
+
return res.status(403).send({ success: false, message: "Webhook already exists for chatbot " + webhook.chatbot_id });
|
|
85
85
|
}
|
|
86
86
|
winston.error("Error saving new webhook ", err);
|
|
87
87
|
return res.status(500).send({ success: false, error: err });
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const winston = require('../config/winston');
|
|
2
|
+
const integrations = require('../models/integrations');
|
|
3
|
+
|
|
4
|
+
class IntegrationService {
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async getIntegration(id_project, integration_name) {
|
|
9
|
+
if (!id_project || !integration_name) {
|
|
10
|
+
throw({ code: 422, error: "Fields 'id_project', 'integration_name' are mandatory" });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const integration = await integrations.findOne({ id_project: id_project, name: integration_name});
|
|
15
|
+
if (!integration && integration_name !== 'openai') {
|
|
16
|
+
throw({ code: 404, error: `Integration ${integration_name} not found for project ${id_project}` });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return integration;
|
|
20
|
+
|
|
21
|
+
} catch (err) {
|
|
22
|
+
winston.error("Erro getting integration: ", err);
|
|
23
|
+
throw({ code: err.code || 500, error: err.error || `Error getting integration for ${integration_name} for project ${id_project}` })
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getKeyFromIntegration(id_project, integration_name) {
|
|
28
|
+
if (!id_project || !integration_name) {
|
|
29
|
+
throw({ code: 422, error: "Fields 'id_project', 'integration_name' are mandatory" });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const integration = await integrations.findOne({ id_project: id_project, name: integration_name});
|
|
34
|
+
if (!integration && integration_name !== 'openai') {
|
|
35
|
+
throw({ code: 404, error: `Integration ${integration_name} not found for project ${id_project}` });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return integration?.value?.apikey;
|
|
39
|
+
|
|
40
|
+
} catch (err) {
|
|
41
|
+
winston.error("Erro getting integration: ", err);
|
|
42
|
+
throw({ code: err.code || 500, error: err.error || `Error getting integration for ${integration_name} for project ${id_project}` })
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const integrationService = new IntegrationService();
|
|
48
|
+
|
|
49
|
+
module.exports = integrationService;
|
|
50
|
+
|