From 75e66a2029d0e91332961bf494f546114d9c1d6c Mon Sep 17 00:00:00 2001 From: Rodrigo Lazo Paz Date: Tue, 30 Sep 2025 13:52:59 -0400 Subject: [PATCH 1/2] [ALF] Deprecate `UsageMetadata` public constructor The class was never meant to be instantiated by clients. The public constructor is now marked as deprecated and will be removed in a upcoming major version bump. Additionally, the PR includes an unused parameter in the internal version to get the code to build. It will be removed in a upcoming change were an actual new parameter, exclusive to the internal constructor, is added. --- .../google/firebase/ai/type/UsageMetadata.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/UsageMetadata.kt b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/UsageMetadata.kt index 1c7d39103fb..e733445e916 100644 --- a/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/UsageMetadata.kt +++ b/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/UsageMetadata.kt @@ -30,15 +30,35 @@ import kotlinx.serialization.Serializable * candidates. * @param thoughtsTokenCount The number of tokens used by the model's internal "thinking" process. */ -public class UsageMetadata( +public class UsageMetadata +internal constructor( public val promptTokenCount: Int, public val candidatesTokenCount: Int?, public val totalTokenCount: Int, public val promptTokensDetails: List, public val candidatesTokensDetails: List, public val thoughtsTokenCount: Int, + placeholder: Unit ) { + @Deprecated("Not intended for public use") + public constructor( + promptTokenCount: Int, + candidatesTokenCount: Int?, + totalTokenCount: Int, + promptTokensDetails: List, + candidatesTokensDetails: List, + thoughtsTokenCount: Int + ) : this( + promptTokenCount, + candidatesTokenCount, + totalTokenCount, + promptTokensDetails, + candidatesTokensDetails, + thoughtsTokenCount, + Unit + ) + @Serializable internal data class Internal( val promptTokenCount: Int? = null, From b5904f29e9ac12a4e506ef6d9721c5052a57f0a5 Mon Sep 17 00:00:00 2001 From: Rodrigo Lazo Paz Date: Tue, 30 Sep 2025 13:54:11 -0400 Subject: [PATCH 2/2] Add changelog entry --- firebase-ai/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/firebase-ai/CHANGELOG.md b/firebase-ai/CHANGELOG.md index a38389fca7c..d694b73cce8 100644 --- a/firebase-ai/CHANGELOG.md +++ b/firebase-ai/CHANGELOG.md @@ -3,6 +3,7 @@ - [changed] **Breaking Change**: Removed the `candidateCount` option from `LiveGenerationConfig` (#7382) - [changed] Added better error messages to `ServiceConnectionHandshakeFailedException` (#7412) +- [changed] Marked the public constructor for `UsageMetadata` as deprecated (#7420) # 17.3.0