Chat

class Chat(model: GenerativeModel, val history: MutableList<Content> = ArrayList())(source)

Representation of a multi-turn interaction with a model.

Captures and stores the history of communication in memory, and provides it as context with each new message.

Note: This object is not thread-safe, and calling sendMessage multiple times without waiting for a response will throw an InvalidStateException.

Parameters

model

The model to use for the interaction.

Constructors

Link copied to clipboard
constructor(model: GenerativeModel, history: MutableList<Content> = ArrayList())

Properties

Link copied to clipboard

The previous content from the chat that has been successfully sent and received from the model. This will be provided to the model for each message sent (as context for the discussion).

Functions

Link copied to clipboard

Sends a message using the provided prompt; automatically providing the existing history as context.

Sends a message using the provided text prompt; automatically providing the existing history as context.

Link copied to clipboard

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

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