Back to Firebase Js Sdk

TemplateChatSession interface

docs-devsite/ai.templatechatsession.md

12.12.15.0 KB
Original Source

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

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.

<b>Signature:</b>

typescript
export interface TemplateChatSession 

Properties

PropertyTypeDescription
paramsStartTemplateChatParams<b><i>(Public Preview)</i></b>
requestOptionsRequestOptions<b><i>(Public Preview)</i></b>

Methods

MethodDescription
getHistory()<b><i>(Public Preview)</i></b> 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)<b><i>(Public Preview)</i></b> Sends a chat message and receives a non-streaming GenerateContentResult
sendMessageStream(request, singleRequestOptions)<b><i>(Public Preview)</i></b> 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.

<b>Signature:</b>

typescript
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.

<b>Signature:</b>

typescript
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.

<b>Signature:</b>

typescript
getHistory(): Promise<Content[]>;

<b>Returns:</b>

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

<b>Signature:</b>

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

Parameters

ParameterTypeDescription
requeststring | Array<string | Part<!-- -->>
singleRequestOptionsSingleRequestOptions

<b>Returns:</b>

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.

<b>Signature:</b>

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

Parameters

ParameterTypeDescription
requeststring | Array<string | Part<!-- -->>
singleRequestOptionsSingleRequestOptions

<b>Returns:</b>

Promise<GenerateContentStreamResult<!-- -->>