|
@@ -18,6 +18,12 @@ export class MachineLearningRepository implements IMachineLearningRepository {
|
|
|
private async post<T>(url: string, input: TextModelInput | VisionModelInput, config: ModelConfig): Promise<T> {
|
|
|
const formData = await this.getFormData(input, config);
|
|
|
const res = await fetch(`${url}/predict`, { method: 'POST', body: formData });
|
|
|
+ if (res.status >= 400) {
|
|
|
+ throw new Error(
|
|
|
+ `Request ${config.modelType ? `for ${config.modelType.replace('-', ' ')} ` : ''}` +
|
|
|
+ `failed with status ${res.status}: ${res.statusText}`,
|
|
|
+ );
|
|
|
+ }
|
|
|
return res.json();
|
|
|
}
|
|
|
|