mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
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`.
This commit is contained in:
@@ -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:auto_gpt_flutter_client/views/auth/firebase_auth_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'views/main_layout.dart';
|
import 'views/main_layout.dart';
|
||||||
@@ -47,9 +47,13 @@ void main() async {
|
|||||||
TaskService(restApiUtility),
|
TaskService(restApiUtility),
|
||||||
),
|
),
|
||||||
ProxyProvider<RestApiUtility, BenchmarkService>(
|
ProxyProvider<RestApiUtility, BenchmarkService>(
|
||||||
update: (context, restApiUtility, taskService) =>
|
update: (context, restApiUtility, benchmarkService) =>
|
||||||
BenchmarkService(restApiUtility),
|
BenchmarkService(restApiUtility),
|
||||||
),
|
),
|
||||||
|
ProxyProvider<RestApiUtility, LeaderboardService>(
|
||||||
|
update: (context, restApiUtility, leaderboardService) =>
|
||||||
|
LeaderboardService(restApiUtility),
|
||||||
|
),
|
||||||
ChangeNotifierProxyProvider<RestApiUtility, ApiSettingsViewModel>(
|
ChangeNotifierProxyProvider<RestApiUtility, ApiSettingsViewModel>(
|
||||||
create: (context) => ApiSettingsViewModel(
|
create: (context) => ApiSettingsViewModel(
|
||||||
Provider.of<RestApiUtility>(context, listen: false)),
|
Provider.of<RestApiUtility>(context, listen: false)),
|
||||||
@@ -90,7 +94,8 @@ class MyApp extends StatelessWidget {
|
|||||||
Provider.of<TaskService>(context, listen: false))),
|
Provider.of<TaskService>(context, listen: false))),
|
||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (context) => SkillTreeViewModel(
|
create: (context) => SkillTreeViewModel(
|
||||||
Provider.of<BenchmarkService>(context, listen: false)),
|
Provider.of<BenchmarkService>(context, listen: false),
|
||||||
|
Provider.of<LeaderboardService>(context, listen: false)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: MainLayout(),
|
child: MainLayout(),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
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_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_request_body.dart';
|
||||||
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_task_status.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/task.dart';
|
||||||
import 'package:auto_gpt_flutter_client/models/test_suite.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/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/chat_viewmodel.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
||||||
import 'package:collection/collection.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
|
// TODO: Potentially move to task queue view model when we create one
|
||||||
final BenchmarkService benchmarkService;
|
final BenchmarkService benchmarkService;
|
||||||
// TODO: Potentially move to task queue view model when we create one
|
// 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;
|
bool isBenchmarkRunning = false;
|
||||||
// TODO: Potentially move to task queue view model when we create one
|
// TODO: Potentially move to task queue view model when we create one
|
||||||
Map<SkillTreeNode, BenchmarkTaskStatus> benchmarkStatusMap = {};
|
Map<SkillTreeNode, BenchmarkTaskStatus> benchmarkStatusMap = {};
|
||||||
@@ -37,7 +41,7 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||||||
final Graph graph = Graph()..isTree = true;
|
final Graph graph = Graph()..isTree = true;
|
||||||
BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
|
BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
|
||||||
|
|
||||||
SkillTreeViewModel(this.benchmarkService);
|
SkillTreeViewModel(this.benchmarkService, this.leaderboardService);
|
||||||
|
|
||||||
Future<void> initializeSkillTree() async {
|
Future<void> initializeSkillTree() async {
|
||||||
try {
|
try {
|
||||||
@@ -206,6 +210,13 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||||||
await benchmarkService.triggerEvaluation(task.id);
|
await benchmarkService.triggerEvaluation(task.id);
|
||||||
print("Evaluation response: $evaluationResponse");
|
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
|
// Update the benchmarkStatusList based on the evaluation response
|
||||||
bool successStatus = evaluationResponse['metrics']['success'];
|
bool successStatus = evaluationResponse['metrics']['success'];
|
||||||
benchmarkStatusMap[node] = successStatus
|
benchmarkStatusMap[node] = successStatus
|
||||||
|
|||||||
Reference in New Issue
Block a user