diff --git a/FirebaseAI/AGENTS.md b/FirebaseAI/AGENTS.md index c60433e897a..c99ae42c64d 100644 --- a/FirebaseAI/AGENTS.md +++ b/FirebaseAI/AGENTS.md @@ -20,7 +20,7 @@ This directory contains the main source code for the FirebaseAI library. - **`GenerateContentError.swift`**: Defines the public `GenerateContentError` enum, representing errors that can occur when generating content. - **`GenerateContentRequest.swift`**: Defines the `GenerateContentRequest` struct, representing a request to generate content from the model. - **`GenerateContentResponse.swift`**: Represents the model's response to a generate content request, including usage metadata, candidates, and prompt feedback. -- **`GenerationConfig.swift`**: Defines the `GenerationConfig` struct for configuring model parameters (e.g., temperature, topP). +- **`GenerationConfig.swift`**: Defines the `GenerationConfig` struct for configuring model parameters (e.g., maxOutputTokens). - **`GenerativeAIRequest.swift`**: Defines the `GenerativeAIRequest` protocol for requests sent to the generative AI backend. - **`GenerativeAIService.swift`**: Responsible for making requests to the generative AI backend, handling authentication, URL construction, and response parsing. - **`GenerativeModel.swift`**: Defines the `GenerativeModel` class, representing a remote multimodal model. It provides methods for generating content and starting chats. diff --git a/FirebaseAI/CHANGELOG.md b/FirebaseAI/CHANGELOG.md index 1da1c0451b5..ccc1dd6ceea 100644 --- a/FirebaseAI/CHANGELOG.md +++ b/FirebaseAI/CHANGELOG.md @@ -1,3 +1,8 @@ +# Unreleased +- [changed] Deprecated model tuning parameters (`temperature`, `topP`, `topK`, `candidateCount`, + `presencePenalty`, and `frequencyPenalty`) in `GenerationConfig` and `LiveGenerationConfig` as + they are unsupported in Gemini 3.x and later models. + # 12.19.0 - [feature] **Public Preview**: Added `GeminiLanguageModel`, allowing Gemini models to be used with Apple's Foundation Models framework. See the diff --git a/FirebaseAI/Sources/GenerationConfig.swift b/FirebaseAI/Sources/GenerationConfig.swift index 299cd8fd4d8..e7aca54004a 100644 --- a/FirebaseAI/Sources/GenerationConfig.swift +++ b/FirebaseAI/Sources/GenerationConfig.swift @@ -73,67 +73,9 @@ public struct GenerationConfig: Sendable, Equatable { /// for more details. /// /// - Parameters: - /// - temperature:Controls the randomness of the language model's output. Higher values (for - /// example, 1.0) make the text more random and creative, while lower values (for example, - /// 0.1) make it more focused and deterministic. - /// - /// > Note: A temperature of 0 means that the highest probability tokens are always selected. - /// > In this case, responses for a given prompt are mostly deterministic, but a small amount - /// > of variation is still possible. - /// - /// > Important: The range of supported temperature values depends on the model; see the - /// > [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#temperature) - /// > for more details. - /// - topP: Controls diversity of generated text. Higher values (e.g., 0.9) produce more diverse - /// text, while lower values (e.g., 0.5) make the output more focused. - /// - /// The supported range is 0.0 to 1.0. - /// - /// > Important: The default `topP` value depends on the model; see the - /// > [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#top-p) - /// > for more details. - /// - topK: Limits the number of highest probability words the model considers when generating - /// text. For example, a topK of 40 means only the 40 most likely words are considered for the - /// next token. A higher value increases diversity, while a lower value makes the output more - /// deterministic. - /// - /// The supported range is 1 to 40. - /// - /// > Important: Support for `topK` and the default value depends on the model; see the - /// [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#top-k) - /// for more details. - /// - candidateCount: The number of response variations to return; defaults to 1 if not set. - /// Support for multiple candidates depends on the model; see the - /// [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) - /// for more details. /// - maxOutputTokens: Maximum number of tokens that can be generated in the response. /// See the configure model parameters [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#max-output-tokens) /// for more details. - /// - presencePenalty: Controls the likelihood of repeating the same words or phrases already - /// generated in the text. Higher values increase the penalty of repetition, resulting in more - /// diverse output. - /// - /// > Note: While both `presencePenalty` and `frequencyPenalty` discourage repetition, - /// > `presencePenalty` applies the same penalty regardless of how many times the word/phrase - /// > has already appeared, whereas `frequencyPenalty` increases the penalty for *each* - /// > repetition of a word/phrase. - /// - /// > Important: The range of supported `presencePenalty` values depends on the model; see the - /// > [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) - /// > for more details - /// - frequencyPenalty: Controls the likelihood of repeating words or phrases, with the penalty - /// increasing for each repetition. Higher values increase the penalty of repetition, - /// resulting in more diverse output. - /// - /// > Note: While both `frequencyPenalty` and `presencePenalty` discourage repetition, - /// > `frequencyPenalty` increases the penalty for *each* repetition of a word/phrase, whereas - /// > `presencePenalty` applies the same penalty regardless of how many times the word/phrase - /// > has already appeared. - /// - /// > Important: The range of supported `frequencyPenalty` values depends on the model; see - /// > the - /// > [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) - /// > for more details /// - stopSequences: A set of up to 5 `String`s that will stop output generation. If specified, /// the API will stop at the first appearance of a stop sequence. The stop sequence will not /// be included as part of the response. See the @@ -174,6 +116,11 @@ public struct GenerationConfig: Sendable, Equatable { /// > that it is not subject to any SLA or deprecation policy and could change in /// > backwards-incompatible ways. /// - imageConfig: Configuration options for generating images. + @available( + *, + deprecated, + message: "candidateCount, temperature, topP, topK, presencePenalty, and frequencyPenalty are unsupported in Gemini 3.x and later models." + ) public init(temperature: Float? = nil, topP: Float? = nil, topK: Int? = nil, candidateCount: Int? = nil, maxOutputTokens: Int? = nil, presencePenalty: Float? = nil, frequencyPenalty: Float? = nil, @@ -200,6 +147,80 @@ public struct GenerationConfig: Sendable, Equatable { self.speechConfig = speechConfig?.speechConfig } + /// Creates a new `GenerationConfig` value without deprecated tuning parameters. + /// + /// See the + /// [Configure model parameters](https://firebase.google.com/docs/vertex-ai/model-parameters) + /// guide and the + /// [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) + /// for more details. + /// + /// - Parameters: + /// - maxOutputTokens: Maximum number of tokens that can be generated in the response. + /// See the configure model parameters [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#max-output-tokens) + /// for more details. + /// - stopSequences: A set of up to 5 `String`s that will stop output generation. If specified, + /// the API will stop at the first appearance of a stop sequence. The stop sequence will not + /// be included as part of the response. See the + /// [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) + /// for more details. + /// - responseMIMEType: Output response MIME type of the generated candidate text. + /// + /// Supported MIME types: + /// - `text/plain`: Text output; the default behavior if unspecified. + /// - `application/json`: JSON response in the candidates. + /// - `text/x.enum`: For classification tasks, output an enum value as defined in the + /// `responseSchema`. + /// - responseSchema: Output schema of the generated candidate text. If set, a compatible + /// `responseMIMEType` must also be set. + /// + /// Compatible MIME types: + /// - `application/json`: Schema for JSON response. + /// + /// Refer to the + /// [Generate structured + /// output](https://firebase.google.com/docs/vertex-ai/structured-output?platform=ios) guide + /// for more details. + /// - responseModalities: The data types (modalities) that may be returned in model responses. + /// + /// See the [multimodal + /// responses](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal-response-generation) + /// documentation for more details. + /// + /// > Warning: Specifying response modalities is a **Public Preview** feature, which means + /// > that it is not subject to any SLA or deprecation policy and could change in + /// > backwards-incompatible ways. + /// - thinkingConfig: Configuration for controlling the "thinking" behavior of compatible Gemini + /// models; see ``ThinkingConfig`` for more details. + /// - speechConfig: Configuration for controlling the voice of the model during conversation; + /// see ``SpeechConfig`` for more details. + /// + /// > Warning: Specifying a speech configuration is a **Public Preview** feature, which means + /// > that it is not subject to any SLA or deprecation policy and could change in + /// > backwards-incompatible ways. + /// - imageConfig: Configuration options for generating images. + public init(maxOutputTokens: Int? = nil, + stopSequences: [String]? = nil, responseMIMEType: String? = nil, + responseSchema: Schema? = nil, responseModalities: [ResponseModality]? = nil, + thinkingConfig: ThinkingConfig? = nil, imageConfig: ImageConfig? = nil, + speechConfig: SpeechConfig? = nil) { + temperature = nil + topP = nil + topK = nil + candidateCount = nil + self.maxOutputTokens = maxOutputTokens + presencePenalty = nil + frequencyPenalty = nil + self.stopSequences = stopSequences + self.responseMIMEType = responseMIMEType + self.responseSchema = responseSchema + responseJSONSchema = nil + self.responseModalities = responseModalities + self.thinkingConfig = thinkingConfig + self.imageConfig = imageConfig + self.speechConfig = speechConfig?.speechConfig + } + init(temperature: Float? = nil, topP: Float? = nil, topK: Int? = nil, candidateCount: Int? = nil, maxOutputTokens: Int? = nil, presencePenalty: Float? = nil, frequencyPenalty: Float? = nil, stopSequences: [String]? = nil, responseMIMEType: String, responseJSONSchema: JSONObject, diff --git a/FirebaseAI/Sources/Types/Public/Live/LiveGenerationConfig.swift b/FirebaseAI/Sources/Types/Public/Live/LiveGenerationConfig.swift index 83d73e0e50c..7d701537e44 100644 --- a/FirebaseAI/Sources/Types/Public/Live/LiveGenerationConfig.swift +++ b/FirebaseAI/Sources/Types/Public/Live/LiveGenerationConfig.swift @@ -32,67 +32,9 @@ public struct LiveGenerationConfig: Sendable { /// for more details. /// /// - Parameters: - /// - temperature:Controls the randomness of the language model's output. Higher values (for - /// example, 1.0) make the text more random and creative, while lower values (for example, - /// 0.1) make it more focused and deterministic. - /// - /// > Note: A temperature of 0 means that the highest probability tokens are always selected. - /// > In this case, responses for a given prompt are mostly deterministic, but a small amount - /// > of variation is still possible. - /// - /// > Important: The range of supported temperature values depends on the model; see the - /// > [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#temperature) - /// > for more details. - /// - topP: Controls diversity of generated text. Higher values (e.g., 0.9) produce more diverse - /// text, while lower values (e.g., 0.5) make the output more focused. - /// - /// The supported range is 0.0 to 1.0. - /// - /// > Important: The default `topP` value depends on the model; see the - /// > [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#top-p) - /// > for more details. - /// - topK: Limits the number of highest probability words the model considers when generating - /// text. For example, a topK of 40 means only the 40 most likely words are considered for the - /// next token. A higher value increases diversity, while a lower value makes the output more - /// deterministic. - /// - /// The supported range is 1 to 40. - /// - /// > Important: Support for `topK` and the default value depends on the model; see the - /// [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#top-k) - /// for more details. - /// - candidateCount: The number of response variations to return; defaults to 1 if not set. - /// Support for multiple candidates depends on the model; see the - /// [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) - /// for more details. /// - maxOutputTokens: Maximum number of tokens that can be generated in the response. /// See the configure model parameters [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#max-output-tokens) /// for more details. - /// - presencePenalty: Controls the likelihood of repeating the same words or phrases already - /// generated in the text. Higher values increase the penalty of repetition, resulting in more - /// diverse output. - /// - /// > Note: While both `presencePenalty` and `frequencyPenalty` discourage repetition, - /// > `presencePenalty` applies the same penalty regardless of how many times the word/phrase - /// > has already appeared, whereas `frequencyPenalty` increases the penalty for *each* - /// > repetition of a word/phrase. - /// - /// > Important: The range of supported `presencePenalty` values depends on the model; see the - /// > [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) - /// > for more details - /// - frequencyPenalty: Controls the likelihood of repeating words or phrases, with the penalty - /// increasing for each repetition. Higher values increase the penalty of repetition, - /// resulting in more diverse output. - /// - /// > Note: While both `frequencyPenalty` and `presencePenalty` discourage repetition, - /// > `frequencyPenalty` increases the penalty for *each* repetition of a word/phrase, whereas - /// > `presencePenalty` applies the same penalty regardless of how many times the word/phrase - /// > has already appeared. - /// - /// > Important: The range of supported `frequencyPenalty` values depends on the model; see - /// > the - /// > [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) - /// > for more details /// - responseModalities: The data types (modalities) that may be returned in model responses. /// /// See the [multimodal @@ -126,6 +68,11 @@ public struct LiveGenerationConfig: Sendable { /// This mechanism prevents the context from exceeding a given length. /// - realtimeInputConfig: Configures model input behavior when generating content via the /// realtime supported methods + @available( + *, + deprecated, + message: "candidateCount, temperature, topP, topK, presencePenalty, and frequencyPenalty are unsupported in Gemini 3.x and later models." + ) public init(temperature: Float? = nil, topP: Float? = nil, topK: Int? = nil, candidateCount: Int? = nil, maxOutputTokens: Int? = nil, presencePenalty: Float? = nil, frequencyPenalty: Float? = nil, @@ -154,6 +101,77 @@ public struct LiveGenerationConfig: Sendable { ) } + /// Creates a new `LiveGenerationConfig` value. + /// + /// See the + /// [Configure model parameters](https://firebase.google.com/docs/vertex-ai/model-parameters) + /// guide and the + /// [Cloud documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#generationconfig) + /// for more details. + /// + /// - Parameters: + /// - maxOutputTokens: Maximum number of tokens that can be generated in the response. + /// See the configure model parameters [documentation](https://firebase.google.com/docs/vertex-ai/model-parameters?platform=ios#max-output-tokens) + /// for more details. + /// - responseModalities: The data types (modalities) that may be returned in model responses. + /// + /// See the [multimodal + /// responses](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal-response-generation) + /// documentation for more details. + /// + /// > Warning: Specifying response modalities is a **Public Preview** feature, which means + /// > that it is not subject to any SLA or deprecation policy and could change in + /// > backwards-incompatible ways. + /// - speech: Controls the voice of the model, when streaming `audio` via + /// ``ResponseModality``. + /// - inputAudioTranscription: Configures (and enables) input transcriptions when streaming to + /// the model. + /// + /// Input transcripts are the model's interpretation of audio data sent to it, and they are + /// populated in model responses via ``LiveServerContent/inputAudioTranscription``. When this + /// field is set to `nil`, input transcripts are not populated in model responses. + /// - outputAudioTranscription: Configures (and enables) output transcriptions when streaming to + /// the model. + /// + /// Output transcripts are text representations of the audio the model is sending to the + /// client, and they are populated in model responses via + /// ``LiveServerContent/outputAudioTranscription``. When this + /// field is set to `nil`, output transcripts are not populated in model responses. + /// + /// > Important: Transcripts are independent to the model turn. This means transcripts may + /// > come earlier or later than when the model sends the corresponding audio responses. + /// - contextWindowCompression: Enables context window compression to manage the model's + /// context window. + /// + /// This mechanism prevents the context from exceeding a given length. + /// - realtimeInputConfig: Configures model input behavior when generating content via the + /// realtime supported methods + public init(maxOutputTokens: Int? = nil, + responseModalities: [ResponseModality]? = nil, + speech: SpeechConfig? = nil, + inputAudioTranscription: AudioTranscriptionConfig? = nil, + outputAudioTranscription: AudioTranscriptionConfig? = nil, + contextWindowCompression: ContextWindowCompressionConfig? = nil, + realtimeInputConfig: RealtimeInputConfig? = nil) { + self.init( + BidiGenerationConfig( + temperature: nil, + topP: nil, + topK: nil, + candidateCount: nil, + maxOutputTokens: maxOutputTokens, + presencePenalty: nil, + frequencyPenalty: nil, + responseModalities: responseModalities, + speechConfig: speech?.speechConfig + ), + inputAudioTranscription: inputAudioTranscription?.audioTranscriptionConfig, + outputAudioTranscription: outputAudioTranscription?.audioTranscriptionConfig, + contextWindowCompression: contextWindowCompression?.bidiContextWindowCompressionConfig, + realtimeInputConfig: realtimeInputConfig?.bidiRealtimeInputConfig + ) + } + init(_ bidiGenerationConfig: BidiGenerationConfig, inputAudioTranscription: BidiAudioTranscriptionConfig? = nil, outputAudioTranscription: BidiAudioTranscriptionConfig? = nil, diff --git a/FirebaseAI/Tests/Unit/GenerationConfigTests.swift b/FirebaseAI/Tests/Unit/GenerationConfigTests.swift index 7dd63534b5d..4f81b92e4d3 100644 --- a/FirebaseAI/Tests/Unit/GenerationConfigTests.swift +++ b/FirebaseAI/Tests/Unit/GenerationConfigTests.swift @@ -41,23 +41,11 @@ final class GenerationConfigTests: XCTestCase { } func testEncodeGenerationConfig_allOptions() throws { - let temperature: Float = 0.5 - let topP: Float = 0.75 - let topK = 40 - let candidateCount = 2 let maxOutputTokens = 256 - let presencePenalty: Float = 0.5 - let frequencyPenalty: Float = 0.75 let stopSequences = ["END", "DONE"] let responseMIMEType = "application/json" let generationConfig = GenerationConfig( - temperature: temperature, - topP: topP, - topK: topK, - candidateCount: candidateCount, maxOutputTokens: maxOutputTokens, - presencePenalty: presencePenalty, - frequencyPenalty: frequencyPenalty, stopSequences: stopSequences, responseMIMEType: responseMIMEType, responseSchema: .array(items: .string()), @@ -69,10 +57,7 @@ final class GenerationConfigTests: XCTestCase { let json = try XCTUnwrap(String(data: jsonData, encoding: .utf8)) XCTAssertEqual(json, """ { - "candidateCount" : \(candidateCount), - "frequencyPenalty" : \(frequencyPenalty), "maxOutputTokens" : \(maxOutputTokens), - "presencePenalty" : \(presencePenalty), "responseMimeType" : "\(responseMIMEType)", "responseModalities" : [ "TEXT", @@ -89,10 +74,7 @@ final class GenerationConfigTests: XCTestCase { "stopSequences" : [ "END", "DONE" - ], - "temperature" : \(temperature), - "topK" : \(topK), - "topP" : \(topP) + ] } """) } @@ -349,12 +331,7 @@ final class GenerationConfigTests: XCTestCase { func testMerge_baseNil() throws { let thinkingConfig = ThinkingConfig(thinkingLevel: .high, includeThoughts: true) let overrides = GenerationConfig( - temperature: 0.5, - topK: 10, - candidateCount: 2, maxOutputTokens: 2048, - presencePenalty: 0.3, - frequencyPenalty: 0.2, stopSequences: ["stop"], responseMIMEType: "application/json", responseModalities: [.text], @@ -363,13 +340,7 @@ final class GenerationConfigTests: XCTestCase { let result = try XCTUnwrap(GenerationConfig.merge(nil, with: overrides)) - XCTAssertEqual(result.temperature, 0.5) - XCTAssertNil(result.topP) - XCTAssertEqual(result.topK, 10) - XCTAssertEqual(result.candidateCount, 2) XCTAssertEqual(result.maxOutputTokens, 2048) - XCTAssertEqual(result.presencePenalty, 0.3) - XCTAssertEqual(result.frequencyPenalty, 0.2) XCTAssertEqual(result.stopSequences, ["stop"]) XCTAssertEqual(result.responseMIMEType, "application/json") XCTAssertEqual(result.responseModalities, [.text]) @@ -379,13 +350,7 @@ final class GenerationConfigTests: XCTestCase { func testMerge_overridesNil() throws { let thinkingConfig = ThinkingConfig(thinkingLevel: .minimal, includeThoughts: false) let overrides = GenerationConfig( - temperature: 0.9, - topP: 0.95, - topK: 5, - candidateCount: 4, maxOutputTokens: 1024, - presencePenalty: 0.5, - frequencyPenalty: 0.1, stopSequences: ["test"], responseModalities: [.image], thinkingConfig: thinkingConfig @@ -393,13 +358,7 @@ final class GenerationConfigTests: XCTestCase { let result = try XCTUnwrap(GenerationConfig.merge(nil, with: overrides)) - XCTAssertEqual(result.temperature, 0.9) - XCTAssertEqual(result.topP, 0.95) - XCTAssertEqual(result.topK, 5) - XCTAssertEqual(result.candidateCount, 4) XCTAssertEqual(result.maxOutputTokens, 1024) - XCTAssertEqual(result.presencePenalty, 0.5) - XCTAssertEqual(result.frequencyPenalty, 0.1) XCTAssertEqual(result.stopSequences, ["test"]) XCTAssertNil(result.responseMIMEType) XCTAssertEqual(result.responseModalities, [.image]) @@ -408,24 +367,14 @@ final class GenerationConfigTests: XCTestCase { func testMerge_mergesProperties() throws { let base = GenerationConfig( - temperature: 0.5, - topK: 10, - candidateCount: 1, responseMIMEType: "text/plain" ) let overrides = GenerationConfig( - temperature: 0.8, - topP: 0.9, responseMIMEType: "application/json", thinkingConfig: ThinkingConfig(thinkingBudget: 1024) ) let result = try XCTUnwrap(GenerationConfig.merge(base, with: overrides)) - - XCTAssertEqual(result.temperature, 0.8) - XCTAssertEqual(result.topK, 10) - XCTAssertEqual(result.candidateCount, 1) - XCTAssertEqual(result.topP, 0.9) XCTAssertEqual(result.responseMIMEType, "application/json") XCTAssertEqual(result.thinkingConfig?.thinkingBudget, 1024) } @@ -475,7 +424,7 @@ final class GenerationConfigTests: XCTestCase { func testMerge_speechConfig_fallbackToBase() throws { let base = GenerationConfig(speechConfig: SpeechConfig(voiceName: "Kore")) - let overrides = GenerationConfig(temperature: 0.5) + let overrides = GenerationConfig(maxOutputTokens: 55) let result = try XCTUnwrap(GenerationConfig.merge(base, with: overrides)) XCTAssertEqual(result.speechConfig, SpeechConfig(voiceName: "Kore").speechConfig) diff --git a/FirebaseAI/Tests/Unit/GenerativeModelSessionTests.swift b/FirebaseAI/Tests/Unit/GenerativeModelSessionTests.swift index 9ddee50812a..966db7d0e78 100644 --- a/FirebaseAI/Tests/Unit/GenerativeModelSessionTests.swift +++ b/FirebaseAI/Tests/Unit/GenerativeModelSessionTests.swift @@ -321,7 +321,7 @@ } func testRespondTo_withOptions() async throws { - let config = GenerationConfig(temperature: 0.5, responseMIMEType: "application/json") + let config = GenerationConfig(responseMIMEType: "application/json") let bundle = BundleTestUtil.bundle() let fileURL = try XCTUnwrap(bundle.url( forResource: "unary-success-thinking-reply-thought-summary", @@ -343,11 +343,6 @@ XCTFail("Expected an object for JSON key 'generationConfig', got: \(json)") return (response, nil) } - guard case let .number(temperature) = generationConfig["temperature"] else { - XCTFail("Expected a number for JSON key 'temperature', got: \(json)") - return (response, nil) - } - XCTAssertEqual(Float(temperature), config.temperature) guard case let .string(responseMIMEType) = generationConfig["responseMimeType"] else { XCTFail("Expected a string for JSON key 'responseMimeType', got: \(json)") return (response, nil) diff --git a/FirebaseAI/Tests/Unit/GenerativeModelVertexAITests.swift b/FirebaseAI/Tests/Unit/GenerativeModelVertexAITests.swift index 35ebf020399..9761f83215e 100644 --- a/FirebaseAI/Tests/Unit/GenerativeModelVertexAITests.swift +++ b/FirebaseAI/Tests/Unit/GenerativeModelVertexAITests.swift @@ -1846,10 +1846,6 @@ final class GenerativeModelVertexAITests: XCTestCase { subdirectory: vertexSubdirectory ) let generationConfig = GenerationConfig( - temperature: 0.5, - topP: 0.9, - topK: 3, - candidateCount: 1, maxOutputTokens: 1024, stopSequences: ["test-stop"], responseMIMEType: "text/plain" diff --git a/FirebaseAI/Tests/Unit/ResponseGenerationOptionsTests.swift b/FirebaseAI/Tests/Unit/ResponseGenerationOptionsTests.swift index 204846bed4f..1dd901dc04e 100644 --- a/FirebaseAI/Tests/Unit/ResponseGenerationOptionsTests.swift +++ b/FirebaseAI/Tests/Unit/ResponseGenerationOptionsTests.swift @@ -19,7 +19,7 @@ final class ResponseGenerationOptionsTests: XCTestCase { func testGenerationConfigConversion() { - let config = GenerationConfig(temperature: 0.5, topK: 40) + let config = GenerationConfig() let options = config.responseGenerationOptions @@ -40,7 +40,7 @@ } func testFactoryMethods() { - let config = GenerationConfig(temperature: 0.7, topP: 0.8) + let config = GenerationConfig() let foundationModelsGenerationOptions = FirebaseAI.GenerationOptions( sampling: .greedy, temperature: 0.4, maximumResponseTokens: 200 ) diff --git a/FirebaseAI/Tests/Unit/Snippets/LiveSnippets.swift b/FirebaseAI/Tests/Unit/Snippets/LiveSnippets.swift index 32b4014a3cf..b4c5f1f175a 100644 --- a/FirebaseAI/Tests/Unit/Snippets/LiveSnippets.swift +++ b/FirebaseAI/Tests/Unit/Snippets/LiveSnippets.swift @@ -215,9 +215,6 @@ final class LiveSnippets: XCTestCase { // Set parameter values in a `LiveGenerationConfig` (example values shown here) let config = LiveGenerationConfig( - temperature: 0.9, - topP: 0.1, - topK: 16, maxOutputTokens: 200, responseModalities: [.audio], speech: SpeechConfig(voiceName: "Fenrir")