Home > @google/generative-ai > ChatSession
ChatSession class that enables sending chat messages and stores history of sent and received messages so far.
Signature:
export declare class ChatSession
Constructor | Modifiers | Description |
---|---|---|
(constructor)(apiKey, model, params, requestOptions) | Constructs a new instance of the ChatSession class |
Property | Modifiers | Type | Description |
---|---|---|---|
model | string | ||
params? | StartChatParams | (Optional) | |
requestOptions? | RequestOptions | (Optional) |
Method | Modifiers | Description |
---|---|---|
getHistory() | Gets the chat history so far. Blocked prompts are not added to history. Blocked candidates are not added to history, nor are the prompts that generated them. | |
sendMessage(request) | Sends a chat message and receives a non-streaming GenerateContentResult | |
sendMessageStream(request) | Sends a chat message and receives the response as a GenerateContentStreamResult containing an iterable stream and a response promise. |