fix: show proper error message

This commit is contained in:
Louis 2023-12-15 14:14:26 +07:00 committed by Faisal Amir
parent d9b0625b17
commit cf7e9350b7

View File

@ -40,6 +40,13 @@ export function requestInference(
signal: controller?.signal, signal: controller?.signal,
}) })
.then(async (response) => { .then(async (response) => {
if (!response.ok) {
subscriber.next(
(await response.json()).error?.message ?? "Error occured"
);
subscriber.complete();
return;
}
if (model.parameters.stream) { if (model.parameters.stream) {
const stream = response.body; const stream = response.body;
const decoder = new TextDecoder("utf-8"); const decoder = new TextDecoder("utf-8");