BetaLiveConnection Class
Send and receive events on a GPT Live connection.
Service errors arrive as error events. Use the context manager to close
the connection. Send session.close to end the session; Live has no
response.cancel command.
Constructor
BetaLiveConnection(connection: ClientConnection)
Parameters
| Name | Description |
|---|---|
|
connection
Required
|
|
Methods
| close |
Close the socket once. |
| recv |
Receive an SDK event model, or a dictionary for an unknown event type. |
| send |
Send an SDK event model, mapping, or JSON string. |
close
recv
Receive an SDK event model, or a dictionary for an unknown event type.
recv(*, timeout: float | None = None) -> LiveServerEvent | Mapping[str, Any]
Keyword-Only Parameters
| Name | Description |
|---|---|
|
timeout
|
Maximum receive wait in seconds; None waits indefinitely. Default value: None
|
Returns
| Type | Description |
|---|---|
|
The server event. |
Exceptions
| Type | Description |
|---|---|
|
On graceful or abnormal socket closure. |
|
|
When the receive deadline expires. |
send
Send an SDK event model, mapping, or JSON string.
send(event: LiveClientEvent | str | Mapping[str, Any]) -> None
Parameters
| Name | Description |
|---|---|
|
event
Required
|
<xref:azure.ai.projects.operations.LiveClientEvent>
The client event. |
Exceptions
| Type | Description |
|---|---|
|
If the supplied JSON string is invalid. |