ContentPart.fromJson constructor
ContentPart.fromJson(
- Map<String, dynamic> json
)
Implementation
factory ContentPart.fromJson(Map<String, dynamic> json) {
final tag = json['type'] as String;
return switch (tag) {
'text' => ContentPartText.fromJson(json),
'image' => ContentPartImage.fromJson(json),
'file' => ContentPartFile.fromJson(json),
'file_base64' => ContentPartFileBase64.fromJson(json),
'file_url' => ContentPartFileUrl.fromJson(json),
'file_reference' => ContentPartFileReference.fromJson(json),
'reasoning' => ContentPartReasoning.fromJson(json),
'tool_call' => ContentPartToolCall.fromJson(json),
'tool_result' => ContentPartToolResult.fromJson(json),
_ => ContentPartUnknown(tag: tag, data: json),
};
}