Skip to content

[Vertex AI] Rename CandidateResponse to Candidate #13897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions FirebaseVertexAI/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
- [changed] **Breaking Change**: The `FunctionCallingConfig` initializer and
`Mode` enum are now internal; use one of the new type methods `auto()`,
`any(allowedFunctionNames:)`, or `none()` to create a config. (#13873)
- [changed] **Breaking Change**: The `CandidateResponse` type is now named
`Candidate`. (#13897)
- [changed] The default request timeout is now 180 seconds instead of the
platform-default value of 60 seconds for a `URLRequest`; this timeout may
still be customized in `RequestOptions`. (#13722)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct ErrorDetailsView: View {
let error = GenerateContentError.responseStoppedEarly(
reason: .maxTokens,
response: GenerateContentResponse(candidates: [
CandidateResponse(content: ModelContent(role: "model", parts:
Candidate(content: ModelContent(role: "model", parts:
"""
A _hypothetical_ model response.
Cillum ex aliqua amet aliquip labore amet eiusmod consectetur reprehenderit sit commodo.
Expand Down Expand Up @@ -212,7 +212,7 @@ struct ErrorDetailsView: View {
#Preview("Prompt Blocked") {
let error = GenerateContentError.promptBlocked(
response: GenerateContentResponse(candidates: [
CandidateResponse(content: ModelContent(role: "model", parts:
Candidate(content: ModelContent(role: "model", parts:
"""
A _hypothetical_ model response.
Cillum ex aliqua amet aliquip labore amet eiusmod consectetur reprehenderit sit commodo.
Expand Down
2 changes: 1 addition & 1 deletion FirebaseVertexAI/Sample/ChatSample/Views/ErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct ErrorView: View {
let errorPromptBlocked = GenerateContentError.promptBlocked(
response: GenerateContentResponse(
candidates: [
CandidateResponse(
Candidate(
content: ModelContent(role: "model", parts: [
"""
A _hypothetical_ model response.
Expand Down
10 changes: 5 additions & 5 deletions FirebaseVertexAI/Sources/GenerateContentResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct GenerateContentResponse: Sendable {
}

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

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

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

Expand Down Expand Up @@ -279,7 +279,7 @@ extension GenerateContentResponse: Decodable {
}

if let candidates = try container.decodeIfPresent(
[CandidateResponse].self,
[Candidate].self,
forKey: .candidates
) {
self.candidates = candidates
Expand Down Expand Up @@ -309,7 +309,7 @@ extension GenerateContentResponse.UsageMetadata: Decodable {
}

@available(iOS 15.0, macOS 11.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
extension CandidateResponse: Decodable {
extension Candidate: Decodable {
enum CodingKeys: CodingKey {
case content
case safetyRatings
Expand Down
2 changes: 1 addition & 1 deletion FirebaseVertexAI/Tests/Unit/VertexAIAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ final class VertexAIAPITests: XCTestCase {
func generateContentResponseAPI() {
let response = GenerateContentResponse(candidates: [])

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

// Usage Metadata
Expand Down
Loading