TemplateChatSession class

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.

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 declare class TemplateChatSession extends ChatSessionBase<StartTemplateChatParams, TemplateRequestInternal, TemplateFunctionDeclarationsTool> 

Extends: ChatSessionBase<StartTemplateChatParams, TemplateRequestInternal, TemplateFunctionDeclarationsTool>

Constructors

Constructor Modifiers Description
(constructor)(apiSettings, params, requestOptions) (Public Preview) Constructs a new instance of the TemplateChatSession class

Properties

Property Modifiers Type Description
params StartTemplateChatParams (Public Preview)
requestOptions RequestOptions | undefined (Public Preview)

Methods

Method Modifiers Description
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.(constructor)

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.

Constructs a new instance of the TemplateChatSession class

Signature:

constructor(apiSettings: ApiSettings, params: StartTemplateChatParams, requestOptions?: RequestOptions | undefined);

Parameters

Parameter Type Description
apiSettings ApiSettings
params StartTemplateChatParams
requestOptions RequestOptions | undefined

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 | undefined;

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>