Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[5/n] OpenAI realtime transport impl #1072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2025
Merged

[5/n] OpenAI realtime transport impl #1072

merged 2 commits into from
Jul 11, 2025

Conversation

rm-openai
Copy link
Collaborator

@rm-openai rm-openai commented Jul 11, 2025

Uses the openai realtime impl over websockets. Unlike the TS version, only supports websockets - no in browser stuff.


rm-openai added a commit that referenced this pull request Jul 11, 2025
Similar to the TS version.
- Config is the things you can set on the session
- Items are similar to responses items. I'm using an abstraction instead
of reusing the ones in the openai SDK, to reduce the amount of work for
other providers



---
[//]: # (BEGIN SAPLING FOOTER)
* #1074
* #1073
* #1072
* #1071
* __->__ #1070
* #1069
* #1068
@rm-openai rm-openai force-pushed the rm/pr1071 branch 2 times, most recently from 9904b08 to 572eb7d Compare July 11, 2025 17:13
rm-openai added a commit that referenced this pull request Jul 11, 2025
Transport interface for actually connecting to the backend and managing
realtime conversations. The transport emits events.






---
[//]: # (BEGIN SAPLING FOOTER)
* #1074
* #1073
* #1072
* __->__ #1071
Base automatically changed from rm/pr1070 to main July 11, 2025 17:19
model: NotRequired[str]
"""The model to use."""

url: NotRequired[str]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit too specific to OpenAI to be a part of abstraction. Or should be documented differently.

pass

@abc.abstractmethod
async def send_event(self, event: RealtimeClientMessage) -> None:
Copy link
Contributor

@pakrym-oai pakrym-oai Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this method public? I assume the message is very specific to the underlying transport.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that you can send events that aren't necessarily public. Helps with custom implementations, as well as with our own realtime evolving quickly


await self._cancel_response()

elapsed_time_ms = (datetime.now() - self._audio_start_time).total_seconds() * 1000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why round to seconds here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not rounding. python mostly uses seconds for everything (it's stored as a float not an int so doesnt lose precision)

@rm-openai rm-openai merged commit 8b7d862 into main Jul 11, 2025
15 checks passed
@rm-openai rm-openai deleted the rm/pr1071 branch July 11, 2025 19:12
rm-openai added a commit that referenced this pull request Jul 11, 2025
RealtimeSession is like Runner, except for Realtime. It's also stateful
and manages the conversation for you.







---
[//]: # (BEGIN SAPLING FOOTER)
* #1076
* #1074
* __->__ #1073
* #1072
* #1071
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants