mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 22:14:28 +01:00
Added Artifact Handling for Chat Messages
- Enhanced the `Chat` model to include an `artifacts` field to hold associated artifacts. - Updated the `AgentMessageTile` widget to display the number of artifacts and added functionality to trigger artifact downloads upon button press. - Introduced a method in `ChatViewModel` to leverage the `ChatService` for artifact downloads.
This commit is contained in:
@@ -8,6 +8,7 @@ class Chat {
|
||||
final DateTime timestamp;
|
||||
final MessageType messageType;
|
||||
final Map<String, dynamic>? jsonResponse;
|
||||
final List<dynamic> artifacts;
|
||||
|
||||
Chat({
|
||||
required this.id,
|
||||
@@ -16,6 +17,7 @@ class Chat {
|
||||
required this.timestamp,
|
||||
required this.messageType,
|
||||
this.jsonResponse,
|
||||
required this.artifacts,
|
||||
});
|
||||
|
||||
// Convert a Map (usually from JSON) to a Chat object
|
||||
@@ -27,6 +29,7 @@ class Chat {
|
||||
timestamp: DateTime.parse(map['timestamp']),
|
||||
messageType: MessageType.values.firstWhere(
|
||||
(e) => e.toString() == 'MessageType.${map['messageType']}'),
|
||||
artifacts: List<dynamic>.from(map['artifacts'] ?? []),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,7 +42,8 @@ class Chat {
|
||||
taskId == other.taskId &&
|
||||
message == other.message &&
|
||||
timestamp == other.timestamp &&
|
||||
messageType == other.messageType;
|
||||
messageType == other.messageType &&
|
||||
artifacts == other.artifacts;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
@@ -47,9 +51,10 @@ class Chat {
|
||||
taskId.hashCode ^
|
||||
message.hashCode ^
|
||||
timestamp.hashCode ^
|
||||
messageType.hashCode;
|
||||
messageType.hashCode ^
|
||||
artifacts.hashCode;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'Chat(id: $id, taskId: $taskId, message: $message, timestamp: $timestamp, messageType: $messageType)';
|
||||
'Chat(id: $id, taskId: $taskId, message: $message, timestamp: $timestamp, messageType: $messageType, artifacts: $artifacts)'; // Added artifacts in toString method
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user