Spaces:
Sleeping
Sleeping
File size: 2,511 Bytes
9a03fcf |
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
import axios from 'axios';
const API_URL = '/api';
const api = {
// Get available benchmarks
getBenchmarks: async () => {
try {
const response = await axios.get(`${API_URL}/benchmarks`);
return response.data;
} catch (error) {
console.error('Error fetching benchmarks:', error);
return { success: false, error: error.message };
}
},
// Get leaderboard data
getLeaderboard: async (benchmark, filters = {}) => {
try {
const { filterColumns, searchQuery, coreColumns } = filters;
const params = new URLSearchParams();
params.append('benchmark', benchmark);
if (filterColumns && filterColumns.length) {
params.append('filter_columns', filterColumns.join(','));
}
if (searchQuery) {
params.append('search_query', searchQuery);
}
if (coreColumns && coreColumns.length) {
params.append('core_columns', coreColumns.join(','));
}
const response = await axios.get(`${API_URL}/leaderboard?${params.toString()}`);
return response.data;
} catch (error) {
console.error('Error fetching leaderboard:', error);
return { success: false, error: error.message };
}
},
// Get available columns for a benchmark
getColumns: async (benchmark) => {
try {
const response = await axios.get(`${API_URL}/columns?benchmark=${benchmark}`);
return response.data;
} catch (error) {
console.error('Error fetching columns:', error);
return { success: false, error: error.message };
}
},
// Get examples for a specific model and benchmark
getExamples: async (benchmark, model, attack = '') => {
try {
const params = new URLSearchParams();
params.append('benchmark', benchmark);
params.append('model', model);
if (attack) {
params.append('attack', attack);
}
const response = await axios.get(`${API_URL}/examples?${params.toString()}`);
return response.data;
} catch (error) {
console.error('Error fetching examples:', error);
return { success: false, error: error.message };
}
},
// Get available attacks for a benchmark
getAttacks: async (benchmark) => {
try {
const response = await axios.get(`${API_URL}/attacks?benchmark=${benchmark}`);
return response.data;
} catch (error) {
console.error('Error fetching attacks:', error);
return { success: false, error: error.message };
}
}
};
export default api;
|