agentchat.realtime_agent.oai_realtime_client
OpenAIRealtimeClient
(Experimental) Client for OpenAI Realtime API.
__init__
(Experimental) Client for OpenAI Realtime API.
Arguments:
llm_config
dict[str, Any] - The config for the client.
logger
Get the logger for the OpenAI Realtime API.
connection
Get the OpenAI WebSocket connection.
send_function_result
Send the result of a function call to the OpenAI Realtime API.
Arguments:
call_id
str - The ID of the function call.result
str - The result of the function call.
send_text
Send a text message to the OpenAI Realtime API.
Arguments:
role
str - The role of the message.text
str - The text of the message.
send_audio
Send audio to the OpenAI Realtime API.
Arguments:
audio
str - The audio to send.
truncate_audio
Truncate audio in the OpenAI Realtime API.
Arguments:
audio_end_ms
int - The end of the audio to truncate.content_index
int - The index of the content to truncate.item_id
str - The ID of the item to truncate.
session_update
Send a session update to the OpenAI Realtime API.
Arguments:
session_options
dict[str, Any] - The session options to update.
connect
Connect to the OpenAI Realtime API.
read_events
Read messages from the OpenAI Realtime API.
OpenAIRealtimeWebRTCClient
(Experimental) Client for OpenAI Realtime API that uses WebRTC protocol.
__init__
(Experimental) Client for OpenAI Realtime API.
Arguments:
llm_config
dict[str, Any] - The config for the client.
logger
Get the logger for the OpenAI Realtime API.
send_function_result
Send the result of a function call to the OpenAI Realtime API.
Arguments:
call_id
str - The ID of the function call.result
str - The result of the function call.
send_text
Send a text message to the OpenAI Realtime API.
Arguments:
role
str - The role of the message.text
str - The text of the message.
send_audio
Send audio to the OpenAI Realtime API.
Arguments:
audio
str - The audio to send.
truncate_audio
Truncate audio in the OpenAI Realtime API.
Arguments:
audio_end_ms
int - The end of the audio to truncate.content_index
int - The index of the content to truncate.item_id
str - The ID of the item to truncate.
session_update
Send a session update to the OpenAI Realtime API.
In the case of WebRTC we can not send it directly, but we can send it to the javascript over the websocket, and rely on it to send session update to OpenAI
Arguments:
session_options
dict[str, Any] - The session options to update.
connect
Connect to the OpenAI Realtime API.
In the case of WebRTC, we pass connection information over the websocket, so that javascript on the other end of websocket open actual connection to OpenAI
read_events
Read messages from the OpenAI Realtime API. Again, in case of WebRTC, we do not read OpenAI messages directly since we do not hold connection to OpenAI. Instead we read messages from the websocket, and javascript client on the other side of the websocket that is connected to OpenAI is relaying events to us.