backend-manager 3.2.74 → 3.2.76
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
|
@@ -226,6 +226,7 @@ OpenAI.prototype.request = function (options) {
|
|
|
226
226
|
})
|
|
227
227
|
.catch((e) => e);
|
|
228
228
|
|
|
229
|
+
// Check for moderation flag
|
|
229
230
|
if (moderation.flagged) {
|
|
230
231
|
return reject(assistant.errorify(`This request is inappropriate`, {code: 451}));
|
|
231
232
|
}
|
|
@@ -235,16 +236,19 @@ OpenAI.prototype.request = function (options) {
|
|
|
235
236
|
await _request('chatgpt', options)
|
|
236
237
|
.then((r) => {
|
|
237
238
|
try {
|
|
239
|
+
// Parse JSON response if needed
|
|
238
240
|
const content = options.response === 'json' ? JSON5.parse(r) : r;
|
|
239
241
|
|
|
242
|
+
// Return
|
|
240
243
|
return resolve({
|
|
241
244
|
content: content,
|
|
242
245
|
tokens: self.tokens,
|
|
243
246
|
moderation: moderation,
|
|
244
247
|
})
|
|
245
248
|
} catch (e) {
|
|
246
|
-
assistant.
|
|
249
|
+
assistant.error('Error parsing response', r, e);
|
|
247
250
|
|
|
251
|
+
// Return
|
|
248
252
|
return reject(e);
|
|
249
253
|
}
|
|
250
254
|
})
|