MemoryRecallItem.fromJson constructor
MemoryRecallItem.fromJson(
- Map<String, dynamic> json
)
Implementation
factory MemoryRecallItem.fromJson(Map<String, dynamic> json) {
final rawRelationships = json["relationships"];
if (rawRelationships != null && rawRelationships is! List) {
throw _memoryUnexpectedResponseError("recall");
}
final score = _memoryOptionalDouble(json["score"]);
if (score == null) {
throw _memoryUnexpectedResponseError("recall");
}
return MemoryRecallItem(
entityId: _memoryRequiredString(json["entity_id"], "recall"),
name: _memoryRequiredString(json["name"], "recall"),
entityType: _memoryRequiredString(json["entity_type"], "recall"),
context: json["context"] as String?,
confidence: _memoryOptionalDouble(json["confidence"]),
createdAt: json["created_at"] as String?,
validAt: json["valid_at"] as String?,
score: score,
relationships: (rawRelationships as List? ?? const [])
.map((item) => MemoryRecallRelationship.fromJson(_memoryJsonMap(item, "recall")))
.toList(growable: false),
);
}