File size: 1,923 Bytes
73d286b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import axios from 'axios';
import {
  ClassificationResponse,
  BatchClassificationResponse,
  CategorySuggestionResponse,
  ValidationRequest,
  ValidationResponse,
  ImprovementRequest,
  ImprovementResponse,
  ModelInfoResponse,
  HealthResponse
} from '../types/api';

const API_BASE_URL = 'http://localhost:8000';

const api = axios.create({
  baseURL: API_BASE_URL,
  headers: {
    'Content-Type': 'application/json',
  },
});

export const healthCheck = async (): Promise<HealthResponse> => {
  const response = await api.get<HealthResponse>('/health');
  return response.data;
};

export const getModelInfo = async (): Promise<ModelInfoResponse> => {
  const response = await api.get<ModelInfoResponse>('/model-info');
  return response.data;
};

export const classifyText = async (text: string, categories?: string[]): Promise<ClassificationResponse> => {
  const response = await api.post<ClassificationResponse>('/classify', {
    text,
    categories,
  });
  return response.data;
};

export const classifyBatch = async (texts: string[], categories?: string[]): Promise<BatchClassificationResponse> => {
  const response = await api.post<BatchClassificationResponse>('/classify-batch', {
    texts,
    categories,
  });
  return response.data;
};

export const suggestCategories = async (texts: string[]): Promise<CategorySuggestionResponse> => {
  const response = await api.post<CategorySuggestionResponse>('/suggest-categories', texts);
  return response.data;
};

export const validateClassifications = async (request: ValidationRequest): Promise<ValidationResponse> => {
  const response = await api.post<ValidationResponse>('/validate', request);
  return response.data;
};

export const improveClassification = async (request: ImprovementRequest): Promise<ImprovementResponse> => {
  const response = await api.post<ImprovementResponse>('/improve-classification', request);
  return response.data;
};