Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 1.84 KB

generative-ai.chatsession.md

File metadata and controls

36 lines (24 loc) · 1.84 KB

Home > @google/generative-ai > ChatSession

ChatSession class

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

Signature:

export declare class ChatSession 

Constructors

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

Properties

Property Modifiers Type Description
model string
params? StartChatParams (Optional)
requestOptions? RequestOptions (Optional)

Methods

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.