ChatSession class

能傳送即時通訊訊息,以及儲存目前收發訊息記錄的 ChatSession 類別。

簽名:

export declare class ChatSession 

建構函式

建構函式 修飾符 說明
(buildor)(apiSettings, model, params, requestOptions) 建構 ChatSession 類別的新例項

屬性

屬性 修飾符 類型 說明
模型 字串
參數 StartChatParams |未定義
requestOptions RequestOptions:未定義

方法

方法 修飾符 說明
getHistory() 取得目前為止的即時通訊記錄。已封鎖的提示不會加入記錄。系統未封鎖的候選人和產生這些候選人的提示也不會新增到記錄中。
sendMessage(要求) 傳送即時通訊訊息並接收非串流的 GenerateContentResult
sendMessageStream(要求) 傳送即時通訊訊息,並以 GenerateContentStreamResult 格式收到回應,內含可疊代串流和回應承諾。

ChatSession.(建構函式)

建構 ChatSession 類別的新例項

簽名:

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

參數

參數 類型 說明
API 設定 API 設定
模型 字串
參數 StartChatParams |未定義
requestOptions RequestOptions:未定義

ChatSession.model

簽名:

model: string;

ChatSession.params

簽名:

params?: StartChatParams | undefined;

ChatSession.requestOptions

簽名:

requestOptions?: RequestOptions | undefined;

ChatSession.getHistory()

取得目前為止的即時通訊記錄。已封鎖的提示不會加入記錄。系統未封鎖的候選人和產生這些候選人的提示也不會新增到記錄中。

簽名:

getHistory(): Promise<Content[]>;

傳回:

承諾<內容[]>

ChatSession.sendMessage()

傳送即時通訊訊息並接收非串流的 GenerateContentResult

簽名:

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

參數

參數 類型 說明
要求 字串 |陣列<字串 |零件>

傳回:

承諾<GenerateContentResult>

ChatSession.sendMessageStream()

傳送即時通訊訊息,並以 GenerateContentStreamResult 格式收到回應,內含可疊代串流和回應承諾。

簽名:

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

參數

參數 類型 說明
要求 字串 |陣列<字串 |零件>

傳回:

Promise<GenerateContentStreamResult>