Class ChatSession (0.2.1)

Chat session to make multi-turn send message request. sendMessage method makes async call to get response of a chat message. sendMessageStream method makes async call to stream response of a chat message.

Package

@google-cloud/vertexai

Constructors

(constructor)(request)

constructor(request: StartChatSessionRequest);

Constructs a new instance of the ChatSession class

Parameter
Name Description
request StartChatSessionRequest

StartChatSessionRequest

Properties

generation_config

generation_config?: GenerationConfig;

history

get history(): Content[];

safety_settings

safety_settings?: SafetySetting[];

Methods

appendHistory(streamGenerateContentResultPromise, newContent)

appendHistory(streamGenerateContentResultPromise: Promise<StreamGenerateContentResult>, newContent: Content): Promise<void>;
Parameters
Name Description
streamGenerateContentResultPromise Promise<StreamGenerateContentResult>
newContent Content
Returns
Type Description
Promise<void>

sendMessage(request)

sendMessage(request: string | Array<string | Part>): Promise<GenerateContentResult>;

Make an sync call to send message.

Parameter
Name Description
request string | Array<string | Part>

send message request. Part {Promise

Returns
Type Description
Promise<GenerateContentResult>

sendMessageStream(request)

sendMessageStream(request: string | Array<string | Part>): Promise<StreamGenerateContentResult>;

Make an async call to stream send message. Response will be returned in stream.

Parameter
Name Description
request string | Array<string | Part>

send message request. Part {Promise

Returns
Type Description
Promise<StreamGenerateContentResult>