VoiceAgentConnection interface

一個連接的雙向語音代理串流。

支援伺服器事件的 for await 一次迭代;第二次嘗試則會丟棄。 提前退出迴路(break或 return迴路體未被捕捉的錯誤)會作為副作用關閉連接。 未識別的伺服器事件類型以 VoiceAgentUnknownEvent 形式傳送,且不會中斷串流。 畸形事件仍會因協議錯誤而失敗。

Extends

AsyncIterable<VoiceAgentRealtimeEvent>

屬性

closed

連線關閉後問題會解決。

state

目前連線狀態。

方法

cancelResponse(VoiceAgentCancelResponseOptions)

取消正在進行中的回應。

clearInputAudio(VoiceAgentEventOptions)

清除緩衝的輸入音訊。

clearOutputAudio(VoiceAgentEventOptions)

在禮拜時清除待處理的音訊。

close(number, string)

優雅地關閉 WebSocket 連線。

commitAudio(VoiceAgentEventOptions)

提交緩衝的輸入音訊。

configureSession(VoiceAgentSessionUpdateConfig, VoiceAgentSessionUpdateOptions)

更新支援即時會話設定。

dispose()

這樣就能解除連結。 等價於 close()。

requestResponse(VoiceAgentResponseOptions)

請求新的回應。

sendAudio(ArrayBuffer | Uint8Array, VoiceAgentEventOptions)

將 base64 編碼的音訊位元組附加到輸入緩衝區。

sendEvent(VoiceAgentClientEvent, VoiceAgentSendOptions)

傳送任何產生的客戶端協定事件。

sendText(string, VoiceAgentSendTextOptions)

新增使用者文字項目,並預設要求回應。

sendToolOutput(string, string, VoiceAgentSendToolOutputOptions)

回傳客戶端執行的函式結果給代理。

繼承的方法

[asyncIterator]()

屬性詳細資料

closed

連線關閉後問題會解決。

closed: Promise<VoiceAgentCloseResult>

屬性值

state

目前連線狀態。

state: VoiceAgentConnectionState

屬性值

方法詳細資料

cancelResponse(VoiceAgentCancelResponseOptions)

取消正在進行中的回應。

function cancelResponse(options?: VoiceAgentCancelResponseOptions): Promise<void>

參數

傳回

Promise<void>

clearInputAudio(VoiceAgentEventOptions)

清除緩衝的輸入音訊。

function clearInputAudio(options?: VoiceAgentEventOptions): Promise<void>

參數

傳回

Promise<void>

clearOutputAudio(VoiceAgentEventOptions)

在禮拜時清除待處理的音訊。

function clearOutputAudio(options?: VoiceAgentEventOptions): Promise<void>

參數

傳回

Promise<void>

close(number, string)

優雅地關閉 WebSocket 連線。

function close(code?: number, reason?: string): Promise<void>

參數

code

number

reason

string

傳回

Promise<void>

commitAudio(VoiceAgentEventOptions)

提交緩衝的輸入音訊。

function commitAudio(options?: VoiceAgentEventOptions): Promise<void>

參數

傳回

Promise<void>

configureSession(VoiceAgentSessionUpdateConfig, VoiceAgentSessionUpdateOptions)

更新支援即時會話設定。

function configureSession(session: VoiceAgentSessionUpdateConfig, options?: VoiceAgentSessionUpdateOptions): Promise<void>

參數

傳回

Promise<void>

dispose()

這樣就能解除連結。 等價於 close()。

function dispose(): Promise<void>

傳回

Promise<void>

requestResponse(VoiceAgentResponseOptions)

請求新的回應。

function requestResponse(options?: VoiceAgentResponseOptions): Promise<void>

參數

傳回

Promise<void>

sendAudio(ArrayBuffer | Uint8Array, VoiceAgentEventOptions)

將 base64 編碼的音訊位元組附加到輸入緩衝區。

function sendAudio(audio: ArrayBuffer | Uint8Array, options?: VoiceAgentEventOptions): Promise<void>

參數

audio

ArrayBuffer | Uint8Array

傳回

Promise<void>

sendEvent(VoiceAgentClientEvent, VoiceAgentSendOptions)

傳送任何產生的客戶端協定事件。

function sendEvent(event: VoiceAgentClientEvent, options?: VoiceAgentSendOptions): Promise<void>

參數

傳回

Promise<void>

sendText(string, VoiceAgentSendTextOptions)

新增使用者文字項目,並預設要求回應。

function sendText(text: string, options?: VoiceAgentSendTextOptions): Promise<void>

參數

text

string

傳回

Promise<void>

sendToolOutput(string, string, VoiceAgentSendToolOutputOptions)

回傳客戶端執行的函式結果給代理。

function sendToolOutput(callId: string, output: string, options?: VoiceAgentSendToolOutputOptions): Promise<void>

參數

callId

string

output

string

傳回

Promise<void>

繼承的方法的詳細資料

[asyncIterator]()

function [asyncIterator](): AsyncIterator<VoiceAgentRealtimeEvent, any, any>

傳回

AsyncIterator<VoiceAgentRealtimeEvent, any, any>

繼承自 非同步運算者。[非同步運算器]