RichMessage.fromJson constructor
Factory constructor to create a RichMessage from a JSON map.
Implementation
factory RichMessage.fromJson(Map<String, dynamic> json) => RichMessage(
id: json['id'] as String?,
key: json['key'] as String?,
from: json['from'] as String?,
versions: json['versions'] != null
? (json['versions'] as List)
.map((e) => MessageVersionType.fromJson(e))
.toList()
: null,
tools: json['tools'] != null
? (json['tools'] as List).map((e) => ToolCallType.fromJson(e)).toList()
: null,
sources: json['sources'] != null
? (json['sources'] as List).map((e) => SourceType.fromJson(e)).toList()
: null,
reasoning: json['reasoning'] != null
? ReasoningType.fromJson(json['reasoning'])
: null,
chainOfThought: json['chainOfThought'] != null
? ChainOfThoughtType.fromJson(json['chainOfThought'])
: null,
plan: json['plan'] != null ? PlanType.fromJson(json['plan']) : null,
contextData: json['contextData'] != null
? ContextDataType.fromJson(json['contextData'])
: null,
confirmation: json['confirmation'] != null
? ConfirmationType.fromJson(json['confirmation'])
: null,
checkpoints: json['checkpoints'] != null
? (json['checkpoints'] as List)
.map((e) => CheckpointType.fromJson(e))
.toList()
: null,
suggestions: json['suggestions'] != null
? List<String>.from(json['suggestions'])
: null,
tasks: json['tasks'] != null
? (json['tasks'] as List).map((e) => TaskType.fromJson(e)).toList()
: null,
messageQueue: json['messageQueue'] != null
? (json['messageQueue'] as List)
.map((e) => SimpleMessageType.fromJson(e))
.toList()
: null,
conversationId: json['conversationId'] as String?,
sessionId: json['session_id'] as String?,
createdAt: json['createdAt'] != null
? DateTime.parse(json['createdAt'])
: null,
updatedAt: json['updatedAt'] != null
? DateTime.parse(json['updatedAt'])
: null,
);