public final class ChatSessionDeprecated. This class and its package are deprecated. See the migration guide for more details.
Represents a conversation between the user and the model.
Note: this class is NOT thread-safe.
Constructors
ChatSession(GenerativeModel model) (deprecated)
public ChatSession(GenerativeModel model)Creates a new chat session given a GenerativeModel instance. Configurations of the chat (e.g., GenerationConfig) inherits from the model.
| Parameter | |
|---|---|
| Name | Description |
model |
GenerativeModel |
Methods
getHistory() (deprecated)
public ImmutableList<Content> getHistory()Returns the history of the conversation.
| Returns | |
|---|---|
| Type | Description |
com.google.common.collect.ImmutableList<Content> |
a history of the conversation as an immutable list of Content. |
sendMessage(Content content) (deprecated)
public GenerateContentResponse sendMessage(Content content)Sends a message to the model and returns a response.
| Parameter | |
|---|---|
| Name | Description |
content |
Contentthe content to be sent. |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a response. |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
sendMessage(String text) (deprecated)
public GenerateContentResponse sendMessage(String text)Sends a message to the model and returns a response.
| Parameter | |
|---|---|
| Name | Description |
text |
Stringthe message to be sent. |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a response. |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
sendMessageStream(Content content) (deprecated)
public ResponseStream<GenerateContentResponse> sendMessageStream(Content content)Sends a message to the model and returns a stream of responses.
| Parameter | |
|---|---|
| Name | Description |
content |
Contentthe content to be sent. |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
an iterable in which each element is a GenerateContentResponse. Can be converted to stream by stream() method. |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
sendMessageStream(String text) (deprecated)
public ResponseStream<GenerateContentResponse> sendMessageStream(String text)Sends a message to the model and returns a stream of responses.
| Parameter | |
|---|---|
| Name | Description |
text |
Stringthe message to be sent. |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
an iterable in which each element is a GenerateContentResponse. Can be converted to stream by stream() method. |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
setHistory(List<Content> history) (deprecated)
public void setHistory(List<Content> history)Sets the history to a list of Content.
| Parameter | |
|---|---|
| Name | Description |
history |
List<Content>A list of Content containing interleaving conversation between "user" and "model". |
withAutomaticFunctionCallingResponder(AutomaticFunctionCallingResponder automaticFunctionCallingResponder) (deprecated)
public ChatSession withAutomaticFunctionCallingResponder(AutomaticFunctionCallingResponder automaticFunctionCallingResponder)Creates a copy of the current ChatSession with updated AutomaticFunctionCallingResponder.
| Parameter | |
|---|---|
| Name | Description |
automaticFunctionCallingResponder |
AutomaticFunctionCallingResponderan AutomaticFunctionCallingResponder instance that will be used in the new ChatSession. |
| Returns | |
|---|---|
| Type | Description |
ChatSession |
a new ChatSession instance with the specified AutomaticFunctionCallingResponder. |
withGenerationConfig(GenerationConfig generationConfig) (deprecated)
public ChatSession withGenerationConfig(GenerationConfig generationConfig)Creates a copy of the current ChatSession with updated GenerationConfig.
| Parameter | |
|---|---|
| Name | Description |
generationConfig |
GenerationConfiga com.google.cloud.vertexai.api.GenerationConfig that will be used in the new ChatSession. |
| Returns | |
|---|---|
| Type | Description |
ChatSession |
a new ChatSession instance with the specified GenerationConfig. |
withSafetySettings(List<SafetySetting> safetySettings) (deprecated)
public ChatSession withSafetySettings(List<SafetySetting> safetySettings)Creates a copy of the current ChatSession with updated SafetySettings.
| Parameter | |
|---|---|
| Name | Description |
safetySettings |
List<SafetySetting>a com.google.cloud.vertexai.api.SafetySetting that will be used in the new ChatSession. |
| Returns | |
|---|---|
| Type | Description |
ChatSession |
a new ChatSession instance with the specified SafetySettings. |
withSystemInstruction(Content systemInstruction) (deprecated)
public ChatSession withSystemInstruction(Content systemInstruction)Creates a copy of the current ChatSession with updated SystemInstruction.
| Parameter | |
|---|---|
| Name | Description |
systemInstruction |
Contenta com.google.cloud.vertexai.api.Content containing system instructions. |
| Returns | |
|---|---|
| Type | Description |
ChatSession |
a new ChatSession instance with the specified ToolConfigs. |
withToolConfig(ToolConfig toolConfig) (deprecated)
public ChatSession withToolConfig(ToolConfig toolConfig)Creates a copy of the current ChatSession with updated ToolConfig.
| Parameter | |
|---|---|
| Name | Description |
toolConfig |
ToolConfiga com.google.cloud.vertexai.api.ToolConfig that will be used in the new ChatSession. |
| Returns | |
|---|---|
| Type | Description |
ChatSession |
a new ChatSession instance with the specified ToolConfigs. |
withTools(List<Tool> tools) (deprecated)
public ChatSession withTools(List<Tool> tools)Creates a copy of the current ChatSession with updated Tools.
| Parameter | |
|---|---|
| Name | Description |
tools |
List<Tool>a com.google.cloud.vertexai.api.Tool that will be used in the new ChatSession. |
| Returns | |
|---|---|
| Type | Description |
ChatSession |
a new ChatSession instance with the specified Tools. |