@tiledesk/tiledesk-server 2.7.26 → 2.7.27

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.
@@ -47,8 +47,7 @@ const mockProjectSandboxPlan = {
47
47
  "name": "Sandbox",
48
48
  "trialDays": 14,
49
49
  "agents": 0,
50
- "type": "payment",
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-16T08:45:54.058Z')
58
+ "createdAt": new Date('2023-10-20T08:45:54.058Z')
60
59
  }
61
60
 
62
61
  const mockProjectBasicPlan = {
@@ -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');
@@ -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
- MODEL_MULTIPLIER = {
2
- "gpt-3.5-turbo": 0.6,
3
- "gpt-4": 25,
4
- "gpt-4-turbo-preview": 12
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 = { MODEL_MULTIPLIER }
43
+ module.exports = { MODELS_MULTIPLIER: loadMultiplier() }