Integrate LeaderboardService into SkillTreeViewModel
This commit integrates the `LeaderboardService` into `SkillTreeViewModel` to enable benchmark report submissions to the leaderboard. A `BenchmarkRun` object is created from the evaluation response and submitted using the `submitReport` method from `LeaderboardService`.pull/5283/head
parent
ff4c76ba00
commit
22ea449850
|
@ -1,4 +1,4 @@
|
|||
import 'package:auto_gpt_flutter_client/services/auth_service.dart';
|
||||
import 'package:auto_gpt_flutter_client/services/leaderboard_service.dart';
|
||||
import 'package:auto_gpt_flutter_client/views/auth/firebase_auth_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'views/main_layout.dart';
|
||||
|
@ -47,9 +47,13 @@ void main() async {
|
|||
TaskService(restApiUtility),
|
||||
),
|
||||
ProxyProvider<RestApiUtility, BenchmarkService>(
|
||||
update: (context, restApiUtility, taskService) =>
|
||||
update: (context, restApiUtility, benchmarkService) =>
|
||||
BenchmarkService(restApiUtility),
|
||||
),
|
||||
ProxyProvider<RestApiUtility, LeaderboardService>(
|
||||
update: (context, restApiUtility, leaderboardService) =>
|
||||
LeaderboardService(restApiUtility),
|
||||
),
|
||||
ChangeNotifierProxyProvider<RestApiUtility, ApiSettingsViewModel>(
|
||||
create: (context) => ApiSettingsViewModel(
|
||||
Provider.of<RestApiUtility>(context, listen: false)),
|
||||
|
@ -90,7 +94,8 @@ class MyApp extends StatelessWidget {
|
|||
Provider.of<TaskService>(context, listen: false))),
|
||||
ChangeNotifierProvider(
|
||||
create: (context) => SkillTreeViewModel(
|
||||
Provider.of<BenchmarkService>(context, listen: false)),
|
||||
Provider.of<BenchmarkService>(context, listen: false),
|
||||
Provider.of<LeaderboardService>(context, listen: false)),
|
||||
),
|
||||
],
|
||||
child: MainLayout(),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:convert';
|
||||
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_run.dart';
|
||||
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_step_request_body.dart';
|
||||
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_task_request_body.dart';
|
||||
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_task_status.dart';
|
||||
|
@ -8,6 +9,7 @@ import 'package:auto_gpt_flutter_client/models/step.dart';
|
|||
import 'package:auto_gpt_flutter_client/models/task.dart';
|
||||
import 'package:auto_gpt_flutter_client/models/test_suite.dart';
|
||||
import 'package:auto_gpt_flutter_client/services/benchmark_service.dart';
|
||||
import 'package:auto_gpt_flutter_client/services/leaderboard_service.dart';
|
||||
import 'package:auto_gpt_flutter_client/viewmodels/chat_viewmodel.dart';
|
||||
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
@ -19,6 +21,8 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||
// TODO: Potentially move to task queue view model when we create one
|
||||
final BenchmarkService benchmarkService;
|
||||
// TODO: Potentially move to task queue view model when we create one
|
||||
final LeaderboardService leaderboardService;
|
||||
// TODO: Potentially move to task queue view model when we create one
|
||||
bool isBenchmarkRunning = false;
|
||||
// TODO: Potentially move to task queue view model when we create one
|
||||
Map<SkillTreeNode, BenchmarkTaskStatus> benchmarkStatusMap = {};
|
||||
|
@ -37,7 +41,7 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||
final Graph graph = Graph()..isTree = true;
|
||||
BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
|
||||
|
||||
SkillTreeViewModel(this.benchmarkService);
|
||||
SkillTreeViewModel(this.benchmarkService, this.leaderboardService);
|
||||
|
||||
Future<void> initializeSkillTree() async {
|
||||
try {
|
||||
|
@ -206,6 +210,13 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||
await benchmarkService.triggerEvaluation(task.id);
|
||||
print("Evaluation response: $evaluationResponse");
|
||||
|
||||
// Decode the evaluationResponse into a BenchmarkRun object
|
||||
BenchmarkRun benchmarkRun = BenchmarkRun.fromJson(evaluationResponse);
|
||||
|
||||
// TODO: We should only trigger this if the user has designated they want to submit
|
||||
// Submit the BenchmarkRun object to the leaderboard
|
||||
await leaderboardService.submitReport(benchmarkRun);
|
||||
|
||||
// Update the benchmarkStatusList based on the evaluation response
|
||||
bool successStatus = evaluationResponse['metrics']['success'];
|
||||
benchmarkStatusMap[node] = successStatus
|
||||
|
|
Loading…
Reference in New Issue