From e145b38a7aaf1a2d5bf450ffb674e9ea8c5e5b84 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 02:34:21 +0000 Subject: [PATCH 1/2] feat: Add responseModalities to GenerationConfig Adds an optional `responseModalities` property to the `GenerationConfig` class. This allows specifying the desired modality types (e.g., TEXT, IMAGE, AUDIO) for the response. The changes include: - Adding `responseModalities: List?` to the `GenerationConfig` primary constructor. - Updating the `GenerationConfig.Builder` to include the new property. - Updating the internal `GenerationConfig.Internal` data class and the `toInternal` mapping for serialization. --- .../google/firebase/vertexai/type/GenerationConfig.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/GenerationConfig.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/GenerationConfig.kt index 4abec8a260d..b141c9631d1 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/GenerationConfig.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/GenerationConfig.kt @@ -88,6 +88,7 @@ private constructor( internal val stopSequences: List?, internal val responseMimeType: String?, internal val responseSchema: Schema?, + internal val responseModalities: List?, ) { /** @@ -128,6 +129,7 @@ private constructor( @JvmField public var stopSequences: List? = null @JvmField public var responseMimeType: String? = null @JvmField public var responseSchema: Schema? = null + @JvmField public var responseModalities: List? = null /** Create a new [GenerationConfig] with the attached arguments. */ public fun build(): GenerationConfig = @@ -155,8 +157,13 @@ private constructor( stopSequences = stopSequences, frequencyPenalty = frequencyPenalty, presencePenalty = presencePenalty, + responseMimeType = responseMimeType, + responseSchema = responseSchema, + responseModalities = responseModalities, + ) responseMimeType = responseMimeType, - responseSchema = responseSchema?.toInternal() + responseSchema = responseSchema?.toInternal(), + responseModalities = responseModalities?.map { it.toInternal() } ) @Serializable @@ -171,6 +178,7 @@ private constructor( @SerialName("presence_penalty") val presencePenalty: Float? = null, @SerialName("frequency_penalty") val frequencyPenalty: Float? = null, @SerialName("response_schema") val responseSchema: Schema.Internal? = null, + @SerialName("response_modalities") val responseModalities: List? = null, ) public companion object { From 4d4863792a11e78cb00abc0103a835710c87d158 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 02:41:50 +0000 Subject: [PATCH 2/2] fix: Correct extraneous parenthesis in GenerationConfig.toInternal Removes an extra parenthesis and corrects the mapping logic within the `toInternal()` function in `GenerationConfig.kt` that was introduced when adding the `responseModalities` property. --- .../com/google/firebase/vertexai/type/GenerationConfig.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/GenerationConfig.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/GenerationConfig.kt index b141c9631d1..c89079baecd 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/GenerationConfig.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/GenerationConfig.kt @@ -157,13 +157,9 @@ private constructor( stopSequences = stopSequences, frequencyPenalty = frequencyPenalty, presencePenalty = presencePenalty, - responseMimeType = responseMimeType, - responseSchema = responseSchema, - responseModalities = responseModalities, - ) responseMimeType = responseMimeType, responseSchema = responseSchema?.toInternal(), - responseModalities = responseModalities?.map { it.toInternal() } + responseModalities = responseModalities?.map { it.toInternal() }, ) @Serializable