Integrate TaskQueueViewModel throughout application
parent
a7e27d1a64
commit
51ebe2407d
|
@ -1,5 +1,6 @@
|
||||||
import 'package:auto_gpt_flutter_client/services/leaderboard_service.dart';
|
import 'package:auto_gpt_flutter_client/services/leaderboard_service.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
|
||||||
|
import 'package:auto_gpt_flutter_client/viewmodels/task_queue_viewmodel.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';
|
||||||
|
@ -97,7 +98,9 @@ class MyApp extends StatelessWidget {
|
||||||
create: (context) => TaskViewModel(
|
create: (context) => TaskViewModel(
|
||||||
Provider.of<TaskService>(context, listen: false))),
|
Provider.of<TaskService>(context, listen: false))),
|
||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (context) => SkillTreeViewModel(
|
create: (context) => SkillTreeViewModel()),
|
||||||
|
ChangeNotifierProvider(
|
||||||
|
create: (context) => TaskQueueViewModel(
|
||||||
Provider.of<BenchmarkService>(context, listen: false),
|
Provider.of<BenchmarkService>(context, listen: false),
|
||||||
Provider.of<LeaderboardService>(context, listen: false)),
|
Provider.of<LeaderboardService>(context, listen: false)),
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// TODO: Put more thought into task status vs. benchmark task status
|
||||||
enum BenchmarkTaskStatus {
|
enum BenchmarkTaskStatus {
|
||||||
notStarted,
|
notStarted,
|
||||||
inProgress,
|
inProgress,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:auto_gpt_flutter_client/models/message_type.dart';
|
import 'package:auto_gpt_flutter_client/models/message_type.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
||||||
|
import 'package:auto_gpt_flutter_client/viewmodels/task_queue_viewmodel.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
||||||
import 'package:auto_gpt_flutter_client/views/chat/agent_message_tile.dart';
|
import 'package:auto_gpt_flutter_client/views/chat/agent_message_tile.dart';
|
||||||
import 'package:auto_gpt_flutter_client/views/chat/chat_input_field.dart';
|
import 'package:auto_gpt_flutter_client/views/chat/chat_input_field.dart';
|
||||||
|
@ -103,7 +104,7 @@ class _ChatViewState extends State<ChatView> {
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
LoadingIndicator(
|
LoadingIndicator(
|
||||||
isLoading: Provider.of<SkillTreeViewModel>(context, listen: true)
|
isLoading: Provider.of<TaskQueueViewModel>(context, listen: true)
|
||||||
.isBenchmarkRunning ||
|
.isBenchmarkRunning ||
|
||||||
widget.viewModel.isWaitingForAgentResponse),
|
widget.viewModel.isWaitingForAgentResponse),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/task_queue_viewmodel.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
@ -22,8 +22,8 @@ class SideBarView extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// TODO: should we pass this in as a dependency?
|
// TODO: should we pass this in as a dependency?
|
||||||
final skillTreeViewModel =
|
final taskQueueViewModel =
|
||||||
Provider.of<SkillTreeViewModel>(context, listen: true);
|
Provider.of<TaskQueueViewModel>(context, listen: true);
|
||||||
return Material(
|
return Material(
|
||||||
child: ValueListenableBuilder(
|
child: ValueListenableBuilder(
|
||||||
valueListenable: selectedViewNotifier,
|
valueListenable: selectedViewNotifier,
|
||||||
|
@ -40,7 +40,7 @@ class SideBarView extends StatelessWidget {
|
||||||
? Colors.blue
|
? Colors.blue
|
||||||
: Colors.black,
|
: Colors.black,
|
||||||
icon: const Icon(Icons.chat),
|
icon: const Icon(Icons.chat),
|
||||||
onPressed: skillTreeViewModel.isBenchmarkRunning
|
onPressed: taskQueueViewModel.isBenchmarkRunning
|
||||||
? null
|
? null
|
||||||
: () => selectedViewNotifier.value = 'TaskView',
|
: () => selectedViewNotifier.value = 'TaskView',
|
||||||
),
|
),
|
||||||
|
@ -52,7 +52,7 @@ class SideBarView extends StatelessWidget {
|
||||||
? Colors.blue
|
? Colors.blue
|
||||||
: Colors.black,
|
: Colors.black,
|
||||||
icon: const Icon(Icons.emoji_events),
|
icon: const Icon(Icons.emoji_events),
|
||||||
onPressed: skillTreeViewModel.isBenchmarkRunning
|
onPressed: taskQueueViewModel.isBenchmarkRunning
|
||||||
? null
|
? null
|
||||||
: () =>
|
: () =>
|
||||||
selectedViewNotifier.value = 'SkillTreeView',
|
selectedViewNotifier.value = 'SkillTreeView',
|
||||||
|
@ -74,9 +74,10 @@ class SideBarView extends StatelessWidget {
|
||||||
IconButton(
|
IconButton(
|
||||||
splashRadius: 0.1,
|
splashRadius: 0.1,
|
||||||
iconSize: 25,
|
iconSize: 25,
|
||||||
icon: Icon(Icons.book, color: Color.fromRGBO(50, 120, 123, 1)),
|
icon: Icon(Icons.book,
|
||||||
onPressed: () =>
|
color: Color.fromRGBO(50, 120, 123, 1)),
|
||||||
_launchURL('https://aiedge.medium.com/autogpt-forge-e3de53cc58ec'),
|
onPressed: () => _launchURL(
|
||||||
|
'https://aiedge.medium.com/autogpt-forge-e3de53cc58ec'),
|
||||||
tooltip: 'Learn how to build your own Agent',
|
tooltip: 'Learn how to build your own Agent',
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:auto_gpt_flutter_client/models/skill_tree/skill_tree_node.dart';
|
import 'package:auto_gpt_flutter_client/models/skill_tree/skill_tree_node.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
||||||
|
import 'package:auto_gpt_flutter_client/viewmodels/task_queue_viewmodel.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
@ -21,8 +22,18 @@ class _TreeNodeViewState extends State<TreeNodeView> {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
print('Node ${widget.node.id} clicked');
|
print('Node ${widget.node.id} clicked');
|
||||||
Provider.of<SkillTreeViewModel>(context, listen: false)
|
final taskQueueViewModel =
|
||||||
.toggleNodeSelection(widget.node.id);
|
Provider.of<TaskQueueViewModel>(context, listen: false);
|
||||||
|
if (!taskQueueViewModel.isBenchmarkRunning) {
|
||||||
|
final skillTreeViewModel =
|
||||||
|
Provider.of<SkillTreeViewModel>(context, listen: false);
|
||||||
|
skillTreeViewModel.toggleNodeSelection(widget.node.id);
|
||||||
|
taskQueueViewModel.updateSelectedNodeHierarchyBasedOnOption(
|
||||||
|
taskQueueViewModel.selectedOption,
|
||||||
|
skillTreeViewModel.selectedNode,
|
||||||
|
skillTreeViewModel.skillTreeNodes,
|
||||||
|
skillTreeViewModel.skillTreeEdges);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: MouseRegion(
|
child: MouseRegion(
|
||||||
onEnter: (_) => setState(() => _isHovering = true),
|
onEnter: (_) => setState(() => _isHovering = true),
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_task_status.dart';
|
import 'package:auto_gpt_flutter_client/models/benchmark/benchmark_task_status.dart';
|
||||||
import 'package:auto_gpt_flutter_client/models/test_option.dart';
|
import 'package:auto_gpt_flutter_client/models/test_option.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/skill_tree_viewmodel.dart';
|
||||||
|
import 'package:auto_gpt_flutter_client/viewmodels/task_queue_viewmodel.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
import 'package:auto_gpt_flutter_client/viewmodels/task_viewmodel.dart';
|
||||||
import 'package:auto_gpt_flutter_client/views/task_queue/leaderboard_submission_button.dart';
|
import 'package:auto_gpt_flutter_client/views/task_queue/leaderboard_submission_button.dart';
|
||||||
import 'package:auto_gpt_flutter_client/views/task_queue/leaderboard_submission_dialog.dart';
|
import 'package:auto_gpt_flutter_client/views/task_queue/leaderboard_submission_dialog.dart';
|
||||||
import 'package:auto_gpt_flutter_client/views/task_queue/test_suite_button.dart';
|
import 'package:auto_gpt_flutter_client/views/task_queue/test_suite_button.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class TaskQueueView extends StatelessWidget {
|
class TaskQueueView extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final viewModel = Provider.of<SkillTreeViewModel>(context);
|
final viewModel = Provider.of<TaskQueueViewModel>(context);
|
||||||
|
|
||||||
// Node hierarchy
|
// Node hierarchy
|
||||||
final nodeHierarchy = viewModel.selectedNodeHierarchy ?? [];
|
final nodeHierarchy = viewModel.selectedNodeHierarchy ?? [];
|
||||||
|
@ -102,8 +103,13 @@ class TaskQueueView extends StatelessWidget {
|
||||||
selectedOptionString: viewModel.selectedOption.description,
|
selectedOptionString: viewModel.selectedOption.description,
|
||||||
onOptionSelected: (selectedOption) {
|
onOptionSelected: (selectedOption) {
|
||||||
print('Option Selected: $selectedOption');
|
print('Option Selected: $selectedOption');
|
||||||
|
final skillTreeViewModel =
|
||||||
|
Provider.of<SkillTreeViewModel>(context, listen: false);
|
||||||
viewModel.updateSelectedNodeHierarchyBasedOnOption(
|
viewModel.updateSelectedNodeHierarchyBasedOnOption(
|
||||||
TestOptionExtension.fromDescription(selectedOption)!);
|
TestOptionExtension.fromDescription(selectedOption)!,
|
||||||
|
skillTreeViewModel.selectedNode,
|
||||||
|
skillTreeViewModel.skillTreeNodes,
|
||||||
|
skillTreeViewModel.skillTreeEdges);
|
||||||
},
|
},
|
||||||
onPlayPressed: (selectedOption) {
|
onPlayPressed: (selectedOption) {
|
||||||
print('Starting benchmark with option: $selectedOption');
|
print('Starting benchmark with option: $selectedOption');
|
||||||
|
|
Loading…
Reference in New Issue