diff --git a/Sources/GoogleAI/GenerateContentResponse.swift b/Sources/GoogleAI/GenerateContentResponse.swift index 44083c4..7b6d548 100644 --- a/Sources/GoogleAI/GenerateContentResponse.swift +++ b/Sources/GoogleAI/GenerateContentResponse.swift @@ -162,6 +162,9 @@ public enum FinishReason: String { /// NOTE: When streaming, the Candidate.content will be empty if content filters blocked the /// output. case safety = "SAFETY" + + /// The token generation was stopped because the response was flagged for image safety reasons. + case imageSafety = "IMAGE_SAFETY" /// The token generation was stopped because the response was flagged for unauthorized citations. case recitation = "RECITATION" diff --git a/Sources/GoogleAI/GenerationConfig.swift b/Sources/GoogleAI/GenerationConfig.swift index c4bd37c..7d02c4b 100644 --- a/Sources/GoogleAI/GenerationConfig.swift +++ b/Sources/GoogleAI/GenerationConfig.swift @@ -76,6 +76,13 @@ public struct GenerationConfig { /// this is limited to `application/json`. public let responseSchema: Schema? + /// Array of output response modalities + /// + /// Supported modalities: + /// - `text`: Text output + /// - `image`: Image output + public let responseModalities: [String]? + /// Creates a new `GenerationConfig` value. /// /// - Parameters: @@ -87,10 +94,11 @@ public struct GenerationConfig { /// - stopSequences: See ``stopSequences``. /// - responseMIMEType: See ``responseMIMEType``. /// - responseSchema: See ``responseSchema``. + /// - responseModalities: See ``responseModalities``. public init(temperature: Float? = nil, topP: Float? = nil, topK: Int? = nil, candidateCount: Int? = nil, maxOutputTokens: Int? = nil, stopSequences: [String]? = nil, responseMIMEType: String? = nil, - responseSchema: Schema? = nil) { + responseSchema: Schema? = nil, responseModalities: [String]? = nil) { // Explicit init because otherwise if we re-arrange the above variables it changes the API // surface. self.temperature = temperature @@ -101,6 +109,7 @@ public struct GenerationConfig { self.stopSequences = stopSequences self.responseMIMEType = responseMIMEType self.responseSchema = responseSchema + self.responseModalities = responseModalities } } diff --git a/Sources/GoogleAI/ModelContent.swift b/Sources/GoogleAI/ModelContent.swift index 59bf1be..48db585 100644 --- a/Sources/GoogleAI/ModelContent.swift +++ b/Sources/GoogleAI/ModelContent.swift @@ -140,7 +140,7 @@ extension ModelContent.Part: Codable { } enum InlineDataKeys: String, CodingKey { - case mimeType = "mime_type" + case mimeType case bytes = "data" }