Added error field check

This commit is contained in:
bmen25124 2025-03-04 03:39:00 +03:00
parent 7d568dd4e0
commit 28fc498ee6

View File

@ -86,11 +86,11 @@ export class TextCompletionService {
signal: new AbortController().signal,
});
if (!response.ok) {
throw await response.json();
const json = await response.json();
if (!response.ok || json.error) {
throw json;
}
const json = await response.json();
return extractData ? extractMessageFromData(json, this.TYPE) : json;
}
@ -156,11 +156,11 @@ export class ChatCompletionService {
signal: new AbortController().signal,
});
if (!response.ok) {
throw await response.json();
const json = await response.json();
if (!response.ok || json.error) {
throw json;
}
const json = await response.json();
return extractData ? extractMessageFromData(json, this.TYPE) : json;
}