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 設定
Model 字串
參數 StartChatParams | 未定義
requestOptions RequestOptions | 未定義

ChatSession.model

簽名:

model: string;

ChatSession.params

簽名:

params?: StartChatParams | undefined;

ChatSession.requestOptions

簽名:

requestOptions?: RequestOptions | undefined;

ChatSession.getHistory()

取得目前為止的即時通訊記錄。已封鎖的提示不會新增至記錄中。封鎖的候選項目不會新增至記錄,也不會加入產生這些候選項目的提示。

簽名:

getHistory(): Promise<Content[]>;

傳回:

Promise<內容[]>

ChatSession.sendMessage()

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

簽名:

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

參數

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

傳回:

Promise<GenerateContentResult>

ChatSession.sendMessageStream()

傳送即時通訊訊息,並以 GenerateContentStreamResult 表示回應,其中包含可疊代串流和回應保證。

簽名:

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

參數

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

傳回:

Promise<GenerateContentStreamResult>