TemplateChatSession interface

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Interface representing a ChatSession class for use with server prompt templates that enables sending chat messages and stores history of sent and received messages so far.

Signature:

export interface TemplateChatSession 

Properties

Property Type Description
params StartTemplateChatParams (Public Preview)
requestOptions RequestOptions (Public Preview)

Methods

Method Description
getHistory() (Public Preview) Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history.
sendMessage(request, singleRequestOptions) (Public Preview) Sends a chat message and receives a non-streaming GenerateContentResult
sendMessageStream(request, singleRequestOptions) (Public Preview) Sends a chat message and receives the response as a GenerateContentStreamResult containing an iterable stream and a response promise.

TemplateChatSession.params

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

params: StartTemplateChatParams;

TemplateChatSession.requestOptions

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Signature:

requestOptions?: RequestOptions;

TemplateChatSession.getHistory()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history.

Signature:

getHistory(): Promise<Content[]>;

Returns:

Promise<Content[]>

TemplateChatSession.sendMessage()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Sends a chat message and receives a non-streaming GenerateContentResult

Signature:

sendMessage(request: string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;

Parameters

Parameter Type Description
request string | Array<string | Part>
singleRequestOptions SingleRequestOptions

Returns:

Promise<GenerateContentResult>

TemplateChatSession.sendMessageStream()

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Sends a chat message and receives the response as a GenerateContentStreamResult containing an iterable stream and a response promise.

Signature:

sendMessageStream(request: string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;

Parameters

Parameter Type Description
request string | Array<string | Part>
singleRequestOptions SingleRequestOptions

Returns:

Promise<GenerateContentStreamResult>