ChatFutures

public abstract class ChatFutures


Wrapper class providing Java compatible methods for Chat.

See also
Chat

Summary

Nested types

public static class ChatFutures.Companion

Public methods

static final @NonNullChatFutures
abstract @NonNullChat

Returns the Chat object wrapped by this object.

abstract @NonNullListenableFuture<@NonNullGenerateContentResponse>

Sends a message using the existing history of this chat as context and the provided Content prompt.

abstract @NonNullPublisher<@NonNullGenerateContentResponse>

Sends a message using the existing history of this chat as context and the provided Content prompt.

Public methods

from

public static final @NonNullChatFutures from(@NonNullChat chat)
Returns
@NonNullChatFutures

a ChatFutures created around the provided Chat

getChat

public abstract @NonNullChat getChat()

Returns the Chat object wrapped by this object.

sendMessage

public abstract @NonNullListenableFuture<@NonNullGenerateContentResponsesendMessage(@NonNullContent prompt)

Sends a message using the existing history of this chat as context and the provided Content prompt.

If successful, the message and response will be added to the history. If unsuccessful, history will remain unchanged.

Parameters
@NonNullContent prompt

The input(s) that, together with the history, will be given to the model as the prompt.

Throws
com.google.firebase.vertexai.type.InvalidStateException com.google.firebase.vertexai.type.InvalidStateException

if prompt is not coming from the 'user' role

com.google.firebase.vertexai.type.InvalidStateException com.google.firebase.vertexai.type.InvalidStateException

if the Chat instance has an active request

sendMessageStream

public abstract @NonNullPublisher<@NonNullGenerateContentResponsesendMessageStream(@NonNullContent prompt)

Sends a message using the existing history of this chat as context and the provided Content prompt.

The response from the model is returned as a stream.

If successful, the message and response will be added to the history. If unsuccessful, history will remain unchanged.

Parameters
@NonNullContent prompt

The input(s) that, together with the history, will be given to the model as the prompt.

Throws
com.google.firebase.vertexai.type.InvalidStateException com.google.firebase.vertexai.type.InvalidStateException

if prompt is not coming from the 'user' role

com.google.firebase.vertexai.type.InvalidStateException com.google.firebase.vertexai.type.InvalidStateException

if the Chat instance has an active request