Python middlewares over the WebSocket of OpenAI Realtime API.
Project description
OpenAI Realtime API Python Utils
If you want to base your application/agent on OpenAI's realtime api, but:
- OpenAI's
agentsSDK makes too many assumptions, openai.resources.realtimeis too low-level,
then this package is for you.
Example
- See the example at ./tests/test_middlewares.py
with hook_handlers(
connection,
server_event_handlers = [
track_config.server_event_handler, # views session.updated
track_conversation.server_event_handler, # views various events
*iap_server_handlers, # views e.g. response.output_audio.delta
stream_mic.server_event_handler, # views session.updated
print_events.server_event_handler, # views all events
f,
],
client_event_handlers = [
middlewares.GiveClientEventId().client_event_handler, # alter all events without ID
track_config.client_event_handler, # views session.update
track_conversation.client_event_handler, # views various events
print_events.client_event_handler, # views all events
],
) as (keep_receiving, send):
iap_register_send_with_handlers(send) # needs to send interrupt events
stream_mic.register_send_with_handlers(send) # needs to send audio input
asyncio.create_task(keep_receiving())
...
Utilities & Middlewares
openai_realtime_api_utils.hook_handlers: run a session with your handlers.openai_realtime_api_utils.middlewares.TrackConfig: Keep track of session config..TrackConversation: Client-side representation of the conversation(s), synced by events..GiveClientEventId: Auto-fill client event id..Interrupt: The user may interrupt assistant speech..AudioPlayer: Host system audio playback..interruptable_audio_player:.Interruptand.AudioPlayerin gift wraps..StreamMic: Host system audio capture..PrintEvents: Print events for debug.
Style
- Functional programming.
- Dependency injection.
- Middleware event handlers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openai_realtime_api_utils-0.1.2.tar.gz.
File metadata
- Download URL: openai_realtime_api_utils-0.1.2.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
221615a196a54aed92afd09a957464195830640bc1fcd0b2592372b680a4e45a
|
|
| MD5 |
080ca3ca065b935a26a6b855921f9d62
|
|
| BLAKE2b-256 |
7c2b003e37d2bb31c9266f2cbd5bd6f5ecdc0e4df5261c354d2a7a3b84cdd52c
|
File details
Details for the file openai_realtime_api_utils-0.1.2-py3-none-any.whl.
File metadata
- Download URL: openai_realtime_api_utils-0.1.2-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1495bb8213dbbd7ad0d59337db5c2daf39d86a663cf830262f05d188a41de9dd
|
|
| MD5 |
71f4ce8567e3b4d9cd0f959ee3a66479
|
|
| BLAKE2b-256 |
70385e355508346ab2ce3011c0c6d6d88ea2efa0a5c8d2b4a96fdf44be233531
|