GenerativeModelFutures

abstract class GenerativeModelFutures


Wrapper class providing Java compatible methods for GenerativeModel.

See also
GenerativeModel

Summary

Public companion functions

GenerativeModelFutures

Public functions

abstract ListenableFuture<CountTokensResponse>
countTokens(vararg prompt: Content)

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

abstract ListenableFuture<GenerateContentResponse>
generateContent(vararg prompt: Content)

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

abstract Publisher<GenerateContentResponse>
generateContentStream(vararg prompt: Content)

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

abstract GenerativeModel

Returns the GenerativeModel object wrapped by this object.

abstract ChatFutures

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

abstract ChatFutures
startChat(history: List<Content>)

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

Public companion functions

Public functions

countTokens

abstract fun countTokens(vararg prompt: Content): ListenableFuture<CountTokensResponse>

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

Parameters
vararg prompt: Content

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

Returns
ListenableFuture<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.

generateContent

abstract fun generateContent(vararg prompt: Content): ListenableFuture<GenerateContentResponse>

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

Parameters
vararg prompt: Content

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

Returns
ListenableFuture<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

abstract fun generateContentStream(vararg prompt: Content): Publisher<GenerateContentResponse>

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

Parameters
vararg prompt: Content

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

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

abstract fun getGenerativeModel(): GenerativeModel

Returns the GenerativeModel object wrapped by this object.

startChat

abstract fun startChat(): ChatFutures

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

startChat

abstract fun startChat(history: List<Content>): ChatFutures

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

Parameters
history: List<Content>

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