import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class ApiService { private apiUrl = 'http://localhost:3000'; constructor(private http: HttpClient) { } getConfidence(): Observable { return this.http.get(`${this.apiUrl}/get_confidence`); } setConfidence(threshold: number): Observable { return this.http.post(`${this.apiUrl}/set_confidence`, { threshold }); } analyze(file: File, modelType: string = 'onnx'): Observable { const formData = new FormData(); formData.append('file', file); formData.append('model_type', modelType); return this.http.post(`${this.apiUrl}/analyze`, formData); } getHistory(): Observable { return this.http.get(`${this.apiUrl}/get_history`); } getModelInfo(modelType: string = 'onnx'): Observable { return this.http.get(`${this.apiUrl}/get_model_info`, { params: { model_type: modelType } }); } getAnalytics(): Observable { // This could be used for a dashboard later return this.http.get(`${this.apiUrl}/get_history`); } }