Skip to content

Commit 61f2ee3

Browse files
authored
[Vertex AI] Rename CandidateResponse to Candidate (#13897)
1 parent 4ca1413 commit 61f2ee3

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

FirebaseVertexAI/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
- [changed] **Breaking Change**: The `FunctionCallingConfig` initializer and
5151
`Mode` enum are now internal; use one of the new type methods `auto()`,
5252
`any(allowedFunctionNames:)`, or `none()` to create a config. (#13873)
53+
- [changed] **Breaking Change**: The `CandidateResponse` type is now named
54+
`Candidate`. (#13897)
5355
- [changed] The default request timeout is now 180 seconds instead of the
5456
platform-default value of 60 seconds for a `URLRequest`; this timeout may
5557
still be customized in `RequestOptions`. (#13722)

FirebaseVertexAI/Sample/ChatSample/Views/ErrorDetailsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct ErrorDetailsView: View {
162162
let error = GenerateContentError.responseStoppedEarly(
163163
reason: .maxTokens,
164164
response: GenerateContentResponse(candidates: [
165-
CandidateResponse(content: ModelContent(role: "model", parts:
165+
Candidate(content: ModelContent(role: "model", parts:
166166
"""
167167
A _hypothetical_ model response.
168168
Cillum ex aliqua amet aliquip labore amet eiusmod consectetur reprehenderit sit commodo.
@@ -212,7 +212,7 @@ struct ErrorDetailsView: View {
212212
#Preview("Prompt Blocked") {
213213
let error = GenerateContentError.promptBlocked(
214214
response: GenerateContentResponse(candidates: [
215-
CandidateResponse(content: ModelContent(role: "model", parts:
215+
Candidate(content: ModelContent(role: "model", parts:
216216
"""
217217
A _hypothetical_ model response.
218218
Cillum ex aliqua amet aliquip labore amet eiusmod consectetur reprehenderit sit commodo.

FirebaseVertexAI/Sample/ChatSample/Views/ErrorView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct ErrorView: View {
3838
let errorPromptBlocked = GenerateContentError.promptBlocked(
3939
response: GenerateContentResponse(
4040
candidates: [
41-
CandidateResponse(
41+
Candidate(
4242
content: ModelContent(role: "model", parts: [
4343
"""
4444
A _hypothetical_ model response.

FirebaseVertexAI/Sources/GenerateContentResponse.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public struct GenerateContentResponse: Sendable {
3030
}
3131

3232
/// A list of candidate response content, ordered from best to worst.
33-
public let candidates: [CandidateResponse]
33+
public let candidates: [Candidate]
3434

3535
/// A value containing the safety ratings for the response, or, if the request was blocked, a
3636
/// reason for blocking the request.
@@ -82,7 +82,7 @@ public struct GenerateContentResponse: Sendable {
8282
}
8383

8484
/// Initializer for SwiftUI previews or tests.
85-
public init(candidates: [CandidateResponse], promptFeedback: PromptFeedback? = nil,
85+
public init(candidates: [Candidate], promptFeedback: PromptFeedback? = nil,
8686
usageMetadata: UsageMetadata? = nil) {
8787
self.candidates = candidates
8888
self.promptFeedback = promptFeedback
@@ -93,7 +93,7 @@ public struct GenerateContentResponse: Sendable {
9393
/// A struct representing a possible reply to a content generation prompt. Each content generation
9494
/// prompt may produce multiple candidate responses.
9595
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
96-
public struct CandidateResponse: Sendable {
96+
public struct Candidate: Sendable {
9797
/// The response's content.
9898
public let content: ModelContent
9999

@@ -279,7 +279,7 @@ extension GenerateContentResponse: Decodable {
279279
}
280280

281281
if let candidates = try container.decodeIfPresent(
282-
[CandidateResponse].self,
282+
[Candidate].self,
283283
forKey: .candidates
284284
) {
285285
self.candidates = candidates
@@ -309,7 +309,7 @@ extension GenerateContentResponse.UsageMetadata: Decodable {
309309
}
310310

311311
@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
312-
extension CandidateResponse: Decodable {
312+
extension Candidate: Decodable {
313313
enum CodingKeys: CodingKey {
314314
case content
315315
case safetyRatings

FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ final class VertexAIAPITests: XCTestCase {
162162
func generateContentResponseAPI() {
163163
let response = GenerateContentResponse(candidates: [])
164164

165-
let _: [CandidateResponse] = response.candidates
165+
let _: [Candidate] = response.candidates
166166
let _: PromptFeedback? = response.promptFeedback
167167

168168
// Usage Metadata

0 commit comments

Comments
 (0)