Skip to content

Commit

Permalink
Add public API tests for GenerateContentResponse in Vertex AI (#12791)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed May 1, 2024
1 parent 14b5af1 commit dea1f7e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,24 @@ final class VertexAIAPITests: XCTestCase {
_ = genAI.startChat(history: [ModelContent(parts: "abc")])
}

// Public API tests for GenerateContentResponse.
func generateContentResponseAPI() {
let response = GenerateContentResponse(candidates: [])

let _: [CandidateResponse] = response.candidates
let _: PromptFeedback? = response.promptFeedback

// Usage Metadata
guard let usageMetadata = response.usageMetadata else { fatalError() }
let _: Int = usageMetadata.promptTokenCount
let _: Int = usageMetadata.candidatesTokenCount
let _: Int = usageMetadata.totalTokenCount

// Computed Properties
let _: String? = response.text
let _: [FunctionCall] = response.functionCalls
}

// Result builder alternative

/*
Expand Down

0 comments on commit dea1f7e

Please sign in to comment.