Skip to content

Conversation

@lukeocodes
Copy link
Contributor

This PR contains regenerations that includes major rewrites of all WebSocket components in the Deepgram Python SDK. The changes take further steps to automating all parts of the SDK, including the WebSocket implementation with a fully type-safe, generated codebase aligned with the latest API definitions.


Note: This regeneration aligns the SDK with the latest API definitions and sets the foundation for future improvements. The WebSocket rewrite provides a more robust, type-safe, and maintainable codebase.

@lukeocodes lukeocodes requested a review from Copilot December 12, 2025 19:42
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 12, 2025

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

189 files out of 299 files are above the max files limit of 100. Please upgrade to Pro plan to get higher limits.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lo/v5-5-regen

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a major refactor of the Deepgram Python SDK, regenerating WebSocket components with a Fern-generated architecture to provide improved type safety and API alignment. The changes include removal of custom-maintained WebSocket types, telemetry infrastructure, and HTTP/client utilities in favor of auto-generated implementations.

Key Changes

  • Complete removal of manually maintained WebSocket message types and event classes across Listen V1/V2, Speak V1, and Agent V1 APIs
  • Deletion of telemetry infrastructure including batching handlers, protocol encoders, and instrumentation layers
  • Removal of custom HTTP client wrappers and DeepgramClient implementations
  • Addition of new SSE (Server-Sent Events) support with EventSource implementation
  • Updates to HTTP retry logic with improved backoff strategies and rate limit handling

Reviewed changes

Copilot reviewed 294 out of 500 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/deepgram/extensions/types/sockets/*.py Removed 23+ manually maintained WebSocket type files for Listen V1/V2, Speak V1, and Agent V1
src/deepgram/extensions/telemetry/*.py Deleted telemetry infrastructure including handlers, encoders, and models
src/deepgram/extensions/core/*.py Removed HTTP/WebSocket instrumentation and telemetry event capture
src/deepgram/client.py Deleted custom DeepgramClient and AsyncDeepgramClient implementations
src/deepgram/core/http_client.py Enhanced retry logic with improved backoff, jitter, and rate limit handling
src/deepgram/core/client_wrapper.py Updated SDK version to 5.3.1 and added async token support
src/deepgram/core/http_sse/*.py Added new SSE support with EventSource, decoders, and charset handling
src/deepgram/agent/v1/types/*.py Added 100+ auto-generated Agent V1 type files
src/deepgram/core/pydantic_utilities.py Fixed RootModel validator mode for Pydantic v2 compatibility

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +73 to +76
def _add_symmetric_jitter(delay: float) -> float:
"""Add symmetric jitter (±10%) for exponential backoff."""
jitter_multiplier = 1 + (random() - 0.5) * JITTER_FACTOR
return delay * jitter_multiplier
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The docstring states "±10%" but the implementation uses JITTER_FACTOR (0.2), which produces ±20% jitter when centered at 0.5. Update the docstring to "±20%" to match the actual behavior, or adjust the implementation if ±10% was intended.

Copilot uses AI. Check for mistakes.


def _add_positive_jitter(delay: float) -> float:
"""Add positive jitter (0-20%) to prevent thundering herd."""
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The docstring correctly states "0-20%" jitter which matches the implementation using JITTER_FACTOR (0.2). However, consider clarifying that this adds jitter in the range [delay, delay * 1.2] for precision.

Suggested change
"""Add positive jitter (0-20%) to prevent thundering herd."""
"""
Add positive jitter (0-20%) to prevent thundering herd.
The returned value will be in the range [delay, delay * 1.2].
"""

Copilot uses AI. Check for mistakes.
- Fix test_listen_v1_media to pass required request parameter to transcribe_file
- Fix test_speak_v1_audio to consume iterator returned by generate()
- Add client.py to fernignore (custom access_token and session ID support)
- Add wire test files to fernignore (test implementation fixes)
- Improve comments with clear explanations for each protected file
Add telemetry_opt_out and telemetry_handler parameters to DeepgramClient
and AsyncDeepgramClient to maintain API compatibility with main branch
signature. These parameters are accepted but ignored (no-op) to avoid
requiring changes to generated SDK files while maintaining backwards
compatibility.
lukeocodes and others added 16 commits December 15, 2025 09:27
- Add tests/manual to .fernignore
- Add .pytest_cache/ and .env to .gitignore
Update send_listen_v_1_media, send_listen_v_2_media, and send_agent_v_1_media
methods to accept bytes instead of str. Change internal implementation to use
_send() instead of _send_model() to properly handle binary audio data.
Add socket client files to .fernignore with detailed comments explaining
the manual fixes for binary audio data support. These files must be manually
maintained because the generator incorrectly types media methods as str and
uses _send_model() which fails on binary data.
Replace direct calls to private _send() method with public send_listen_v_1_media
and send_listen_v_2_media methods in manual test files.
Add comprehensive WebSocket API reference documentation covering Listen V1,
Listen V2, Speak V1, and Agent V1. Document method signatures, message types,
event types, and usage examples for both sync and async clients. Update all
media method examples to show binary data usage.
Rescue release-please setup from main branch for automated releases
- Add matrix strategy for Python 3.8-3.13
- Update setup-python action to v6
- Change mypy path to src/
- Add Docker verification step for WireMock tests
- Update publish job to use POETRY_PYPI_TOKEN_PYPI
Add commitlint-based PR title validation to enforce conventional commits
- Add changelog-log workflow for webhook notifications
- Add tests-daily workflow for scheduled test runs
Rescue migration documentation for v2-to-v3 and v3-to-v5 migrations
- Add 22 example files covering all major SDK functionality
- Include authentication, transcription, TTS, voice agent, management API examples
- Add fixtures directory with sample audio files
- Add README.md with categorized examples and usage instructions
- Add requirements.txt for example dependencies
- Examples demonstrate streaming, error handling, and best practices
- All examples validated against actual client functionality
- Fix import ordering (ruff isort)
- Remove trailing whitespace
- Remove trailing blank lines
- Format code according to project standards
@lukeocodes lukeocodes changed the title refactor!: SDK release with new Fern generated architecture refactor!: sdk release with new fern generated architecture Dec 17, 2025
Add datetime wrapper in tests/wire/__init__.py to handle 'Z' suffix
for Python 3.8-3.10 compatibility. Python 3.10's datetime.fromisoformat()
doesn't support 'Z' suffix (added in 3.11), so we convert 'Z' to '+00:00'
automatically when the wire tests module is imported.

This allows generated test files to use datetime.fromisoformat('2024-01-15T09:30:00Z')
without modification, ensuring compatibility across all supported Python versions.

The wrapper class inherits from the original datetime class, so all other
datetime functionality remains unchanged.
Document the Python 3.8-3.10 datetime.fromisoformat compatibility fix
that patches datetime.datetime.fromisoformat() to handle 'Z' suffix in
ISO 8601 strings. This allows generated wire test files to work across
all supported Python versions without modification.
Update version in pyproject.toml and SDK headers (User-Agent and
X-Fern-SDK-Version) to 6.0.0-alpha.2.
- Add poetry to PATH after bootstrap in all jobs (compile, test, publish)
  to ensure poetry commands are available
- Remove unnecessary matrix strategy from publish job - it should run
  once per tag push, not per Python version
Update version in pyproject.toml and SDK headers (User-Agent and
X-Fern-SDK-Version) to 6.0.0-alpha.3.
Replace PYPI_API_TOKEN secret with OIDC authentication using pypa/gh-action-pypi-publish action in both ci.yml and release-please.yml workflows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants