Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/openai/types/realtime/response_audio_delta_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class ResponseAudioDeltaEvent(BaseModel):
response_id: str
"""The ID of the response."""

type: Literal["response.output_audio.delta"]
"""The event type, must be `response.output_audio.delta`."""
type: Literal["response.audio.delta"]
"""The event type, must be `response.audio.delta`."""
4 changes: 2 additions & 2 deletions src/openai/types/realtime/response_audio_done_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class ResponseAudioDoneEvent(BaseModel):
response_id: str
"""The ID of the response."""

type: Literal["response.output_audio.done"]
"""The event type, must be `response.output_audio.done`."""
type: Literal["response.audio.done"]
"""The event type, must be `response.audio.done`."""
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class ResponseAudioTranscriptDeltaEvent(BaseModel):
response_id: str
"""The ID of the response."""

type: Literal["response.output_audio_transcript.delta"]
"""The event type, must be `response.output_audio_transcript.delta`."""
type: Literal["response.audio_transcript.delta"]
"""The event type, must be `response.audio_transcript.delta`."""
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ class ResponseAudioTranscriptDoneEvent(BaseModel):
transcript: str
"""The final transcript of the audio."""

type: Literal["response.output_audio_transcript.done"]
"""The event type, must be `response.output_audio_transcript.done`."""
type: Literal["response.audio_transcript.done"]
"""The event type, must be `response.audio_transcript.done`."""
32 changes: 32 additions & 0 deletions tests/test_realtime_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest

from openai._compat import parse_obj
from openai.types.realtime.response_audio_done_event import ResponseAudioDoneEvent
from openai.types.realtime.response_audio_delta_event import ResponseAudioDeltaEvent
from openai.types.realtime.response_audio_transcript_done_event import ResponseAudioTranscriptDoneEvent
from openai.types.realtime.response_audio_transcript_delta_event import ResponseAudioTranscriptDeltaEvent


@pytest.mark.parametrize(
("model", "event_type", "extra"),
[
(ResponseAudioDeltaEvent, "response.audio.delta", {"delta": "abc"}),
(ResponseAudioDoneEvent, "response.audio.done", {}),
(ResponseAudioTranscriptDeltaEvent, "response.audio_transcript.delta", {"delta": "hello"}),
(ResponseAudioTranscriptDoneEvent, "response.audio_transcript.done", {"transcript": "hello"}),
],
)
def test_realtime_audio_event_type_literals_match_api_events(model: type, event_type: str, extra: dict) -> None:
event = parse_obj(
model,
{
"event_id": "event_1",
"response_id": "resp_1",
"item_id": "item_1",
"output_index": 0,
"content_index": 0,
"type": event_type,
**extra,
},
)
assert event.type == event_type