TemplateChatFutures

@PublicPreviewAPI
public abstract class TemplateChatFutures


Wrapper class providing Java compatible methods for TemplateChat.

See also
TemplateChat

Summary

Nested types

public static class TemplateChatFutures.Companion

Public methods

static final @NonNull TemplateChatFutures
from(@NonNull TemplateChat templateChat)
abstract @NonNull TemplateChat

Returns the TemplateChat object wrapped by this object.

abstract @NonNull ListenableFuture<@NonNull GenerateContentResponse>

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

abstract @NonNull Publisher<@NonNull GenerateContentResponse>

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

Public methods

from

public static final @NonNull TemplateChatFutures from(@NonNull TemplateChat templateChat)
Returns
@NonNull TemplateChatFutures

a TemplateChatFutures created around the provided TemplateChat

getTemplateChat

public abstract @NonNull TemplateChat getTemplateChat()

Returns the TemplateChat object wrapped by this object.

sendMessage

public abstract @NonNull ListenableFuture<@NonNull GenerateContentResponsesendMessage(@NonNull Content 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
@NonNull Content prompt

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

Throws
com.google.firebase.ai.type.InvalidStateException com.google.firebase.ai.type.InvalidStateException

if prompt is not coming from the 'user' role

com.google.firebase.ai.type.InvalidStateException com.google.firebase.ai.type.InvalidStateException

if the TemplateChat instance has an active request

sendMessageStream

public abstract @NonNull Publisher<@NonNull GenerateContentResponsesendMessageStream(@NonNull Content 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
@NonNull Content prompt

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

Throws
com.google.firebase.ai.type.InvalidStateException com.google.firebase.ai.type.InvalidStateException

if prompt is not coming from the 'user' role

com.google.firebase.ai.type.InvalidStateException com.google.firebase.ai.type.InvalidStateException

if the TemplateChat instance has an active request