GenerativeModelFutures

public abstract class GenerativeModelFutures


Wrapper class providing Java compatible methods for GenerativeModel.

See also
GenerativeModel

Summary

Nested types

Public methods

abstract @NonNull ListenableFuture<@NonNull CountTokensResponse>

Counts the number of tokens in a prompt using the model's tokenizer.

static final @NonNull GenerativeModelFutures
abstract @NonNull ListenableFuture<@NonNull GenerateContentResponse>

Generates new content from the input Content given to the model as a prompt.

abstract @NonNull Publisher<@NonNull GenerateContentResponse>

Generates new content as a stream from the input Content given to the model as a prompt.

abstract @NonNull GenerativeModel

Returns the GenerativeModel object wrapped by this object.

abstract @NonNull ChatFutures

Creates a ChatFutures instance which internally tracks the ongoing conversation with the model.

abstract @NonNull ChatFutures

Creates a ChatFutures instance, initialized using the optionally provided history.

Public methods

countTokens

public abstract @NonNull ListenableFuture<@NonNull CountTokensResponsecountTokens(@NonNull Content prompt)

Counts the number of tokens in a prompt using the model's tokenizer.

Parameters
@NonNull Content prompt

The input(s) given to the model as a prompt.

Returns
@NonNull ListenableFuture<@NonNull CountTokensResponse>

The CountTokensResponse of running the model's tokenizer on the input.

Throws
com.google.firebase.vertexai.type.FirebaseVertexAIException com.google.firebase.vertexai.type.FirebaseVertexAIException

if the request failed.

from

public static final @NonNull GenerativeModelFutures from(@NonNull GenerativeModel model)
Returns
@NonNull GenerativeModelFutures

a GenerativeModelFutures created around the provided GenerativeModel

generateContent

public abstract @NonNull ListenableFuture<@NonNull GenerateContentResponsegenerateContent(@NonNull Content prompt)

Generates new content from the input Content given to the model as a prompt.

Parameters
@NonNull Content prompt

The input(s) given to the model as a prompt.

Returns
@NonNull ListenableFuture<@NonNull GenerateContentResponse>

The content generated by the model.

Throws
com.google.firebase.vertexai.type.FirebaseVertexAIException com.google.firebase.vertexai.type.FirebaseVertexAIException

if the request failed.

generateContentStream

public abstract @NonNull Publisher<@NonNull GenerateContentResponsegenerateContentStream(@NonNull Content prompt)

Generates new content as a stream from the input Content given to the model as a prompt.

Parameters
@NonNull Content prompt

The input(s) given to the model as a prompt.

Returns
@NonNull Publisher<@NonNull GenerateContentResponse>

A Publisher which will emit responses as they are returned by the model.

Throws
com.google.firebase.vertexai.type.FirebaseVertexAIException com.google.firebase.vertexai.type.FirebaseVertexAIException

if the request failed.

getGenerativeModel

public abstract @NonNull GenerativeModel getGenerativeModel()

Returns the GenerativeModel object wrapped by this object.

startChat

public abstract @NonNull ChatFutures startChat()

Creates a ChatFutures instance which internally tracks the ongoing conversation with the model.

startChat

public abstract @NonNull ChatFutures startChat(@NonNull List<@NonNull Content> history)

Creates a ChatFutures instance, initialized using the optionally provided history.

Parameters
@NonNull List<@NonNull Content> history

A list of previous interactions with the model to use as a starting point