From 32a6788e806b4a34ccaccdae8d7b638b5e63fa9b Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Thu, 7 Nov 2024 17:30:54 -0500 Subject: [PATCH] [Vertex AI] Fix `testCountTokens_jsonSchema` integration test (#14049) --- FirebaseVertexAI/CHANGELOG.md | 5 +++++ .../Tests/TestApp/Tests/Integration/IntegrationTests.swift | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/FirebaseVertexAI/CHANGELOG.md b/FirebaseVertexAI/CHANGELOG.md index b4a67aff89f..a7c1b1aaba5 100644 --- a/FirebaseVertexAI/CHANGELOG.md +++ b/FirebaseVertexAI/CHANGELOG.md @@ -1,3 +1,8 @@ +# Unreleased +- [changed] The token counts from `GenerativeModel.countTokens(...)` now include + tokens from the schema for JSON output and function calling; reported token + counts will now be higher if using these features. + # 11.5.0 - [fixed] Fixed an issue where `VertexAI.vertexAI(app: app1)` and `VertexAI.vertexAI(app: app2)` would return the same instance if their diff --git a/FirebaseVertexAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift b/FirebaseVertexAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift index 15e0435e275..8e6e6c8d601 100644 --- a/FirebaseVertexAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift +++ b/FirebaseVertexAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift @@ -217,8 +217,8 @@ final class IntegrationTests: XCTestCase { let response = try await model.countTokens(prompt) - XCTAssertEqual(response.totalTokens, 34) - XCTAssertEqual(response.totalBillableCharacters, 59) + XCTAssertEqual(response.totalTokens, 58) + XCTAssertEqual(response.totalBillableCharacters, 160) } func testCountTokens_appCheckNotConfigured_shouldFail() async throws {