diff --git a/Sources/GoogleAI/GenerateContentResponse.swift b/Sources/GoogleAI/GenerateContentResponse.swift index 5cfa5ae..4b639c0 100644 --- a/Sources/GoogleAI/GenerateContentResponse.swift +++ b/Sources/GoogleAI/GenerateContentResponse.swift @@ -51,7 +51,7 @@ public struct GenerateContentResponse { } /// Initializer for SwiftUI previews or tests. - public init(candidates: [CandidateResponse], promptFeedback: PromptFeedback?) { + public init(candidates: [CandidateResponse], promptFeedback: PromptFeedback? = nil) { self.candidates = candidates self.promptFeedback = promptFeedback } diff --git a/Tests/GoogleAITests/GoogleAITests.swift b/Tests/GoogleAITests/GoogleAITests.swift index c0764bb..90b6fa6 100644 --- a/Tests/GoogleAITests/GoogleAITests.swift +++ b/Tests/GoogleAITests/GoogleAITests.swift @@ -149,6 +149,18 @@ final class GoogleGenerativeAITests: 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 + + // Computed Properties + let _: String? = response.text + let _: [FunctionCall] = response.functionCalls + } + // Result builder alternative /*