projectionEstimateChatMetadataRetainedBytes function
int
projectionEstimateChatMetadataRetainedBytes(
- ChatRetainedSizeEstimator estimator,
- Map<
String, Object?> metadata
Implementation
int projectionEstimateChatMetadataRetainedBytes(
acp.ChatRetainedSizeEstimator estimator,
Map<String, Object?> metadata,
) {
final kind = metadata['kind'];
if (metadata.length == 1 && kind is String && kind == 'thought') {
return _thoughtMetadataHostRetainedBytes;
}
final contentBlocks = metadata['contentBlocks'];
if (contentBlocks is List) {
return _estimateContentBlockMetadataRetainedBytes(
estimator,
metadata,
contentBlocks,
);
}
final options = metadata['configOptions'];
if (kind is! String || kind != 'config_option_update' || options is! List) {
return estimator.estimate(metadata);
}
final typedOptions = options.whereType<ChatConfigOption>().toList(
growable: false,
);
var retained = _typedConfigMetadataHostRetainedBytes;
return projectionAddConfigOptionsRetainedBytes(
retained,
estimator,
typedOptions,
);
}