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.

Fix empty user chats

hunteraraujoa8023c259876
diff --git a/frontend/lib/viewmodels/chat_viewmodel.dart b/frontend/lib/viewmodels/chat_viewmodel.dart
index baf8e6543d..f85c9d5eac 100644
--- a/frontend/lib/viewmodels/chat_viewmodel.dart
+++ b/frontend/lib/viewmodels/chat_viewmodel.dart
@@ -120,13 +120,17 @@ class ChatViewModel with ChangeNotifier {
Step executedStep = Step.fromMap(executedStepResponse);
// Create a Chat object for the user message
- final userChat = Chat(
- id: executedStep.stepId,
- taskId: executedStep.taskId,
- message: executedStep.input,
- timestamp: DateTime.now(),
- messageType: MessageType.user,
- );
+ if (executedStep.input.isNotEmpty) {
+ final userChat = Chat(
+ id: executedStep.stepId,
+ taskId: executedStep.taskId,
+ message: executedStep.input,
+ timestamp: DateTime.now(),
+ messageType: MessageType.user,
+ );
+
+ _chats.add(userChat);
+ }
// Create a Chat object for the agent message
final agentChat = Chat(
@@ -137,8 +141,6 @@ class ChatViewModel with ChangeNotifier {
messageType: MessageType.agent,
jsonResponse: executedStepResponse);
- // Add the user and agent chats to the list
- _chats.add(userChat);
_chats.add(agentChat);
// Notify UI of the new chats