wingbot 3.76.6 → 3.76.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.76.6",
3
+ "version": "3.76.8",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
package/src/ChatGpt.js CHANGED
@@ -190,12 +190,14 @@ class ChatGpt {
190
190
  defaultUser = null,
191
191
  openAiEndpoint = 'https://api.openai.com/v1',
192
192
  apiKey,
193
+ apiVersion = '2023-03-15-preview',
193
194
  authorization,
194
195
  timeout = 15000,
195
196
  ...rest
196
197
  } = options;
197
198
 
198
199
  this._apiKey = apiKey;
200
+ this._apiVersion = apiVersion;
199
201
  this._authorization = authorization;
200
202
  this._timeout = timeout;
201
203
 
@@ -230,6 +232,15 @@ class ChatGpt {
230
232
  ];
231
233
  }
232
234
 
235
+ /**
236
+ * Model used, when the preset does not specify one
237
+ *
238
+ * @returns {ChatGPTModel}
239
+ */
240
+ get defaultModel () {
241
+ return this._options.model;
242
+ }
243
+
233
244
  _log (msg, ...args) {
234
245
  if (this._logger === console) {
235
246
 
@@ -440,7 +451,7 @@ class ChatGpt {
440
451
  Object.assign(body, { functions });
441
452
  }
442
453
 
443
- const apiUrl = `${this._openAiEndpoint}/chat/completions${this._apiKey ? '?api-version=2023-03-15-preview' : ''}`;
454
+ const apiUrl = `${this._openAiEndpoint}/chat/completions${this._apiKey ? `?api-version=${encodeURIComponent(this._apiVersion)}` : ''}`;
444
455
 
445
456
  this._log('#GPT request', body);
446
457
 
package/src/LLM.js CHANGED
@@ -121,6 +121,7 @@ const LLMSession = require('./LLMSession');
121
121
  /**
122
122
  * @typedef {object} LLMChatProvider
123
123
  * @prop {LLMChatProviderPrompt} requestChat
124
+ * @prop {string} [defaultModel] - model used, when the options don't specify one
124
125
  */
125
126
 
126
127
  /** @typedef {import('node-fetch').default} Fetch */
@@ -387,11 +388,19 @@ class LLM {
387
388
  if (!this._presets.has(preset)) {
388
389
  throw new Error(`LLM Preset '${preset}' does not exist.`);
389
390
  }
390
- return {
391
+ const opts = {
391
392
  ...this._presets.get(preset),
392
393
  ...override,
393
394
  preset
394
395
  };
396
+
397
+ // presets without a model rely on the provider's default - make it
398
+ // visible, so it gets logged within the PromptInfo
399
+ if (opts.model == null) {
400
+ opts.model = this._provider?.defaultModel ?? null;
401
+ }
402
+
403
+ return opts;
395
404
  }
396
405
 
397
406
  /**
@@ -45,6 +45,15 @@ class LLMMockProvider {
45
45
  ];
46
46
  }
47
47
 
48
+ /**
49
+ * Model used, when the preset does not specify one
50
+ *
51
+ * @returns {string}
52
+ */
53
+ get defaultModel () {
54
+ return LLMMockProvider.DEFAULT_MODEL;
55
+ }
56
+
48
57
  /**
49
58
  *
50
59
  * @param {string} preset