AIMessage.fromJson constructor
AIMessage.fromJson( - Map<String, dynamic> json
)
Implementation
factory AIMessage.fromJson(Map<String, dynamic> json) {
return AIMessage(
role: AIRole.values.firstWhere((e) => e.name == json['role']),
content: json['content'] as String,
attachments: json['attachments'] != null
? (json['attachments'] as List)
.map((e) => AIAttachment.fromJson(e as Map<String, dynamic>))
.toList()
: null,
metadata: json['metadata'] as Map<String, dynamic>?,
toolCalls: json['toolCalls'] != null
? (json['toolCalls'] as List)
.map((e) => AIToolCall.fromJson(e as Map<String, dynamic>))
.toList()
: null,
toolCallId: json['toolCallId'] as String?,
timestamp: DateTime.parse(json['timestamp'] as String),
id: json['id'] as String,
);
}