wingbot 3.76.7 → 3.76.9
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 +1 -1
- package/src/ChatGpt.js +4 -2
package/package.json
CHANGED
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
|
|
|
@@ -449,7 +451,7 @@ class ChatGpt {
|
|
|
449
451
|
Object.assign(body, { functions });
|
|
450
452
|
}
|
|
451
453
|
|
|
452
|
-
const apiUrl = `${this._openAiEndpoint}/chat/completions${this._apiKey ?
|
|
454
|
+
const apiUrl = `${this._openAiEndpoint}/chat/completions${this._apiKey ? `?api-version=${encodeURIComponent(this._apiVersion)}` : ''}`;
|
|
453
455
|
|
|
454
456
|
this._log('#GPT request', body);
|
|
455
457
|
|
|
@@ -478,7 +480,7 @@ class ChatGpt {
|
|
|
478
480
|
|
|
479
481
|
if (status !== 200
|
|
480
482
|
|| !Array.isArray(responseData.choices)) {
|
|
481
|
-
throw new Error(`Chat GPT ${status}`);
|
|
483
|
+
throw new Error(`Chat GPT ${status}: ${responseText.slice(0, 200)}`);
|
|
482
484
|
}
|
|
483
485
|
|
|
484
486
|
const [choice] = responseData.choices;
|