TruncationRetentionRatio.fromJson constructor
Creates from JSON.
Implementation
factory TruncationRetentionRatio.fromJson(Map<String, dynamic> json) {
if (json['type'] != 'retention_ratio') {
throw FormatException(
'TruncationRetentionRatio.fromJson expected type "retention_ratio", '
'got ${json['type']}',
);
}
if (json['retention_ratio'] == null) {
throw const FormatException(
'TruncationRetentionRatio.fromJson missing required "retention_ratio" field',
);
}
final tokenLimits = json['token_limits'] as Map<String, dynamic>?;
return TruncationRetentionRatio(
retentionRatio: (json['retention_ratio'] as num).toDouble(),
postInstructionsTokenLimit: tokenLimits?['post_instructions'] as int?,
);
}