|
| 1 | +// Copyright 2025 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +import Foundation |
| 16 | + |
| 17 | +/// Represents the different types, or modalities, of data that a model can produce as output. |
| 18 | +/// |
| 19 | +/// To configure the desired output modalities for model requests, set the `responseModalities` |
| 20 | +/// parameter when initializing a ``GenerationConfig``. See the [multimodal |
| 21 | +/// responses](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal-response-generation) |
| 22 | +/// documentation for more details. |
| 23 | +/// |
| 24 | +/// > Important: Support for each response modality, or combination of modalities, depends on the |
| 25 | +/// > model. |
| 26 | +@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) |
| 27 | +public struct ResponseModality: EncodableProtoEnum, Sendable { |
| 28 | + enum Kind: String { |
| 29 | + case text = "TEXT" |
| 30 | + case image = "IMAGE" |
| 31 | + } |
| 32 | + |
| 33 | + /// Specifies that the model should generate textual content. |
| 34 | + /// |
| 35 | + /// Use this modality when you need the model to produce written language, such as answers to |
| 36 | + /// questions, summaries, creative writing, code snippets, or structured data formats like JSON. |
| 37 | + public static let text = ResponseModality(kind: .text) |
| 38 | + |
| 39 | + /// **Public Experimental**: Specifies that the model should generate image data. |
| 40 | + /// |
| 41 | + /// Use this modality when you want the model to create visual content based on the provided input |
| 42 | + /// or prompts. The response might contain one or more generated images. See the [image |
| 43 | + /// generation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal-response-generation#image-generation) |
| 44 | + /// documentation for more details. |
| 45 | + /// |
| 46 | + /// > Warning: Image generation using Gemini 2.0 Flash is a **Public Experimental** feature, which |
| 47 | + /// > means that it is not subject to any SLA or deprecation policy and could change in |
| 48 | + /// > backwards-incompatible ways. |
| 49 | + public static let image = ResponseModality(kind: .image) |
| 50 | + |
| 51 | + let rawValue: String |
| 52 | +} |
0 commit comments