mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-09 22:36:01 +05:45
Regenerate GenerateContent/ with the GeminiLanguageModel/scripts/typegen generator from Discovery Document revision 20260929, fixing the drift reported by the check-data-models CI job. Generated model changes: - Structs use optional `var` properties, an empty `init()` and `Buildable` instead of memberwise initializers. - Acronyms are capitalized in Swift names (e.g. `responseMIMEType`, `URLContext`). JSON schema properties are typed as `JSONObject`, and `Schema`, `DataType` and `VideoMetadata` are no longer generated. - Enums combine both backends' cases and decode unknown values to `.unrecognized`. - Every generated file has a "DO NOT EDIT" header. GeminiLanguageModel changes: - Build requests with `Buildable` closures and adopt the renamed properties. The encoded JSON is unchanged. - Add `GeminiLanguageModel.Error.invalidResponse(InvalidResponse)`. Responses that fail to decode or contain a function call with no name now throw `invalidResponse` instead of `networkFailure`, and `InvalidResponse.underlyingError` exposes the original error. - Map the `MODEL_ARMOR` and `JAILBREAK` block reasons and the `MODEL_ARMOR` finish reason to `guardrailViolation`. - Exclude the GeminiLanguageModel test READMEs from the root SwiftPM manifest so builds with `-warnings-as-errors` succeed.
168 lines
8.2 KiB
Swift
168 lines
8.2 KiB
Swift
// Copyright 2026 Google LLC
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// DO NOT EDIT. This file is generated by GeminiLanguageModel/scripts/typegen;
|
|
// see its README.md for how to regenerate it.
|
|
|
|
import Foundation
|
|
|
|
/// Configuration for content generation. This message contains all the parameters that control how
|
|
/// the model generates content. It allows you to influence the randomness, length, and structure of
|
|
/// the output.
|
|
package struct GenerationConfig: Codable, Sendable, Equatable, Hashable, Buildable {
|
|
/// If enabled, audio timestamps will be included in the request to the model. This can be useful
|
|
/// for synchronizing audio with other modalities in the response.
|
|
///
|
|
/// > Important: This property is not supported in the Gemini Developer API.
|
|
package var audioTimestamp: Bool?
|
|
|
|
/// Configuration for audio transcription (speech recognition).
|
|
package var audioTranscriptionConfig: AudioTranscriptionConfig?
|
|
|
|
/// The number of candidate responses to generate. A higher `candidate_count` can provide more
|
|
/// options to choose from, but it also consumes more resources. This can be useful for generating
|
|
/// a variety of responses and selecting the best one.
|
|
package var candidateCount: Int?
|
|
|
|
/// If enabled, the model will detect emotions and adapt its responses accordingly. For example,
|
|
/// if the model detects that the user is frustrated, it may provide a more empathetic response.
|
|
package var enableAffectiveDialog: Bool?
|
|
|
|
/// Enables enhanced civic answers. It may not be available for all models.
|
|
///
|
|
/// > Important: This property is not supported in the Gemini Enterprise Agent Platform.
|
|
package var enableEnhancedCivicAnswers: Bool?
|
|
|
|
/// Penalizes tokens based on their frequency in the generated text. A positive value helps to
|
|
/// reduce the repetition of words and phrases. Valid values can range from [-2.0, 2.0].
|
|
package var frequencyPenalty: Double?
|
|
|
|
/// Config for image generation features. Deprecated: Use `response_format.image` instead.
|
|
package var imageConfig: ImageConfig?
|
|
|
|
/// The number of top log probabilities to return for each token. This can be used to see which
|
|
/// other tokens were considered likely candidates for a given position. A higher value will
|
|
/// return more options, but it will also increase the size of the response.
|
|
package var logprobs: Int?
|
|
|
|
/// The maximum number of tokens to generate in the response. A token is approximately four
|
|
/// characters. The default value varies by model. This parameter can be used to control the
|
|
/// length of the generated text and prevent overly long responses.
|
|
package var maxOutputTokens: Int?
|
|
|
|
/// The token resolution at which input media content is sampled. This is used to control the
|
|
/// trade-off between the quality of the response and the number of tokens used to represent the
|
|
/// media. A higher resolution allows the model to perceive more detail, which can lead to a more
|
|
/// nuanced response, but it will also use more tokens. This does not affect the image dimensions
|
|
/// sent to the model.
|
|
package var mediaResolution: MediaResolution?
|
|
|
|
/// Penalizes tokens that have already appeared in the generated text. A positive value encourages
|
|
/// the model to generate more diverse and less repetitive text. Valid values can range from
|
|
/// [-2.0, 2.0].
|
|
package var presencePenalty: Double?
|
|
|
|
/// New response format field for the model to configure output formatting and delivery.
|
|
package var responseFormat: ResponseFormatConfig?
|
|
|
|
/// When this field is set, response_schema must be omitted and response_mime_type must be set to
|
|
/// `application/json`. Deprecated: Use `response_format` instead.
|
|
package var responseJSONSchema: JSONObject?
|
|
|
|
/// If set to true, the log probabilities of the output tokens are returned. Log probabilities are
|
|
/// the logarithm of the probability of a token appearing in the output. A higher log probability
|
|
/// means the token is more likely to be generated. This can be useful for analyzing the model's
|
|
/// confidence in its own output and for debugging.
|
|
package var responseLogprobs: Bool?
|
|
|
|
/// The IANA standard MIME type of the response. The model will generate output that conforms to
|
|
/// this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The
|
|
/// model needs to be prompted to output the appropriate response type, otherwise the behavior is
|
|
/// undefined. Deprecated: Use `response_format` instead.
|
|
package var responseMIMEType: String?
|
|
|
|
/// The modalities of the response. The model will generate a response that includes all the
|
|
/// specified modalities. For example, if this is set to `[TEXT, IMAGE]`, the response will
|
|
/// include both text and an image.
|
|
package var responseModalities: [Modality]?
|
|
|
|
/// A seed for the random number generator. By setting a seed, you can make the model's output
|
|
/// mostly deterministic. For a given prompt and parameters (like temperature, top_p, etc.), the
|
|
/// model will produce the same response every time. However, it's not a guaranteed absolute
|
|
/// deterministic behavior. This is different from parameters like `temperature`, which control
|
|
/// the *level* of randomness. `seed` ensures that the "random" choices the model makes are the
|
|
/// same on every run, making it essential for testing and ensuring reproducible results.
|
|
package var seed: Int?
|
|
|
|
/// The speech generation config.
|
|
package var speechConfig: SpeechConfig?
|
|
|
|
/// A list of character sequences that will stop the model from generating further tokens. If a
|
|
/// stop sequence is generated, the output will end at that point. This is useful for controlling
|
|
/// the length and structure of the output. For example, you can use ["\n", "###"] to stop
|
|
/// generation at a new line or a specific marker.
|
|
package var stopSequences: [String]?
|
|
|
|
/// Controls the randomness of the output. A higher temperature results in more creative and
|
|
/// diverse responses, while a lower temperature makes the output more predictable and focused.
|
|
/// The valid range is (0.0, 2.0].
|
|
package var temperature: Double?
|
|
|
|
/// Configuration for thinking features. An error will be returned if this field is set for models
|
|
/// that don't support thinking.
|
|
package var thinkingConfig: ThinkingConfig?
|
|
|
|
/// Specifies the top-k sampling threshold. The model considers only the top k most probable
|
|
/// tokens for the next token. This can be useful for generating more coherent and less random
|
|
/// text. For example, a `top_k` of 40 means the model will choose the next word from the 40 most
|
|
/// likely words.
|
|
package var topK: Int?
|
|
|
|
/// Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens
|
|
/// whose cumulative probability is at least `top_p`. This helps generate more diverse and less
|
|
/// repetitive responses. For example, a `top_p` of 0.9 means the model considers tokens until the
|
|
/// cumulative probability of the tokens to select from reaches 0.9. It's recommended to adjust
|
|
/// either temperature or `top_p`, but not both.
|
|
package var topP: Double?
|
|
|
|
/// Initializes a new `GenerationConfig`.
|
|
package init() {}
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case audioTimestamp
|
|
case audioTranscriptionConfig
|
|
case candidateCount
|
|
case enableAffectiveDialog
|
|
case enableEnhancedCivicAnswers
|
|
case frequencyPenalty
|
|
case imageConfig
|
|
case logprobs
|
|
case maxOutputTokens
|
|
case mediaResolution
|
|
case presencePenalty
|
|
case responseFormat
|
|
case responseJSONSchema = "responseJsonSchema"
|
|
case responseLogprobs
|
|
case responseMIMEType = "responseMimeType"
|
|
case responseModalities
|
|
case seed
|
|
case speechConfig
|
|
case stopSequences
|
|
case temperature
|
|
case thinkingConfig
|
|
case topK
|
|
case topP
|
|
}
|
|
}
|