toJson method
Implementation
Map<String, dynamic> toJson() {
final hasImages = images != null && images!.isNotEmpty;
if (!hasImages) {
return {'role': role, 'content': content};
}
final contentList = <Map<String, dynamic>>[
{'type': 'text', 'text': content},
];
for (final image in images!) {
contentList.add({
'type': 'image_url',
'image_url': {'url': image},
});
}
return {'role': role, 'content': contentList};
}