Skip to content

Commit c9536b8

Browse files
committed
Add totalBillableCharacters to CountTokensResponse in Vertex AI (#12646)
1 parent 261c236 commit c9536b8

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

FirebaseVertexAI/Sources/CountTokensRequest.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ extension CountTokensRequest: GenerativeAIRequest {
4242
public struct CountTokensResponse: Decodable {
4343
/// The total number of tokens in the input given to the model as a prompt.
4444
public let totalTokens: Int
45+
46+
/// The total number of billable characters in the input given to the model as a prompt.
47+
public let totalBillableCharacters: Int
4548
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"totalTokens": 6
2+
"totalTokens": 6,
3+
"totalBillableCharacters": 16
34
}

FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,9 @@ final class GenerativeModelTests: XCTestCase {
935935
)
936936

937937
let response = try await model.countTokens("Why is the sky blue?")
938+
938939
XCTAssertEqual(response.totalTokens, 6)
940+
XCTAssertEqual(response.totalBillableCharacters, 16)
939941
}
940942

941943
func testCountTokens_modelNotFound() async throws {

0 commit comments

Comments
 (0)