@tiledesk/tiledesk-server 2.10.2 → 2.10.3

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,9 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
+ # 2.10.3
9
+ - Added support for formatType in openai completions
10
+
8
11
  # 2.10.2
9
12
  - Updated tybot-connector to 0.2.113
10
13
 
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.10.2",
4
+ "version": "2.10.3",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
package/routes/openai.js CHANGED
@@ -43,15 +43,12 @@ router.post('/', async (req, res) => {
43
43
 
44
44
 
45
45
  let json = {
46
- "model": body.model,
47
- "messages": [
48
- {
49
- "role": "user",
50
- "content": body.question
51
- }
46
+ model: body.model,
47
+ messages: [
48
+ { role: "user", content: body.question }
52
49
  ],
53
- "max_tokens": body.max_tokens,
54
- "temperature": body.temperature
50
+ max_tokens: body.max_tokens,
51
+ temperature: body.temperature
55
52
  }
56
53
 
57
54
  let message = { role: "", content: "" };
@@ -61,6 +58,12 @@ router.post('/', async (req, res) => {
61
58
  json.messages.unshift(message);
62
59
  }
63
60
 
61
+ if (body.formatType && body.formatType !== 'none') {
62
+ json.response_format = {
63
+ type: body.formatType
64
+ }
65
+ }
66
+
64
67
  let multiplier = MODELS_MULTIPLIER[json.model];
65
68
  if (!multiplier) {
66
69
  multiplier = 1;
@@ -73,6 +76,7 @@ router.post('/', async (req, res) => {
73
76
  let incremented_key = await quoteManager.incrementTokenCount(req.project, data);
74
77
  winston.verbose("Tokens quota incremented for key " + incremented_key);
75
78
  }
79
+
76
80
  res.status(200).send(response.data);
77
81
 
78
82
  }).catch((err) => {