|
|
@ -1,6 +1,7 @@ |
|
|
class Message { |
|
|
class Message { |
|
|
final String role; // 'user' or 'assistant' |
|
|
final String role; // 'user' or 'assistant' |
|
|
final String content; |
|
|
final String content; |
|
|
|
|
|
final Map? data; |
|
|
final DateTime timestamp; |
|
|
final DateTime timestamp; |
|
|
final bool isLoading; |
|
|
final bool isLoading; |
|
|
|
|
|
|
|
|
@ -8,6 +9,7 @@ class Message { |
|
|
required this.role, |
|
|
required this.role, |
|
|
required this.content, |
|
|
required this.content, |
|
|
required this.timestamp, |
|
|
required this.timestamp, |
|
|
|
|
|
this.data, |
|
|
this.isLoading = false, |
|
|
this.isLoading = false, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -16,6 +18,7 @@ class Message { |
|
|
return Message( |
|
|
return Message( |
|
|
role: json['role'] as String, |
|
|
role: json['role'] as String, |
|
|
content: json['content'] as String, |
|
|
content: json['content'] as String, |
|
|
|
|
|
data: json['data'], |
|
|
timestamp: DateTime.parse(json['timestamp'] as String), |
|
|
timestamp: DateTime.parse(json['timestamp'] as String), |
|
|
isLoading: json['isLoading'] as bool? ?? false, |
|
|
isLoading: json['isLoading'] as bool? ?? false, |
|
|
); |
|
|
); |
|
|
@ -26,6 +29,7 @@ class Message { |
|
|
return { |
|
|
return { |
|
|
'role': role, |
|
|
'role': role, |
|
|
'content': content, |
|
|
'content': content, |
|
|
|
|
|
'data': data, |
|
|
'timestamp': timestamp.toIso8601String(), |
|
|
'timestamp': timestamp.toIso8601String(), |
|
|
'isLoading': isLoading, |
|
|
'isLoading': isLoading, |
|
|
}; |
|
|
}; |
|
|
@ -45,14 +49,16 @@ class Message { |
|
|
Message copyWith({ |
|
|
Message copyWith({ |
|
|
String? role, |
|
|
String? role, |
|
|
String? content, |
|
|
String? content, |
|
|
|
|
|
Map? data, |
|
|
DateTime? timestamp, |
|
|
DateTime? timestamp, |
|
|
bool? isLoading, |
|
|
bool? isLoading, |
|
|
}) { |
|
|
}) { |
|
|
return Message( |
|
|
return Message( |
|
|
role: role ?? this.role, |
|
|
role: role ?? this.role, |
|
|
content: content ?? this.content, |
|
|
content: content ?? this.content, |
|
|
|
|
|
data: data ?? this.data, |
|
|
timestamp: timestamp ?? this.timestamp, |
|
|
timestamp: timestamp ?? this.timestamp, |
|
|
isLoading: isLoading ?? this.isLoading, |
|
|
isLoading: isLoading ?? this.isLoading, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|