mirror of
https://github.com/immich-app/immich.git
synced 2025-04-08 03:01:32 -05: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
1 changed files with 6 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue