Skip to content

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.

Implement Continuous Mode in ChatViewModel

hunteraraujo5cd1abab945a
diff --git a/frontend/lib/viewmodels/chat_viewmodel.dart b/frontend/lib/viewmodels/chat_viewmodel.dart
index 5c8fb3cae5..baf8e6543d 100644
--- a/frontend/lib/viewmodels/chat_viewmodel.dart
+++ b/frontend/lib/viewmodels/chat_viewmodel.dart
@@ -10,6 +10,14 @@ class ChatViewModel with ChangeNotifier {
List<Chat> _chats = [];
String? _currentTaskId;
+ bool _isContinuousMode = false;
+
+ bool get isContinuousMode => _isContinuousMode;
+ set isContinuousMode(bool value) {
+ _isContinuousMode = value;
+ notifyListeners();
+ }
+
ChatViewModel(this._chatService);
/// Returns the current list of chats.
@@ -95,7 +103,7 @@ class ChatViewModel with ChangeNotifier {
}
/// Sends a chat message for a specific task.
- void sendChatMessage(String message) async {
+ void sendChatMessage(String? message) async {
if (_currentTaskId == null) {
print("Error: Task ID is not set.");
return;
@@ -136,6 +144,10 @@ class ChatViewModel with ChangeNotifier {
// Notify UI of the new chats
notifyListeners();
+ if (_isContinuousMode) {
+ sendChatMessage(null);
+ }
+
print("Chats added for task ID: $_currentTaskId");
} catch (error) {
// TODO: Bubble up errors to UI