Closed davidvonthenen closed 1 month ago
[!CAUTION]
Review failed
The head commit changed during the review from e0ad551bc5fbd94c1d73448d8650526fa98dbd90 to 4c9c63972d9a2c034c068669453569c6966e514a.
The changes involve enhancements to the deepgram
library, focusing on optional typing for class attributes, improved error handling in WebSocket connections, and the introduction of new abstract classes for managing WebSocket communications. The modifications also include restructured import statements for better organization and clarity across various modules. New exception classes have been added to handle specific API errors, enhancing the overall robustness of the error management system.
Files | Change Summary |
---|---|
deepgram/audio/speaker/speaker.py |
Introduced optional typing for class attributes and enhanced error handling in _start_asyncio_receiver . Updated finish method to check for thread existence before joining. |
deepgram/clients/__init__.py |
Reorganized import statements for better readability. |
deepgram/clients/analyze/v1/async_client.py |
Modified import paths for AbstractAsyncRestClient , DeepgramError , and DeepgramTypeError to simplify the module structure. |
deepgram/clients/analyze/v1/client.py |
Changed import paths for AbstractSyncRestClient , DeepgramError , and DeepgramTypeError to improve clarity and maintainability. |
deepgram/clients/common/__init__.py |
Added new imports for DeepgramApiError , DeepgramUnknownApiError , and several abstract client classes, enhancing error handling and client abstractions. |
deepgram/clients/common/v1/__init__.py |
Introduced imports for new error classes and abstract client classes, expanding functionality. |
deepgram/clients/common/v1/abstract_async_websocket.py |
Added AbstractAsyncWebSocketClient class with methods for managing WebSocket connections asynchronously, including error handling and message processing. |
deepgram/clients/common/v1/abstract_sync_websocket.py |
Introduced AbstractSyncWebSocketClient class for synchronous WebSocket management, featuring methods for connection handling and message processing. |
deepgram/clients/common/v1/errors.py |
Added DeepgramApiError and DeepgramUnknownApiError exception classes to handle specific API-related errors. |
deepgram/clients/listen/v1/rest/async_client.py |
Updated import paths for AbstractAsyncRestClient , DeepgramError , and DeepgramTypeError for consistency. |
deepgram/clients/listen/v1/rest/client.py |
Changed import paths for AbstractSyncRestClient , DeepgramError , and DeepgramTypeError to streamline imports. |
deepgram/clients/listen/v1/websocket/async_client.py |
Refactored AsyncListenWebSocketClient to inherit from AbstractAsyncWebSocketClient , consolidating functionality and simplifying error handling. |
deepgram/clients/listen/v1/websocket/client.py |
Refactored ListenWebSocketClient to inherit from AbstractSyncWebSocketClient , improving structure and message handling. |
deepgram/clients/manage/v1/async_client.py |
Updated import path for AbstractAsyncRestClient to a common module. |
deepgram/clients/manage/v1/client.py |
Changed import path for AbstractSyncRestClient to a common module. |
deepgram/clients/selfhosted/v1/async_client.py |
Updated import path for AbstractAsyncRestClient to a common module. |
deepgram/clients/selfhosted/v1/client.py |
Changed import path for AbstractSyncRestClient to a common module. |
deepgram/clients/speak/v1/rest/async_client.py |
Modified import paths for AbstractAsyncRestClient , DeepgramError , and DeepgramTypeError for consistency. |
deepgram/clients/speak/v1/rest/client.py |
Changed import paths for AbstractSyncRestClient , DeepgramError , and DeepgramTypeError to streamline imports. |
deepgram/clients/speak/v1/websocket/async_client.py |
Refactored AsyncSpeakWSClient to inherit from AbstractAsyncWebSocketClient , enhancing structure and functionality. |
deepgram/clients/speak/v1/websocket/client.py |
Refactored SpeakWSClient to inherit from AbstractSyncWebSocketClient , improving structure and message handling. |
examples/text-to-speech/websocket/async_complete/main.py |
Introduced signal handling for graceful shutdowns and a global variable to control message printing. |
examples/text-to-speech/websocket/complete/main.py |
Added a global variable to manage message printing in the on_binary_data method and modified logging configuration. |
_start_asyncio_receiver
method, enhancing robustness in connection management.Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Unit Tests passed.
Proposed changes
Addresses: https://github.com/deepgram/deepgram-python-sdk/issues/264
This is to make way to support Agent API in a much cleaner and reusable way. It should drastically decrease code spawl.
Tested all Speech-to-Text and Text-to-Speech examples. Basically, anything that uses a WebSocket.
Also, unit tests passed further demonstrating that users should be unaware of this internal change.
Types of changes
What types of changes does your code introduce to the community Python SDK? Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
NA
Summary by CodeRabbit
New Features
AbstractAsyncWebSocketClient
andAbstractSyncWebSocketClient
).DeepgramApiError
andDeepgramUnknownApiError
.Improvements
Bug Fixes