File size: 910 Bytes
382dea6
 
85aae51
 
 
382dea6
85aae51
382dea6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import axios from 'axios';

// Use environment variable if provided (for production), otherwise default to localhost
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000';

const api = axios.create({
  baseURL: API_URL,
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'admin-secret-key' // Default admin key
  }
});

export const searchApi = {
  query: (data) => api.post('/query', data),
  hybridQuery: (data) => api.post('/hybrid-query', data),
  filteredQuery: (data) => api.post('/filtered-query', data),
};

export const adminApi = {
  getCacheStats: () => api.get('/cache/stats'),
  clearCache: () => api.delete('/cache'),
  updateThreshold: (threshold) => api.patch(`/cache/threshold?threshold=${threshold}`),
  getAnalytics: () => api.get('/analytics'),
  getClustersAnalysis: () => api.get('/clusters/analysis'),
  runEvaluation: () => api.get('/evaluate'),
};