mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-02 18:59:15 -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
					
				@ -18,6 +18,12 @@ export class MachineLearningRepository implements IMachineLearningRepository {
 | 
				
			|||||||
  private async post<T>(url: string, input: TextModelInput | VisionModelInput, config: ModelConfig): Promise<T> {
 | 
					  private async post<T>(url: string, input: TextModelInput | VisionModelInput, config: ModelConfig): Promise<T> {
 | 
				
			||||||
    const formData = await this.getFormData(input, config);
 | 
					    const formData = await this.getFormData(input, config);
 | 
				
			||||||
    const res = await fetch(`${url}/predict`, { method: 'POST', body: formData });
 | 
					    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();
 | 
					    return res.json();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user