toJson method
Converts to JSON.
Implementation
Map<String, dynamic> toJson() => {
'role': role,
'content': content,
if (attachments != null)
'attachments': attachments!.map((a) => a.toJson()).toList(),
if (metadata != null) 'metadata': metadata,
};