diff --git a/.changes/baseball-comfort-dock-appliance.json b/.changes/baseball-comfort-dock-appliance.json new file mode 100644 index 00000000..697a0e89 --- /dev/null +++ b/.changes/baseball-comfort-dock-appliance.json @@ -0,0 +1 @@ +{"type":"MAJOR","changes":["Make totalTokens in CountTokensResponse nullable"]} diff --git a/common/src/main/kotlin/com/google/ai/client/generativeai/common/Response.kt b/common/src/main/kotlin/com/google/ai/client/generativeai/common/Response.kt index 009f4743..ac7cec57 100644 --- a/common/src/main/kotlin/com/google/ai/client/generativeai/common/Response.kt +++ b/common/src/main/kotlin/com/google/ai/client/generativeai/common/Response.kt @@ -30,7 +30,9 @@ data class GenerateContentResponse( val usageMetadata: UsageMetadata? = null ) : Response -@Serializable data class CountTokensResponse(val totalTokens: Int) : Response +@Serializable +data class CountTokensResponse(val totalTokens: Int, val totalBillableCharacters: Int? = null) : + Response @Serializable data class GRpcErrorResponse(val error: GRpcError) : Response diff --git a/common/src/test/java/com/google/ai/client/generativeai/common/APIControllerTests.kt b/common/src/test/java/com/google/ai/client/generativeai/common/APIControllerTests.kt index b30d01f2..959f10dd 100644 --- a/common/src/test/java/com/google/ai/client/generativeai/common/APIControllerTests.kt +++ b/common/src/test/java/com/google/ai/client/generativeai/common/APIControllerTests.kt @@ -160,7 +160,8 @@ internal class RequestFormatTests { @Test fun `countTokenRequest doesn't include the model name`() = doBlocking { - val response = JSON.encodeToString(CountTokensResponse(totalTokens = 10)) + val response = + JSON.encodeToString(CountTokensResponse(totalTokens = 10, totalBillableCharacters = 10)) val mockEngine = MockEngine { respond(response, HttpStatusCode.OK, headersOf(HttpHeaders.ContentType, "application/json")) }