mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
Add LeaderboardService with submitReport Method
This commit adds a new `LeaderboardService` class featuring a `submitReport` method. This method allows for the submission of `BenchmarkRun` objects to the leaderboard via a POST request to the `/api/reports` endpoint. The new service uses the `ApiType.leaderboard` enum value.
This commit is contained in:
24
frontend/lib/services/leaderboard_service.dart
Normal file
24
frontend/lib/services/leaderboard_service.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:auto_gpt_flutter_client/models/benchmark/api_type.dart';
|
||||
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_run.dart';
|
||||
import 'package:auto_gpt_flutter_client/utils/rest_api_utility.dart';
|
||||
|
||||
class LeaderboardService {
|
||||
final RestApiUtility api;
|
||||
|
||||
LeaderboardService(this.api);
|
||||
|
||||
/// Submits a benchmark report to the leaderboard.
|
||||
///
|
||||
/// [benchmarkRun] is a BenchmarkRun object representing the data of a completed benchmark.
|
||||
Future<Map<String, dynamic>> submitReport(BenchmarkRun benchmarkRun) async {
|
||||
try {
|
||||
return await api.post(
|
||||
'api/reports',
|
||||
benchmarkRun.toJson(),
|
||||
apiType: ApiType.leaderboard,
|
||||
);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to submit the report to the leaderboard: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user