Message.fromJson constructor
Implementation
factory Message.fromJson(Map<String, Object?> json) {
final role = Role.fromJsonName(json['role']?.toString());
final toolCalls = json['tool_calls'] is List<Object?>
? (json['tool_calls'] as List<Object?>)
.whereType<Map<String, Object?>>()
.map(ToolCall.fromJson)
.toList(growable: false)
: const <ToolCall>[];
final channels = json['channels'] is Map<String, Object?>
? (json['channels'] as Map<String, Object?>).map(
(key, value) => MapEntry(key, value?.toString() ?? ''),
)
: const <String, String>{};
return Message(
role: role,
contents: Contents.fromJson(json['content']),
toolCalls: toolCalls,
channels: channels,
);
}