From 340b8190e22ff23a8144b5612cfe58711cb0d7a7 Mon Sep 17 00:00:00 2001 From: VinayGuthal Date: Thu, 3 Apr 2025 12:40:18 -0400 Subject: [PATCH 1/8] update --- .../firebase/vertexai/java/LiveModelFutures.kt | 6 +++--- .../firebase/vertexai/java/LiveSessionFutures.kt | 12 ++++++++++++ .../firebase/vertexai/type/LiveGenerationConfig.kt | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt index c167e700a5e..aa7ba07e377 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt @@ -37,11 +37,11 @@ public abstract class LiveModelFutures internal constructor() { * @throws [ServiceConnectionHandshakeFailedException] If the client was not able to establish a * connection with the server. */ - public abstract fun connect(): ListenableFuture + public abstract fun connect(): ListenableFuture private class FuturesImpl(private val model: LiveGenerativeModel) : LiveModelFutures() { - override fun connect(): ListenableFuture { - return SuspendToFutureAdapter.launchFuture { model.connect() } + override fun connect(): ListenableFuture { + return SuspendToFutureAdapter.launchFuture { LiveSessionFutures.from(model.connect()) } } } diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt index 044f83e8cc1..a81a28c3baa 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt @@ -48,6 +48,16 @@ public abstract class LiveSessionFutures internal constructor() { functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)? ): ListenableFuture + /** + * Starts an audio conversation with the Gemini server, which can only be stopped using + * [stopAudioConversation]. + * + * @param functionCallHandler A callback function to map function calls from the server to their + * response parts. + */ + public abstract fun startAudioConversation( + ): ListenableFuture + /** * Stops the audio conversation with the Gemini Server. * @@ -124,6 +134,8 @@ public abstract class LiveSessionFutures internal constructor() { functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)? ) = SuspendToFutureAdapter.launchFuture { session.startAudioConversation(functionCallHandler) } + override fun startAudioConversation() = SuspendToFutureAdapter.launchFuture { session.startAudioConversation() } + override fun stopAudioConversation() = SuspendToFutureAdapter.launchFuture { session.stopAudioConversation() } diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/LiveGenerationConfig.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/LiveGenerationConfig.kt index 55e789fd14f..2f8f39a3afc 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/LiveGenerationConfig.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/LiveGenerationConfig.kt @@ -130,8 +130,8 @@ private constructor( public fun setFrequencyPenalty(frequencyPenalty: Float?): Builder = apply { this.frequencyPenalty = frequencyPenalty } - public fun setResponseModalities(responseModalities: ResponseModality?): Builder = apply { - this.responseModality = responseModalities + public fun setResponseModality(responseModality: ResponseModality?): Builder = apply { + this.responseModality = responseModality } public fun setSpeechConfig(speechConfig: SpeechConfig?): Builder = apply { this.speechConfig = speechConfig From 5f1154b09362114ca08fe5cb2bdde7a9d5b0563f Mon Sep 17 00:00:00 2001 From: VinayGuthal Date: Thu, 3 Apr 2025 14:01:35 -0400 Subject: [PATCH 2/8] update --- .../com/google/firebase/vertexai/java/LiveSessionFutures.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt index a81a28c3baa..b8e8a4e838e 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt @@ -55,8 +55,7 @@ public abstract class LiveSessionFutures internal constructor() { * @param functionCallHandler A callback function to map function calls from the server to their * response parts. */ - public abstract fun startAudioConversation( - ): ListenableFuture + public abstract fun startAudioConversation(): ListenableFuture /** * Stops the audio conversation with the Gemini Server. @@ -134,7 +133,8 @@ public abstract class LiveSessionFutures internal constructor() { functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)? ) = SuspendToFutureAdapter.launchFuture { session.startAudioConversation(functionCallHandler) } - override fun startAudioConversation() = SuspendToFutureAdapter.launchFuture { session.startAudioConversation() } + override fun startAudioConversation() = + SuspendToFutureAdapter.launchFuture { session.startAudioConversation() } override fun stopAudioConversation() = SuspendToFutureAdapter.launchFuture { session.stopAudioConversation() } From 7ded9a84078750edd2cb6ef70aac2a6893e50baa Mon Sep 17 00:00:00 2001 From: VinayGuthal Date: Fri, 11 Apr 2025 13:07:56 -0400 Subject: [PATCH 3/8] update --- .../firebase/vertexai/java/LiveSessionFutures.kt | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt index b8e8a4e838e..568b1f3b523 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt @@ -44,18 +44,11 @@ public abstract class LiveSessionFutures internal constructor() { * @param functionCallHandler A callback function to map function calls from the server to their * response parts. */ + @JvmOverloads public abstract fun startAudioConversation( functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)? ): ListenableFuture - /** - * Starts an audio conversation with the Gemini server, which can only be stopped using - * [stopAudioConversation]. - * - * @param functionCallHandler A callback function to map function calls from the server to their - * response parts. - */ - public abstract fun startAudioConversation(): ListenableFuture /** * Stops the audio conversation with the Gemini Server. @@ -133,9 +126,6 @@ public abstract class LiveSessionFutures internal constructor() { functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)? ) = SuspendToFutureAdapter.launchFuture { session.startAudioConversation(functionCallHandler) } - override fun startAudioConversation() = - SuspendToFutureAdapter.launchFuture { session.startAudioConversation() } - override fun stopAudioConversation() = SuspendToFutureAdapter.launchFuture { session.stopAudioConversation() } From 3faf0f7972ea871d0b1aa363fdc508973e6e7425 Mon Sep 17 00:00:00 2001 From: VinayGuthal Date: Tue, 15 Apr 2025 14:42:22 -0400 Subject: [PATCH 4/8] remove unspecified modality --- .../firebase/vertexai/java/LiveModelFutures.kt | 5 ++--- .../vertexai/java/LiveSessionFutures.kt | 9 ++++++++- .../firebase/vertexai/type/ResponseModality.kt | 17 +++++------------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt index aa7ba07e377..cc8fb8893d7 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt @@ -19,7 +19,6 @@ package com.google.firebase.vertexai.java import androidx.concurrent.futures.SuspendToFutureAdapter import com.google.common.util.concurrent.ListenableFuture import com.google.firebase.vertexai.LiveGenerativeModel -import com.google.firebase.vertexai.type.LiveSession import com.google.firebase.vertexai.type.PublicPreviewAPI import com.google.firebase.vertexai.type.ServiceConnectionHandshakeFailedException @@ -32,8 +31,8 @@ import com.google.firebase.vertexai.type.ServiceConnectionHandshakeFailedExcepti public abstract class LiveModelFutures internal constructor() { /** - * Start a [LiveSession] with the server for bidirectional streaming. - * @return A [LiveSession] that you can use to stream messages to and from the server. + * Start a [LiveSessionFutures] with the server for bidirectional streaming. + * @return A [LiveSessionFutures] that you can use to stream messages to and from the server. * @throws [ServiceConnectionHandshakeFailedException] If the client was not able to establish a * connection with the server. */ diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt index 568b1f3b523..f5b56758d19 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt @@ -44,11 +44,15 @@ public abstract class LiveSessionFutures internal constructor() { * @param functionCallHandler A callback function to map function calls from the server to their * response parts. */ - @JvmOverloads public abstract fun startAudioConversation( functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)? ): ListenableFuture + /** + * Starts an audio conversation with the Gemini server, which can only be stopped using + * [stopAudioConversation]. + */ + public abstract fun startAudioConversation(): ListenableFuture /** * Stops the audio conversation with the Gemini Server. @@ -126,6 +130,9 @@ public abstract class LiveSessionFutures internal constructor() { functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)? ) = SuspendToFutureAdapter.launchFuture { session.startAudioConversation(functionCallHandler) } + override fun startAudioConversation() = + SuspendToFutureAdapter.launchFuture { session.startAudioConversation() } + override fun stopAudioConversation() = SuspendToFutureAdapter.launchFuture { session.stopAudioConversation() } diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt index e8fe70db157..c1f6aaf4f9b 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt @@ -18,7 +18,6 @@ package com.google.firebase.vertexai.type import com.google.firebase.vertexai.common.util.FirstOrdinalSerializer import kotlinx.serialization.KSerializer -import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable /** Modality for bidirectional streaming. */ @@ -27,7 +26,6 @@ public class ResponseModality private constructor(public val ordinal: Int) { @Serializable(Internal.Serializer::class) internal enum class Internal { - @SerialName("MODALITY_UNSPECIFIED") UNSPECIFIED, TEXT, IMAGE, AUDIO; @@ -38,8 +36,7 @@ public class ResponseModality private constructor(public val ordinal: Int) { when (this) { TEXT -> ResponseModality.TEXT IMAGE -> ResponseModality.IMAGE - AUDIO -> ResponseModality.AUDIO - else -> ResponseModality.UNSPECIFIED + else -> ResponseModality.AUDIO } } @@ -47,20 +44,16 @@ public class ResponseModality private constructor(public val ordinal: Int) { when (this) { TEXT -> "TEXT" IMAGE -> "IMAGE" - AUDIO -> "AUDIO" - else -> "UNSPECIFIED" + else -> "AUDIO" } public companion object { - /** Unspecified modality. */ - @JvmField public val UNSPECIFIED: ResponseModality = ResponseModality(0) - /** Plain text. */ - @JvmField public val TEXT: ResponseModality = ResponseModality(1) + @JvmField public val TEXT: ResponseModality = ResponseModality(0) /** Image. */ - @JvmField public val IMAGE: ResponseModality = ResponseModality(2) + @JvmField public val IMAGE: ResponseModality = ResponseModality(1) /** Audio. */ - @JvmField public val AUDIO: ResponseModality = ResponseModality(4) + @JvmField public val AUDIO: ResponseModality = ResponseModality(2) } } From bad6b8379f040a139feb7e5cd4aa8a637a29e923 Mon Sep 17 00:00:00 2001 From: VinayGuthal Date: Tue, 15 Apr 2025 14:56:56 -0400 Subject: [PATCH 5/8] update --- firebase-vertexai/CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/firebase-vertexai/CHANGELOG.md b/firebase-vertexai/CHANGELOG.md index f43495222bc..840fdd1ce88 100644 --- a/firebase-vertexai/CHANGELOG.md +++ b/firebase-vertexai/CHANGELOG.md @@ -1,5 +1,11 @@ # Unreleased - +* [changed] **Breaking Change**: `LiveModelFutures.connect` now returns `ListenableFuture` instead of `ListenableFuture`. + * **Action Required:** Remove any transformations from LiveSession object to LiveSessionFutures. + * **Action Required:** Change type of variable handling `LiveModelFutures.connect` to `ListenableFuture` +* [changed] **Breaking Change**: Removed `UNSPECIFIED` value for enum class `ResponseModality` + * **Action Required:** Remove all references to `ResponseModality.UNSPECIFIED` +* [changed] **Breaking Change**: Renamed `LiveGenerationConfig.setResponseModalities` to `LiveGenerationConfig.setResponseModality` + * **Action Required:** Replace all references of `LiveGenerationConfig.setResponseModalities` with `LiveGenerationConfig.setResponseModality` # 16.3.0 * [feature] Emits a warning when attempting to use an incompatible model with From db5f3a03217e24fbf558db67836c121bfbf9e9ba Mon Sep 17 00:00:00 2001 From: VinayGuthal Date: Tue, 15 Apr 2025 14:59:03 -0400 Subject: [PATCH 6/8] update numbers --- .../com/google/firebase/vertexai/type/ResponseModality.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt index c1f6aaf4f9b..e36016b8ebc 100644 --- a/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt +++ b/firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt @@ -48,12 +48,12 @@ public class ResponseModality private constructor(public val ordinal: Int) { } public companion object { /** Plain text. */ - @JvmField public val TEXT: ResponseModality = ResponseModality(0) + @JvmField public val TEXT: ResponseModality = ResponseModality(1) /** Image. */ - @JvmField public val IMAGE: ResponseModality = ResponseModality(1) + @JvmField public val IMAGE: ResponseModality = ResponseModality(2) /** Audio. */ - @JvmField public val AUDIO: ResponseModality = ResponseModality(2) + @JvmField public val AUDIO: ResponseModality = ResponseModality(4) } } From 6f5a249ef35d03ae217d01b4a5801c592d2c06f8 Mon Sep 17 00:00:00 2001 From: VinayGuthal Date: Tue, 15 Apr 2025 14:59:51 -0400 Subject: [PATCH 7/8] update --- firebase-vertexai/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase-vertexai/CHANGELOG.md b/firebase-vertexai/CHANGELOG.md index 840fdd1ce88..8ac51d5ea8d 100644 --- a/firebase-vertexai/CHANGELOG.md +++ b/firebase-vertexai/CHANGELOG.md @@ -1,6 +1,6 @@ # Unreleased * [changed] **Breaking Change**: `LiveModelFutures.connect` now returns `ListenableFuture` instead of `ListenableFuture`. - * **Action Required:** Remove any transformations from LiveSession object to LiveSessionFutures. + * **Action Required:** Remove any transformations from LiveSession object to LiveSessionFutures object. * **Action Required:** Change type of variable handling `LiveModelFutures.connect` to `ListenableFuture` * [changed] **Breaking Change**: Removed `UNSPECIFIED` value for enum class `ResponseModality` * **Action Required:** Remove all references to `ResponseModality.UNSPECIFIED` From 33b7a90953c829120e4b14836b0b4c303dd8d35c Mon Sep 17 00:00:00 2001 From: VinayGuthal Date: Tue, 15 Apr 2025 15:06:08 -0400 Subject: [PATCH 8/8] remove HEAD --- firebase-vertexai/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/firebase-vertexai/CHANGELOG.md b/firebase-vertexai/CHANGELOG.md index ab83212dcc9..0969016889c 100644 --- a/firebase-vertexai/CHANGELOG.md +++ b/firebase-vertexai/CHANGELOG.md @@ -1,5 +1,4 @@ # Unreleased -<<<<<<< HEAD * [changed] **Breaking Change**: `LiveModelFutures.connect` now returns `ListenableFuture` instead of `ListenableFuture`. * **Action Required:** Remove any transformations from LiveSession object to LiveSessionFutures object. * **Action Required:** Change type of variable handling `LiveModelFutures.connect` to `ListenableFuture`