LiveSessionFutures

@PublicPreviewAPI
public abstract class LiveSessionFutures


Wrapper class providing Java compatible methods for LiveSession.

See also
LiveSession

Summary

Nested types

public static class LiveSessionFutures.Companion

Public methods

abstract @NonNull ListenableFuture<Unit>

Closes the client session.

static final @NonNull LiveSessionFutures
abstract @NonNull Publisher<@NonNull LiveContentResponse>

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

abstract @NonNull ListenableFuture<Unit>
send(@NonNull Content content)

Sends data to the server.

abstract @NonNull ListenableFuture<Unit>

Sends text to the server

abstract @NonNull ListenableFuture<Unit>

Sends the function response from the client to the server.

abstract @NonNull ListenableFuture<Unit>

Streams client data to the server.

abstract @NonNull ListenableFuture<Unit>
startAudioConversation(
    Function1<@NonNull FunctionCallPart, @NonNull FunctionResponsePart> functionCallHandler
)

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

abstract @NonNull ListenableFuture<Unit>

Stops the audio conversation with the Gemini Server.

abstract void

Stop receiving from the server.

Public methods

close

public abstract @NonNull ListenableFuture<Unitclose()

Closes the client session.

from

public static final @NonNull LiveSessionFutures from(@NonNull LiveSession session)
Returns
@NonNull LiveSessionFutures

a LiveSessionFutures created around the provided LiveSession

receive

public abstract @NonNull Publisher<@NonNull LiveContentResponsereceive()

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

Returns
@NonNull Publisher<@NonNull 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

public abstract @NonNull ListenableFuture<Unitsend(@NonNull Content content)

Sends data to the server.

Parameters
@NonNull Content content

Client Content to be sent to the server.

send

public abstract @NonNull ListenableFuture<Unitsend(@NonNull String text)

Sends text to the server

Parameters
@NonNull String text

Text to be sent to the server.

sendFunctionResponse

public abstract @NonNull ListenableFuture<UnitsendFunctionResponse(
    @NonNull List<@NonNull FunctionResponsePart> functionList
)

Sends the function response from the client to the server.

Parameters
@NonNull List<@NonNull FunctionResponsePart> functionList

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

sendMediaStream

public abstract @NonNull ListenableFuture<UnitsendMediaStream(@NonNull List<@NonNull MediaData> mediaChunks)

Streams client data to the server.

Parameters
@NonNull List<@NonNull MediaData> mediaChunks

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

startAudioConversation

public abstract @NonNull ListenableFuture<UnitstartAudioConversation(
    Function1<@NonNull FunctionCallPart, @NonNull FunctionResponsePart> functionCallHandler
)

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

Parameters
Function1<@NonNull FunctionCallPart, @NonNull FunctionResponsePart> functionCallHandler

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

stopAudioConversation

public abstract @NonNull ListenableFuture<UnitstopAudioConversation()

Stops the audio conversation with the Gemini Server.

stopReceiving

public abstract void stopReceiving()

Stop receiving from the server.