mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
Implement Continuous Mode in ChatViewModel
Added a new state variable `_isContinuousMode` to the ChatViewModel to track whether the chat is in continuous mode or not. This state is toggled via a setter and triggers UI updates through `notifyListeners()`. Enhanced the `sendChatMessage` method to automatically send a null message if continuous mode is active, triggering the next step in the chat.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user