docs-devsite/ai.templatechatsession.md
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 %}
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>
export interface TemplateChatSession
| Property | Type | Description |
|---|---|---|
| params | StartTemplateChatParams | <b><i>(Public Preview)</i></b> |
| requestOptions | RequestOptions | <b><i>(Public Preview)</i></b> |
| Method | Description |
|---|---|
| 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. |
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>
params: StartTemplateChatParams;
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>
requestOptions?: 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.
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>
getHistory(): Promise<Content[]>;
<b>Returns:</b>
Promise<Content<!-- -->[]>
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>
sendMessage(request: string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;
| Parameter | Type | Description |
|---|---|---|
| request | string | Array<string | Part<!-- -->> | |
| singleRequestOptions | SingleRequestOptions |
<b>Returns:</b>
Promise<GenerateContentResult<!-- -->>
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>
sendMessageStream(request: string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;
| Parameter | Type | Description |
|---|---|---|
| request | string | Array<string | Part<!-- -->> | |
| singleRequestOptions | SingleRequestOptions |
<b>Returns:</b>
Promise<GenerateContentStreamResult<!-- -->>