LiveSessionFutures

@PublicPreviewAPI
abstract class LiveSessionFutures


Wrapper class providing Java compatible methods for LiveSession.

See also
LiveSession

Summary

Public companion functions

LiveSessionFutures
from(session: LiveSession)

Public functions

abstract ListenableFuture<Unit>

Closes the client session.

abstract Publisher<LiveContentResponse>

Receives responses from the server for both streaming and standard requests.

abstract ListenableFuture<Unit>
send(content: Content)

Sends data to the server.

abstract ListenableFuture<Unit>
send(text: String)

Sends text to the server

abstract ListenableFuture<Unit>

Sends the function response from the client to the server.

abstract ListenableFuture<Unit>

Streams client data to the server.

abstract ListenableFuture<Unit>
startAudioConversation(
    functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)?
)

Starts an audio conversation with the Gemini server, which can only be stopped using stopAudioConversation.

abstract ListenableFuture<Unit>

Stops the audio conversation with the Gemini Server.

abstract Unit

Stop receiving from the server.

Public companion functions

from

fun from(session: LiveSession): LiveSessionFutures
Returns
LiveSessionFutures

a LiveSessionFutures created around the provided LiveSession

Public functions

close

abstract fun close(): ListenableFuture<Unit>

Closes the client session.

receive

abstract fun receive(): Publisher<LiveContentResponse>

Receives responses from the server for both streaming and standard requests.

Returns
Publisher<LiveContentResponse>

A Publisher which will emit LiveContentResponse as and when it receives it.

Throws
com.google.firebase.vertexai.type.SessionAlreadyReceivingException: com.google.firebase.vertexai.type.SessionAlreadyReceivingException

When the session is already receiving.

send

abstract fun send(content: Content): ListenableFuture<Unit>

Sends data to the server.

Parameters
content: Content

Client Content to be sent to the server.

send

abstract fun send(text: String): ListenableFuture<Unit>

Sends text to the server

Parameters
text: String

Text to be sent to the server.

sendFunctionResponse

abstract fun sendFunctionResponse(functionList: List<FunctionResponsePart>): ListenableFuture<Unit>

Sends the function response from the client to the server.

Parameters
functionList: List<FunctionResponsePart>

The list of FunctionResponsePart instances indicating the function response from the client.

sendMediaStream

abstract fun sendMediaStream(mediaChunks: List<MediaData>): ListenableFuture<Unit>

Streams client data to the server.

Parameters
mediaChunks: List<MediaData>

The list of MediaData instances representing the media data to be sent.

startAudioConversation

abstract fun startAudioConversation(
    functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)?
): ListenableFuture<Unit>

Starts an audio conversation with the Gemini server, which can only be stopped using stopAudioConversation.

Parameters
functionCallHandler: ((FunctionCallPart) -> FunctionResponsePart)?

A callback function to map function calls from the server to their response parts.

stopAudioConversation

abstract fun stopAudioConversation(): ListenableFuture<Unit>

Stops the audio conversation with the Gemini Server.

stopReceiving

abstract fun stopReceiving(): Unit

Stop receiving from the server.