CountTokensResponse.fromJson constructor
CountTokensResponse.fromJson(
- Object? j
Implementation
factory CountTokensResponse.fromJson(Object? j) {
final json = j as Map<String, Object?>;
return CountTokensResponse(
totalTokens: switch (json['totalTokens']) {
null => 0,
Object $1 => decodeInt($1),
},
cachedContentTokenCount: switch (json['cachedContentTokenCount']) {
null => 0,
Object $1 => decodeInt($1),
},
promptTokensDetails: switch (json['promptTokensDetails']) {
null => [],
List<Object?> $1 => [
for (final i in $1) ModalityTokenCount.fromJson(i),
],
_ => throw const FormatException('"promptTokensDetails" is not a list'),
},
cacheTokensDetails: switch (json['cacheTokensDetails']) {
null => [],
List<Object?> $1 => [
for (final i in $1) ModalityTokenCount.fromJson(i),
],
_ => throw const FormatException('"cacheTokensDetails" is not a list'),
},
);
}