Skip to content

Commit 0a1a48a

Browse files
authored
Merge branch 'main' into daymon-update-bidi
2 parents 644a50b + 47e37b5 commit 0a1a48a

File tree

8 files changed

+35
-22
lines changed

8 files changed

+35
-22
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/CompositeIndexTestHelper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ public void assertOnlineAndOfflineResultsMatch(
125125
@NonNull CollectionReference collection,
126126
@NonNull Query query,
127127
@NonNull String... expectedDocs) {
128-
checkOnlineAndOfflineResultsMatch(collection, query, toHashedIds(expectedDocs));
128+
// `checkOnlineAndOfflineResultsMatch` first makes sure all documents needed for
129+
// `query` are in the cache. It does so making a `get` on the first argument.
130+
// Since *all* composite index tests use the same collection, this is very inefficient to do.
131+
// Therefore, we should only do so for tests where `TEST_ID_FIELD` matches the current test.
132+
checkOnlineAndOfflineResultsMatch(this.query(collection), query, toHashedIds(expectedDocs));
129133
}
130134

131135
// Asserts that the IDs in the query snapshot matches the expected Ids. The expected document

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public static List<Object> nullList() {
535535
* @param expectedDocs Ordered list of document keys that are expected to match the query
536536
*/
537537
public static void checkOnlineAndOfflineResultsMatch(
538-
CollectionReference collection, Query query, String... expectedDocs) {
538+
Query collection, Query query, String... expectedDocs) {
539539
// Note: Order matters. The following has to be done in the specific order:
540540

541541
// 1- Pre-populate the cache with the entire collection.

firebase-vertexai/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Unreleased
2+
* [changed] **Breaking Change**: `LiveModelFutures.connect` now returns `ListenableFuture<LiveSessionFutures>` instead of `ListenableFuture<LiveSession>`.
3+
* **Action Required:** Remove any transformations from LiveSession object to LiveSessionFutures object.
4+
* **Action Required:** Change type of variable handling `LiveModelFutures.connect` to `ListenableFuture<LiveSessionsFutures>`
5+
* [changed] **Breaking Change**: Removed `UNSPECIFIED` value for enum class `ResponseModality`
6+
* **Action Required:** Remove all references to `ResponseModality.UNSPECIFIED`
7+
* [changed] **Breaking Change**: Renamed `LiveGenerationConfig.setResponseModalities` to `LiveGenerationConfig.setResponseModality`
8+
* **Action Required:** Replace all references of `LiveGenerationConfig.setResponseModalities` with `LiveGenerationConfig.setResponseModality`
29
* [feature] Added support for `HarmBlockThreshold.OFF`. See the
310
[model documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters#how_to_configure_content_filters){: .external}
411
for more information.

firebase-vertexai/api.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ package com.google.firebase.vertexai.java {
115115
}
116116

117117
@com.google.firebase.vertexai.type.PublicPreviewAPI public abstract class LiveModelFutures {
118-
method public abstract com.google.common.util.concurrent.ListenableFuture<com.google.firebase.vertexai.type.LiveSession> connect();
118+
method public abstract com.google.common.util.concurrent.ListenableFuture<com.google.firebase.vertexai.java.LiveSessionFutures> connect();
119119
method public static final com.google.firebase.vertexai.java.LiveModelFutures from(com.google.firebase.vertexai.LiveGenerativeModel model);
120120
field public static final com.google.firebase.vertexai.java.LiveModelFutures.Companion Companion;
121121
}
@@ -132,6 +132,7 @@ package com.google.firebase.vertexai.java {
132132
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> send(String text);
133133
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> sendFunctionResponse(java.util.List<com.google.firebase.vertexai.type.FunctionResponsePart> functionList);
134134
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> sendMediaStream(java.util.List<com.google.firebase.vertexai.type.MediaData> mediaChunks);
135+
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> startAudioConversation();
135136
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> startAudioConversation(kotlin.jvm.functions.Function1<? super com.google.firebase.vertexai.type.FunctionCallPart,com.google.firebase.vertexai.type.FunctionResponsePart>? functionCallHandler);
136137
method public abstract com.google.common.util.concurrent.ListenableFuture<kotlin.Unit> stopAudioConversation();
137138
method public abstract void stopReceiving();
@@ -597,7 +598,7 @@ package com.google.firebase.vertexai.type {
597598
method public com.google.firebase.vertexai.type.LiveGenerationConfig.Builder setFrequencyPenalty(Float? frequencyPenalty);
598599
method public com.google.firebase.vertexai.type.LiveGenerationConfig.Builder setMaxOutputTokens(Integer? maxOutputTokens);
599600
method public com.google.firebase.vertexai.type.LiveGenerationConfig.Builder setPresencePenalty(Float? presencePenalty);
600-
method public com.google.firebase.vertexai.type.LiveGenerationConfig.Builder setResponseModalities(com.google.firebase.vertexai.type.ResponseModality? responseModalities);
601+
method public com.google.firebase.vertexai.type.LiveGenerationConfig.Builder setResponseModality(com.google.firebase.vertexai.type.ResponseModality? responseModality);
601602
method public com.google.firebase.vertexai.type.LiveGenerationConfig.Builder setSpeechConfig(com.google.firebase.vertexai.type.SpeechConfig? speechConfig);
602603
method public com.google.firebase.vertexai.type.LiveGenerationConfig.Builder setTemperature(Float? temperature);
603604
method public com.google.firebase.vertexai.type.LiveGenerationConfig.Builder setTopK(Integer? topK);
@@ -696,7 +697,6 @@ package com.google.firebase.vertexai.type {
696697
field public static final com.google.firebase.vertexai.type.ResponseModality.Companion Companion;
697698
field public static final com.google.firebase.vertexai.type.ResponseModality IMAGE;
698699
field public static final com.google.firebase.vertexai.type.ResponseModality TEXT;
699-
field public static final com.google.firebase.vertexai.type.ResponseModality UNSPECIFIED;
700700
}
701701

702702
public static final class ResponseModality.Companion {

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveModelFutures.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package com.google.firebase.vertexai.java
1919
import androidx.concurrent.futures.SuspendToFutureAdapter
2020
import com.google.common.util.concurrent.ListenableFuture
2121
import com.google.firebase.vertexai.LiveGenerativeModel
22-
import com.google.firebase.vertexai.type.LiveSession
2322
import com.google.firebase.vertexai.type.PublicPreviewAPI
2423
import com.google.firebase.vertexai.type.ServiceConnectionHandshakeFailedException
2524

@@ -32,16 +31,16 @@ import com.google.firebase.vertexai.type.ServiceConnectionHandshakeFailedExcepti
3231
public abstract class LiveModelFutures internal constructor() {
3332

3433
/**
35-
* Start a [LiveSession] with the server for bidirectional streaming.
36-
* @return A [LiveSession] that you can use to stream messages to and from the server.
34+
* Start a [LiveSessionFutures] with the server for bidirectional streaming.
35+
* @return A [LiveSessionFutures] that you can use to stream messages to and from the server.
3736
* @throws [ServiceConnectionHandshakeFailedException] If the client was not able to establish a
3837
* connection with the server.
3938
*/
40-
public abstract fun connect(): ListenableFuture<LiveSession>
39+
public abstract fun connect(): ListenableFuture<LiveSessionFutures>
4140

4241
private class FuturesImpl(private val model: LiveGenerativeModel) : LiveModelFutures() {
43-
override fun connect(): ListenableFuture<LiveSession> {
44-
return SuspendToFutureAdapter.launchFuture { model.connect() }
42+
override fun connect(): ListenableFuture<LiveSessionFutures> {
43+
return SuspendToFutureAdapter.launchFuture { LiveSessionFutures.from(model.connect()) }
4544
}
4645
}
4746

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/java/LiveSessionFutures.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ public abstract class LiveSessionFutures internal constructor() {
5252
): ListenableFuture<Unit>
5353

5454
/**
55-
* Stops the audio conversation with the model.
55+
* Starts an audio conversation with the model, which can only be stopped using
56+
* [stopAudioConversation].
57+
*/
58+
public abstract fun startAudioConversation(): ListenableFuture<Unit>
59+
60+
/**
61+
* Stops the audio conversation with the Gemini Server.
5662
*
5763
* This only needs to be called after a previous call to [startAudioConversation].
5864
*
@@ -157,6 +163,9 @@ public abstract class LiveSessionFutures internal constructor() {
157163
functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)?
158164
) = SuspendToFutureAdapter.launchFuture { session.startAudioConversation(functionCallHandler) }
159165

166+
override fun startAudioConversation() =
167+
SuspendToFutureAdapter.launchFuture { session.startAudioConversation() }
168+
160169
override fun stopAudioConversation() =
161170
SuspendToFutureAdapter.launchFuture { session.stopAudioConversation() }
162171

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/LiveGenerationConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ private constructor(
130130
public fun setFrequencyPenalty(frequencyPenalty: Float?): Builder = apply {
131131
this.frequencyPenalty = frequencyPenalty
132132
}
133-
public fun setResponseModalities(responseModalities: ResponseModality?): Builder = apply {
134-
this.responseModality = responseModalities
133+
public fun setResponseModality(responseModality: ResponseModality?): Builder = apply {
134+
this.responseModality = responseModality
135135
}
136136
public fun setSpeechConfig(speechConfig: SpeechConfig?): Builder = apply {
137137
this.speechConfig = speechConfig

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/ResponseModality.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package com.google.firebase.vertexai.type
1818

1919
import com.google.firebase.vertexai.common.util.FirstOrdinalSerializer
2020
import kotlinx.serialization.KSerializer
21-
import kotlinx.serialization.SerialName
2221
import kotlinx.serialization.Serializable
2322

2423
/** Represents the type of content present in a response (e.g., text, image, audio). */
@@ -27,7 +26,6 @@ public class ResponseModality private constructor(public val ordinal: Int) {
2726

2827
@Serializable(Internal.Serializer::class)
2928
internal enum class Internal {
30-
@SerialName("MODALITY_UNSPECIFIED") UNSPECIFIED,
3129
TEXT,
3230
IMAGE,
3331
AUDIO;
@@ -38,21 +36,17 @@ public class ResponseModality private constructor(public val ordinal: Int) {
3836
when (this) {
3937
TEXT -> ResponseModality.TEXT
4038
IMAGE -> ResponseModality.IMAGE
41-
AUDIO -> ResponseModality.AUDIO
42-
else -> ResponseModality.UNSPECIFIED
39+
else -> ResponseModality.AUDIO
4340
}
4441
}
4542

4643
internal fun toInternal() =
4744
when (this) {
4845
TEXT -> "TEXT"
4946
IMAGE -> "IMAGE"
50-
AUDIO -> "AUDIO"
51-
else -> "UNSPECIFIED"
47+
else -> "AUDIO"
5248
}
5349
public companion object {
54-
/** Unspecified modality. */
55-
@JvmField public val UNSPECIFIED: ResponseModality = ResponseModality(0)
5650

5751
/** Represents a plain text response modality. */
5852
@JvmField public val TEXT: ResponseModality = ResponseModality(1)

0 commit comments

Comments
 (0)