Files

4.8 KiB

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

ChatSession class that enables sending chat messages and stores history of sent and received messages so far.

Signature:

export declare class ChatSession extends ChatSessionBase<StartChatParams, GenerateContentRequest, FunctionDeclarationsTool> 

Extends: ChatSessionBase<StartChatParams, GenerateContentRequest, FunctionDeclarationsTool>

Constructors

Constructor Modifiers Description
(constructor)(apiSettings, model, chromeAdapter, params, requestOptions) Constructs a new instance of the ChatSession class

Properties

Property Modifiers Type Description
model string
params StartChatParams | undefined
requestOptions RequestOptions | undefined

Methods

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.

ChatSession.(constructor)

Constructs a new instance of the ChatSession class

Signature:

constructor(apiSettings: ApiSettings, model: string, chromeAdapter?: ChromeAdapter | undefined, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);

Parameters

Parameter Type Description
apiSettings ApiSettings
model string
chromeAdapter ChromeAdapter | undefined
params StartChatParams | undefined
requestOptions RequestOptions | undefined

ChatSession.model

Signature:

model: string;

ChatSession.params

Signature:

params?: StartChatParams | undefined;

ChatSession.requestOptions

Signature:

requestOptions?: RequestOptions | undefined;

ChatSession.sendMessage()

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>

ChatSession.sendMessageStream()

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>