mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
fix(server): handle failed ML responses (#4036)
* handle ml error responses * more explicit error message * formatting * better formatting
This commit is contained in:
parent
258b98c262
commit
4b11e925d9
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user