docs-devsite/ai.chatsession.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 %}
ChatSession class that enables sending chat messages and stores history of sent and received messages so far.
<b>Signature:</b>
export declare class ChatSession extends ChatSessionBase<StartChatParams, GenerateContentRequest, FunctionDeclarationsTool>
<b>Extends:</b> ChatSessionBase<!-- --><StartChatParams<!-- -->, GenerateContentRequest<!-- -->, FunctionDeclarationsTool<!-- -->>
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(apiSettings, model, chromeAdapter, params, requestOptions) | Constructs a new instance of the <code>ChatSession</code> class |
| Property | Modifiers | Type | Description |
|---|---|---|---|
| model | string | ||
| params | StartChatParams | undefined | ||
| requestOptions | RequestOptions | undefined |
| Method | Modifiers | Description |
|---|---|---|
| sendMessage(request, singleRequestOptions) | Sends a chat message and receives a non-streaming GenerateContentResult | |
| sendMessageStream(request, singleRequestOptions) | Sends a chat message and receives the response as a GenerateContentStreamResult containing an iterable stream and a response promise. |
Constructs a new instance of the ChatSession class
<b>Signature:</b>
constructor(apiSettings: ApiSettings, model: string, chromeAdapter?: ChromeAdapter | undefined, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);
| Parameter | Type | Description |
|---|---|---|
| apiSettings | ApiSettings | |
| model | string | |
| chromeAdapter | ChromeAdapter | undefined | |
| params | StartChatParams | undefined | |
| requestOptions | RequestOptions | undefined |
<b>Signature:</b>
model: string;
<b>Signature:</b>
params?: StartChatParams | undefined;
<b>Signature:</b>
requestOptions?: RequestOptions | undefined;
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<!-- -->>
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<!-- -->>