Skip to content

Commit d730323

Browse files
committed
update
1 parent 8c8fc9d commit d730323

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

firebase-vertexai/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ package com.google.firebase.vertexai.type {
627627

628628
public final class LiveSession {
629629
method public suspend Object? close(kotlin.coroutines.Continuation<? super kotlin.Unit>);
630-
method public suspend Object? receive(java.util.List<com.google.firebase.vertexai.type.ContentModality> outputModalities, kotlin.coroutines.Continuation<? super kotlinx.coroutines.flow.Flow<? extends com.google.firebase.vertexai.type.LiveContentResponse>>);
630+
method public kotlinx.coroutines.flow.Flow<com.google.firebase.vertexai.type.LiveContentResponse> receive(java.util.List<com.google.firebase.vertexai.type.ContentModality> outputModalities);
631631
method public kotlinx.coroutines.flow.Flow<java.util.List<com.google.firebase.vertexai.type.FunctionCallPart>> receiveAudioConversationFunctionCalls();
632632
method public suspend Object? send(com.google.firebase.vertexai.type.Content content, kotlin.coroutines.Continuation<? super kotlin.Unit>);
633633
method public suspend Object? send(String text, kotlin.coroutines.Continuation<? super kotlin.Unit>);

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/LiveGenerativeModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ internal constructor(
8181

8282
/**
8383
* Returns a LiveSession object using which you could send/receive messages from the server
84-
* @return LiveSession object created. Returns null if the object cannot be created.
84+
* @return LiveSession object created
8585
* @throws [BidiServerHandshakeFailed] if the handshake with the server failed.
8686
*/
8787
public suspend fun connect(): LiveSession {

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import kotlinx.coroutines.reactive.asPublisher
3131
import org.reactivestreams.Publisher
3232

3333
/**
34-
* Wrapper class providing Java compatible methods for [GenerativeModel].
34+
* Wrapper class providing Java compatible methods for [LiveSession].
3535
*
36-
* @see [GenerativeModel]
36+
* @see [LiveSession]
3737
*/
3838
public abstract class LiveSessionFutures internal constructor() {
3939

@@ -94,7 +94,7 @@ public abstract class LiveSessionFutures internal constructor() {
9494
*/
9595
public abstract fun receive(
9696
outputModalities: List<ContentModality>
97-
): ListenableFuture<Publisher<LiveContentResponse>>
97+
): Publisher<LiveContentResponse>
9898

9999
/**
100100
* Receives all function call responses from the server for the audio conversation feature..
@@ -106,10 +106,8 @@ public abstract class LiveSessionFutures internal constructor() {
106106

107107
private class FuturesImpl(private val session: LiveSession) : LiveSessionFutures() {
108108

109-
override fun receive(
110-
outputModalities: List<ContentModality>
111-
): ListenableFuture<Publisher<LiveContentResponse>> =
112-
SuspendToFutureAdapter.launchFuture { session.receive(outputModalities).asPublisher() }
109+
override fun receive(outputModalities: List<ContentModality>): Publisher<LiveContentResponse> =
110+
session.receive(outputModalities).asPublisher()
113111

114112
override fun receiveAudioConversationFunctionCalls(): Publisher<List<FunctionCallPart>> =
115113
session.receiveAudioConversationFunctionCalls().asPublisher()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public class QuotaExceededException
175175
internal constructor(message: String, cause: Throwable? = null) :
176176
FirebaseVertexAIException(message, cause)
177177

178-
/** Bidi session already receiving. */
178+
/** Streaming session already receiving. */
179179
public class SessionAlreadyReceivingException :
180180
FirebaseVertexAIException(
181181
"This session is already receiving. Please call stopReceiving() before calling this again."

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import io.ktor.websocket.readBytes
2727
import java.util.concurrent.ConcurrentLinkedQueue
2828
import kotlin.coroutines.CoroutineContext
2929
import kotlinx.coroutines.CoroutineScope
30-
import kotlinx.coroutines.Dispatchers
3130
import kotlinx.coroutines.cancel
3231
import kotlinx.coroutines.channels.Channel
3332
import kotlinx.coroutines.delay
@@ -156,7 +155,7 @@ internal constructor(
156155
receivedAudio.copyInto(audioBuffer, offset)
157156
offset += receivedAudio.size
158157
if (offset >= MIN_BUFFER_SIZE) {
159-
sendMediaStream(listOf(MediaData( audioBuffer, "audio/pcm")))
158+
sendMediaStream(listOf(MediaData(audioBuffer, "audio/pcm")))
160159
audioBuffer.fill(0)
161160
offset = 0
162161
}
@@ -248,13 +247,13 @@ internal constructor(
248247
*
249248
* @throws [SessionAlreadyReceivingException] when the session is already receiving.
250249
*/
251-
public suspend fun receive(outputModalities: List<ContentModality>): Flow<LiveContentResponse> {
250+
public fun receive(outputModalities: List<ContentModality>): Flow<LiveContentResponse> {
252251
if (startedReceiving) {
253252
throw SessionAlreadyReceivingException()
254253
}
255254

256255
val flowReceive = session!!.incoming.receiveAsFlow()
257-
CoroutineScope(Dispatchers.IO).launch { flowReceive.collect { receiveChannel.send(it) } }
256+
CoroutineScope(backgroundDispatcher).launch { flowReceive.collect { receiveChannel.send(it) } }
258257
return flow {
259258
startedReceiving = true
260259
while (true) {

0 commit comments

Comments
 (0)