@tiledesk/tiledesk-server 2.7.26 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +6 -0
- package/app.js +1 -1
- package/config/labels/widget.json +31 -0
- package/deploy.sh +1 -1
- package/event/emailEvent.js +58 -2
- package/models/faq.js +5 -0
- package/models/kb_setting.js +38 -3
- package/package.json +4 -3
- package/pubmodules/s/index.js +2 -2
- package/pubmodules/s/models/subscription-payment.js +2 -2
- package/pubmodules/s/stripe/index.js +2 -2
- package/routes/kb.js +952 -542
- package/routes/openai.js +3 -3
- package/routes/project.js +21 -6
- package/routes/quotes.js +13 -4
- package/services/QuoteManager.js +163 -16
- package/services/emailService.js +53 -1
- package/services/requestService.js +16 -5
- package/template/email/beenInvitedNewUser.html +221 -216
- package/template/email/checkpointReachedEmail.html +92 -0
- package/test/kbRoute.js +1186 -311
- package/test/mock/projectMock.js +2 -3
- package/test/openaiRoute.js +3 -0
- package/test/requestService.js +3 -0
- package/utils/aiUtils.js +41 -5
package/test/mock/projectMock.js
CHANGED
@@ -47,8 +47,7 @@ const mockProjectSandboxPlan = {
|
|
47
47
|
"name": "Sandbox",
|
48
48
|
"trialDays": 14,
|
49
49
|
"agents": 0,
|
50
|
-
"type": "
|
51
|
-
"subStart": new Date('2023-10-20T08:45:54.058Z')
|
50
|
+
"type": "free",
|
52
51
|
},
|
53
52
|
"versions": 20115,
|
54
53
|
"channels": [
|
@@ -56,7 +55,7 @@ const mockProjectSandboxPlan = {
|
|
56
55
|
"name": "chat21"
|
57
56
|
}
|
58
57
|
],
|
59
|
-
"createdAt": new Date('2023-10-
|
58
|
+
"createdAt": new Date('2023-10-20T08:45:54.058Z')
|
60
59
|
}
|
61
60
|
|
62
61
|
const mockProjectBasicPlan = {
|
package/test/openaiRoute.js
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
//During the test the env variable is set to test
|
2
2
|
process.env.NODE_ENV = 'test';
|
3
3
|
// process.env.GPTKEY = 'customgptkey';
|
4
|
+
//process.env.AI_MODELS = 'gpt-3.5-turbo:0.6;gpt-4:25;gpt-4-turbo-preview:12;gpt-4o:6'
|
5
|
+
//process.env.AI_MODELS = 'gpt-3.5-turbo;gpt-4-turbo-preview;gpt-4o'
|
6
|
+
process.env.AI_MODELS = ' gpt-3.5-turbo:0 .6;gpt -4:2 5; g pt-4-tur bo-preview:12;gp t-4o:6'
|
4
7
|
|
5
8
|
let log = false;
|
6
9
|
var projectService = require('../services/projectService');
|
package/test/requestService.js
CHANGED
@@ -94,6 +94,7 @@ describe('RequestService', function () {
|
|
94
94
|
id_project: savedProject._id, first_text: "first_text",
|
95
95
|
lead: createdLead, requester: savedProjectAndPU.project_user
|
96
96
|
};
|
97
|
+
// attributes: { sourcePage: "https://widget-pre.tiledesk.com/v2/index.html?tiledesk_projectid=5ce3d1ceb25ad30017279999&td_draft=true" } // for quote test
|
97
98
|
|
98
99
|
requestService.create(request).then(async function (savedRequest) {
|
99
100
|
winston.verbose("resolve", savedRequest.toObject());
|
@@ -121,6 +122,8 @@ describe('RequestService', function () {
|
|
121
122
|
expect(savedRequest.snapshot.requester.isAuthenticated).to.equal(true);
|
122
123
|
expect(savedRequest.createdBy).to.equal(savedProjectAndPU.project_user._id.toString());
|
123
124
|
expect(savedRequest.id_project).to.equal(savedProject._id.toString());
|
125
|
+
|
126
|
+
//expect(savedRequest.attributes.sourcePage).to.equal("https://widget-pre.tiledesk.com/v2/index.html?tiledesk_projectid=5ce3d1ceb25ad30017279999&td_draft=true")
|
124
127
|
|
125
128
|
|
126
129
|
setTimeout(async () => {
|
package/utils/aiUtils.js
CHANGED
@@ -1,7 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
var winston = require('../config/winston');
|
2
|
+
|
3
|
+
// MODELS_MULTIPLIER = {
|
4
|
+
// "gpt-3.5-turbo": 0.6,
|
5
|
+
// "gpt-4": 25,
|
6
|
+
// "gpt-4-turbo-preview": 12
|
7
|
+
// }
|
8
|
+
|
9
|
+
loadMultiplier();
|
10
|
+
function loadMultiplier() {
|
11
|
+
|
12
|
+
|
13
|
+
let models_string = process.env.AI_MODELS;
|
14
|
+
winston.debug("(loadMultiplier) models_string: ", models_string)
|
15
|
+
let models = {};
|
16
|
+
|
17
|
+
if (!models_string) {
|
18
|
+
winston.info("AI_MODELS not defined");
|
19
|
+
winston.info("AI Models: ", models)
|
20
|
+
return models;
|
21
|
+
}
|
22
|
+
|
23
|
+
let models_string_trimmed = models_string.replace(/ /g,'');
|
24
|
+
winston.debug("(loadMultiplier) models_string_trimmed: ", models_string_trimmed)
|
25
|
+
|
26
|
+
let splitted_string = models_string_trimmed.split(";");
|
27
|
+
winston.debug("splitted_string: ", splitted_string)
|
28
|
+
|
29
|
+
splitted_string.forEach(m => {
|
30
|
+
m_split = m.split(":");
|
31
|
+
if (!m_split[1]) {
|
32
|
+
multiplier = null;
|
33
|
+
} else {
|
34
|
+
multiplier = Number(m_split[1]);;
|
35
|
+
}
|
36
|
+
models[m_split[0]] = multiplier;
|
37
|
+
})
|
38
|
+
|
39
|
+
winston.info("AI Models: ", models)
|
40
|
+
return models;
|
5
41
|
}
|
6
42
|
|
7
|
-
module.exports = {
|
43
|
+
module.exports = { MODELS_MULTIPLIER: loadMultiplier() }
|