AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Enhance SkillTreeViewModel to Manage Benchmark Status (#5266)
hunteraraujoa37b486227dd
diff --git a/frontend/lib/viewmodels/skill_tree_viewmodel.dart b/frontend/lib/viewmodels/skill_tree_viewmodel.dartindex 23d712a838..d48fd2f9d8 100644--- a/frontend/lib/viewmodels/skill_tree_viewmodel.dart+++ b/frontend/lib/viewmodels/skill_tree_viewmodel.dart@@ -11,14 +11,14 @@ import 'package:collection/collection.dart';import 'package:flutter/foundation.dart';import 'package:flutter/services.dart';import 'package:graphview/GraphView.dart';-import 'package:provider/provider.dart';-import 'package:uuid/uuid.dart';class SkillTreeViewModel extends ChangeNotifier {// TODO: Potentially move to task queue view model when we create onefinal BenchmarkService benchmarkService;// TODO: Potentially move to task queue view model when we create onebool isBenchmarkRunning = false;+ // TODO: Potentially move to task queue view model when we create one+ List<Map<SkillTreeNode, bool>> benchmarkStatusList = [];List<SkillTreeNode> _skillTreeNodes = [];List<SkillTreeEdge> _skillTreeEdges = [];@@ -26,6 +26,8 @@ class SkillTreeViewModel extends ChangeNotifier {// TODO: Potentially move to task queue view model when we create oneList<SkillTreeNode>? _selectedNodeHierarchy;+ List<SkillTreeNode> get skillTreeNodes => _skillTreeNodes;+ List<SkillTreeEdge> get skillTreeEdges => _skillTreeEdges;SkillTreeNode? get selectedNode => _selectedNode;List<SkillTreeNode>? get selectedNodeHierarchy => _selectedNodeHierarchy;@@ -137,43 +139,48 @@ class SkillTreeViewModel extends ChangeNotifier {}// TODO: Move to task queue view model- // TODO: We should check if the test passed. If not we short circuit.- // TODO: We should create a model to track our active tests+ // TODO: We should be creating TestSuite objectsFuture<void> runBenchmark(ChatViewModel chatViewModel) async {- // 1. Set the benchmark running flag to true+ // Clear the benchmarkStatusList+ benchmarkStatusList.clear();++ // Set the benchmark running flag to trueisBenchmarkRunning = true;- // 2. Notify listeners+ // Notify listenersnotifyListeners();- // 3. Grab the reversed node hierarchy+ // Populate benchmarkStatusList with reversed node hierarchyfinal reversedSelectedNodeHierarchy =List.from(_selectedNodeHierarchy!.reversed);+ for (var node in reversedSelectedNodeHierarchy) {+ benchmarkStatusList.add({node: false});+ }try {- // 4. Loop through the nodes in the hierarchy+ // Loop through the nodes in the hierarchyfor (var node in reversedSelectedNodeHierarchy) {- // 5. Create a BenchmarkTaskRequestBody+ // Create a BenchmarkTaskRequestBodyfinal benchmarkTaskRequestBody = BenchmarkTaskRequestBody(input: node.data.task, evalId: node.data.evalId);- // 6. Create a new benchmark task+ // Create a new benchmark taskfinal createdTask = await benchmarkService.createBenchmarkTask(benchmarkTaskRequestBody);- // 7. Create a new Task object+ // Create a new Task objectfinal task =Task(id: createdTask['task_id'], title: createdTask['input']);- // 8. Update the current task ID in ChatViewModel+ // Update the current task ID in ChatViewModelchatViewModel.setCurrentTaskId(task.id);- // 9. Execute the first step and initialize the Step object+ // Execute the first step and initialize the Step objectMap<String, dynamic> stepResponse =await benchmarkService.executeBenchmarkStep(task.id, BenchmarkStepRequestBody(input: null));Step step = Step.fromMap(stepResponse);- // 11. Check if it's the last step+ // Check if it's the last stepwhile (!step.isLast) {// Fetch chats for the taskchatViewModel.fetchChatsForTask();@@ -184,10 +191,17 @@ class SkillTreeViewModel extends ChangeNotifier {step = Step.fromMap(stepResponse);}- // 12. Trigger the evaluation+ // Trigger the evaluationfinal evaluationResponse =await benchmarkService.triggerEvaluation(task.id);print("Evaluation response: $evaluationResponse");++ // Update the benchmarkStatusList based on the evaluation response+ bool successStatus = evaluationResponse['metrics']['success'];+ var nodeStatus = benchmarkStatusList.firstWhere(+ (element) => element.keys.first.id == node.id,+ );+ nodeStatus[node] = successStatus;}} catch (e) {print("Error while running benchmark: $e");@@ -197,10 +211,4 @@ class SkillTreeViewModel extends ChangeNotifier {isBenchmarkRunning = false;notifyListeners();}-- // Getter to expose nodes for the View- List<SkillTreeNode> get skillTreeNodes => _skillTreeNodes;-- // Getter to expose edges for the View- List<SkillTreeEdge> get skillTreeEdges => _skillTreeEdges;}