Skip to content

Commit

Permalink
Add totalBillableCharacters to CountTokensResponse in Vertex AI (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard authored Mar 27, 2024
1 parent 3e32efe commit 0711dc1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions FirebaseVertexAI/Sources/CountTokensRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ extension CountTokensRequest: GenerativeAIRequest {
public struct CountTokensResponse: Decodable {
/// The total number of tokens in the input given to the model as a prompt.
public let totalTokens: Int

/// The total number of billable characters in the input given to the model as a prompt.
public let totalBillableCharacters: Int
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"totalTokens": 6
"totalTokens": 6,
"totalBillableCharacters": 16
}
2 changes: 2 additions & 0 deletions FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,9 @@ final class GenerativeModelTests: XCTestCase {
)

let response = try await model.countTokens("Why is the sky blue?")

XCTAssertEqual(response.totalTokens, 6)
XCTAssertEqual(response.totalBillableCharacters, 16)
}

func testCountTokens_modelNotFound() async throws {
Expand Down

0 comments on commit 0711dc1

Please sign in to comment.