|
| 1 | +Project: /docs/reference/js/_project.yaml |
| 2 | +Book: /docs/reference/_book.yaml |
| 3 | +page_type: reference |
| 4 | + |
| 5 | +{% comment %} |
| 6 | +DO NOT EDIT THIS FILE! |
| 7 | +This is generated by the JS SDK team, and any local changes will be |
| 8 | +overwritten. Changes should be made in the source code at |
| 9 | +https://github.com/firebase/firebase-js-sdk |
| 10 | +{% endcomment %} |
| 11 | + |
| 12 | +# ChatSession class |
| 13 | +ChatSession class that enables sending chat messages and stores history of sent and received messages so far. |
| 14 | + |
| 15 | +<b>Signature:</b> |
| 16 | + |
| 17 | +```typescript |
| 18 | +export declare class ChatSession |
| 19 | +``` |
| 20 | + |
| 21 | +## Constructors |
| 22 | + |
| 23 | +| Constructor | Modifiers | Description | |
| 24 | +| --- | --- | --- | |
| 25 | +| [(constructor)(apiSettings, model, params, requestOptions)](./vertexai-preview.chatsession.md#chatsessionconstructor) | | Constructs a new instance of the <code>ChatSession</code> class | |
| 26 | + |
| 27 | +## Properties |
| 28 | + |
| 29 | +| Property | Modifiers | Type | Description | |
| 30 | +| --- | --- | --- | --- | |
| 31 | +| [model](./vertexai-preview.chatsession.md#chatsessionmodel) | | string | | |
| 32 | +| [params](./vertexai-preview.chatsession.md#chatsessionparams) | | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) \| undefined | | |
| 33 | +| [requestOptions](./vertexai-preview.chatsession.md#chatsessionrequestoptions) | | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) \| undefined | | |
| 34 | + |
| 35 | +## Methods |
| 36 | + |
| 37 | +| Method | Modifiers | Description | |
| 38 | +| --- | --- | --- | |
| 39 | +| [getHistory()](./vertexai-preview.chatsession.md#chatsessiongethistory) | | 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. | |
| 40 | +| [sendMessage(request)](./vertexai-preview.chatsession.md#chatsessionsendmessage) | | Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) | |
| 41 | +| [sendMessageStream(request)](./vertexai-preview.chatsession.md#chatsessionsendmessagestream) | | Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. | |
| 42 | + |
| 43 | +## ChatSession.(constructor) |
| 44 | + |
| 45 | +Constructs a new instance of the `ChatSession` class |
| 46 | + |
| 47 | +<b>Signature:</b> |
| 48 | + |
| 49 | +```typescript |
| 50 | +constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); |
| 51 | +``` |
| 52 | + |
| 53 | +#### Parameters |
| 54 | + |
| 55 | +| Parameter | Type | Description | |
| 56 | +| --- | --- | --- | |
| 57 | +| apiSettings | ApiSettings | | |
| 58 | +| model | string | | |
| 59 | +| params | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) \| undefined | | |
| 60 | +| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) \| undefined | | |
| 61 | + |
| 62 | +## ChatSession.model |
| 63 | + |
| 64 | +<b>Signature:</b> |
| 65 | + |
| 66 | +```typescript |
| 67 | +model: string; |
| 68 | +``` |
| 69 | + |
| 70 | +## ChatSession.params |
| 71 | + |
| 72 | +<b>Signature:</b> |
| 73 | + |
| 74 | +```typescript |
| 75 | +params?: StartChatParams | undefined; |
| 76 | +``` |
| 77 | + |
| 78 | +## ChatSession.requestOptions |
| 79 | + |
| 80 | +<b>Signature:</b> |
| 81 | + |
| 82 | +```typescript |
| 83 | +requestOptions?: RequestOptions | undefined; |
| 84 | +``` |
| 85 | + |
| 86 | +## ChatSession.getHistory() |
| 87 | + |
| 88 | +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. |
| 89 | + |
| 90 | +<b>Signature:</b> |
| 91 | + |
| 92 | +```typescript |
| 93 | +getHistory(): Promise<Content[]>; |
| 94 | +``` |
| 95 | +<b>Returns:</b> |
| 96 | + |
| 97 | +Promise<[Content](./vertexai-preview.content.md#content_interface)<!-- -->\[\]> |
| 98 | + |
| 99 | +## ChatSession.sendMessage() |
| 100 | + |
| 101 | +Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) |
| 102 | + |
| 103 | +<b>Signature:</b> |
| 104 | + |
| 105 | +```typescript |
| 106 | +sendMessage(request: string | Array<string | Part>): Promise<GenerateContentResult>; |
| 107 | +``` |
| 108 | + |
| 109 | +#### Parameters |
| 110 | + |
| 111 | +| Parameter | Type | Description | |
| 112 | +| --- | --- | --- | |
| 113 | +| request | string \| Array<string \| [Part](./vertexai-preview.md#part)<!-- -->> | | |
| 114 | + |
| 115 | +<b>Returns:</b> |
| 116 | + |
| 117 | +Promise<[GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface)<!-- -->> |
| 118 | + |
| 119 | +## ChatSession.sendMessageStream() |
| 120 | + |
| 121 | +Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. |
| 122 | + |
| 123 | +<b>Signature:</b> |
| 124 | + |
| 125 | +```typescript |
| 126 | +sendMessageStream(request: string | Array<string | Part>): Promise<GenerateContentStreamResult>; |
| 127 | +``` |
| 128 | + |
| 129 | +#### Parameters |
| 130 | + |
| 131 | +| Parameter | Type | Description | |
| 132 | +| --- | --- | --- | |
| 133 | +| request | string \| Array<string \| [Part](./vertexai-preview.md#part)<!-- -->> | | |
| 134 | + |
| 135 | +<b>Returns:</b> |
| 136 | + |
| 137 | +Promise<[GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface)<!-- -->> |
| 138 | + |
0 commit comments