Message.fromMap constructor
Implementation
factory Message.fromMap(Map<String, dynamic> map) {
String role = map['role'];
int createdAt = map['created_at'];
List content = map['content'];
String getText() {
for (Map item in content) {
String type = item['type'];
if (type == 'text') {
Map text = item['text'];
//List annotations = item['annotations'];
return text['value'];
}
}
return 'NOT IMPLEMENTED';
}
return Message(
date: DateTime.fromMillisecondsSinceEpoch(createdAt),
text: getText(),
sender: role == 'user' ? SenderType.user : SenderType.assistant,
threadId: map['thread_id'],
);
}