-
Notifications
You must be signed in to change notification settings - Fork 115
feat: adds support for agent mip_opt_out #558
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
Conversation
WalkthroughA new optional boolean field Changes
Sequence Diagram(s)sequenceDiagram
participant TestSuite as TestAgentMipOptOut
participant Agent as Agent Dataclass
participant Serializer as Serialization Logic
TestSuite->>Agent: Instantiate Agent (default mip_opt_out)
TestSuite->>Agent: Set mip_opt_out True/False
TestSuite->>Serializer: Serialize Agent to dict/JSON
Serializer-->>TestSuite: Serialized output (mip_opt_out included/excluded)
TestSuite->>Serializer: Deserialize dict/JSON to Agent
Serializer-->>TestSuite: Agent instance with correct mip_opt_out
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Pylint (3.3.7)deepgram/clients/agent/v1/websocket/options.pytests/unit_test/test_unit_agent_mip_opt_out.py✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tests/response_data/speak/rest/1fe0ad339338a9d6cffbab2c7ace41ba5387b5fe7906854795702dce91034fd3-f8c3bf62a9aa3e6fc1619c250e48abe7519373d3edf41be62eb5dc45199af2ef.wavis excluded by!**/*.wav
📒 Files selected for processing (10)
deepgram/clients/agent/v1/websocket/options.py(1 hunks)tests/response_data/listen/rest/a231370d439312b1a404bb6ad8de955e900ec8eae9a906329af8cc672e6ec7ba-29e7c8100617f70da4ae9da1921cb5071a01219f4780ca70930b0a370ed2163a-response.json(1 hunks)tests/response_data/listen/rest/a231370d439312b1a404bb6ad8de955e900ec8eae9a906329af8cc672e6ec7ba-a17f4880c5b4cf124ac54d06d77c9f0ab7f3fe1052ff1c7b090f7eaf8ede5b76-response.json(1 hunks)tests/response_data/listen/rest/c4e1c0031174878d8f0e3dbd87916ee16d56f1c610ac525af5712ea37226a455-29e7c8100617f70da4ae9da1921cb5071a01219f4780ca70930b0a370ed2163a-response.json(1 hunks)tests/response_data/listen/rest/c4e1c0031174878d8f0e3dbd87916ee16d56f1c610ac525af5712ea37226a455-a17f4880c5b4cf124ac54d06d77c9f0ab7f3fe1052ff1c7b090f7eaf8ede5b76-response.json(1 hunks)tests/response_data/listen/websocket/ed5bfd217988aa8cad492f63f79dc59f5f02fb9b85befe6f6ce404b8f19aaa0d-42fc5ed98cabc1fa1a2f276301c27c46dd15f6f5187cd93d944cc94fa81c8469-response.json(1 hunks)tests/response_data/listen/websocket/ed5bfd217988aa8cad492f63f79dc59f5f02fb9b85befe6f6ce404b8f19aaa0d-d7334c26cf6468c191e05ff5e8151da9b67985c66ab177e9446fd14bbafd70df-response.json(1 hunks)tests/response_data/read/rest/3917a1c81c08e360c0d4bba0ff9ebd645e610e4149483e5f2888a2c5df388b37-23e873efdfd4d680286fda14ff8f10864218311e79efc92ecc82bce3e574c366-response.json(1 hunks)tests/response_data/speak/rest/1fe0ad339338a9d6cffbab2c7ace41ba5387b5fe7906854795702dce91034fd3-f8c3bf62a9aa3e6fc1619c250e48abe7519373d3edf41be62eb5dc45199af2ef-response.json(1 hunks)tests/unit_test/test_unit_agent_mip_opt_out.py(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
tests/response_data/speak/rest/1fe0ad339338a9d6cffbab2c7ace41ba5387b5fe7906854795702dce91034fd3-f8c3bf62a9aa3e6fc1619c250e48abe7519373d3edf41be62eb5dc45199af2ef-response.json (3)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:16-17
Timestamp: 2024-10-18T00:30:20.224Z
Learning: In `examples/text-to-speech/websocket/output_to_wav/main.py`, the hardcoded values for `AUDIO_FILE` and `TTS_TEXT` are intentional and should remain as is.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:52-56
Timestamp: 2024-10-18T00:30:04.220Z
Learning: In `examples/text-to-speech/websocket/output_to_wav/main.py`, the code is intended as an example demonstrating functionality, and refactoring suggestions may not be necessary.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:38-41
Timestamp: 2024-10-18T00:30:01.884Z
Learning: In the `examples/text-to-speech/websocket/output_to_wav/main.py` file, the code is intended as a simple example, and additional error handling for file operations is not required.
tests/response_data/listen/websocket/ed5bfd217988aa8cad492f63f79dc59f5f02fb9b85befe6f6ce404b8f19aaa0d-42fc5ed98cabc1fa1a2f276301c27c46dd15f6f5187cd93d944cc94fa81c8469-response.json (1)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:16-17
Timestamp: 2024-10-18T00:30:20.224Z
Learning: In `examples/text-to-speech/websocket/output_to_wav/main.py`, the hardcoded values for `AUDIO_FILE` and `TTS_TEXT` are intentional and should remain as is.
deepgram/clients/agent/v1/websocket/options.py (10)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#431
File: deepgram/clients/listen/v1/websocket/client.py:30-30
Timestamp: 2024-10-09T02:19:46.087Z
Learning: The `LiveOptions` import in `deepgram/clients/listen/v1/websocket/client.py` is intentionally present for future use and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#431
File: deepgram/clients/listen/v1/websocket/client.py:30-30
Timestamp: 2024-07-11T14:10:17.231Z
Learning: The `LiveOptions` import in `deepgram/clients/listen/v1/websocket/client.py` is intentionally present for future use and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#431
File: deepgram/clients/listen/v1/websocket/async_client.py:30-30
Timestamp: 2024-10-09T02:19:46.087Z
Learning: The unused import `LiveOptions` in `deepgram/clients/listen/v1/websocket/async_client.py` is intentional and will be used in PR #432.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#431
File: deepgram/clients/listen/v1/websocket/async_client.py:30-30
Timestamp: 2024-07-11T14:10:24.647Z
Learning: The unused import `LiveOptions` in `deepgram/clients/listen/v1/websocket/async_client.py` is intentional and will be used in PR #432.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/speak/v1/websocket/response.py:23-30
Timestamp: 2024-07-01T19:12:00.190Z
Learning: When using the `dataclasses.field` with default values in the `deepgram/clients/speak/v1/websocket/response.py`, avoid using mutable default arguments. Instead, use `field(default_factory=...)`.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/speak/v1/websocket/response.py:23-30
Timestamp: 2024-10-09T02:19:48.728Z
Learning: When using the `dataclasses.field` with default values in the `deepgram/clients/speak/v1/websocket/response.py`, avoid using mutable default arguments. Instead, use `field(default_factory=...)`.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#468
File: examples/text-to-speech/websocket/complete/main.py:26-30
Timestamp: 2024-09-27T15:21:34.197Z
Learning: In `examples/text-to-speech/websocket/complete/main.py`, commented-out options like `auto_flush_speak_delta` and `verbose` are intentional in examples and should not be flagged in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/websocket/__init__.py:8-8
Timestamp: 2024-10-09T02:19:46.086Z
Learning: Unused imports in `deepgram/clients/listen/v1/websocket/__init__.py` are retained to maintain backward compatibility and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/websocket/__init__.py:8-8
Timestamp: 2024-07-01T19:21:39.778Z
Learning: Unused imports in `deepgram/clients/listen/v1/websocket/__init__.py` are retained to maintain backward compatibility and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/rest/options.py:12-12
Timestamp: 2024-07-01T19:12:36.972Z
Learning: Unused imports in `deepgram/clients/listen/v1/rest/options.py` are retained to maintain backwards compatibility.
tests/unit_test/test_unit_agent_mip_opt_out.py (2)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#417
File: deepgram/clients/live/v1/client.py:14-14
Timestamp: 2024-06-12T18:02:10.651Z
Learning: Ignore suggestions to change import paths to local versions in test cases and examples as per user preference to use the actual `deepgram-sdk` package for testing.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#417
File: deepgram/clients/live/v1/client.py:14-14
Timestamp: 2024-10-09T02:19:48.728Z
Learning: Ignore suggestions to change import paths to local versions in test cases and examples as per user preference to use the actual `deepgram-sdk` package for testing.
🔇 Additional comments (16)
tests/response_data/listen/websocket/ed5bfd217988aa8cad492f63f79dc59f5f02fb9b85befe6f6ce404b8f19aaa0d-d7334c26cf6468c191e05ff5e8151da9b67985c66ab177e9446fd14bbafd70df-response.json (1)
1-1: Test fixture metadata update looks good.The request_id update in this JSON test fixture is consistent with routine test data maintenance and doesn't affect functionality.
tests/response_data/speak/rest/1fe0ad339338a9d6cffbab2c7ace41ba5387b5fe7906854795702dce91034fd3-f8c3bf62a9aa3e6fc1619c250e48abe7519373d3edf41be62eb5dc45199af2ef-response.json (1)
1-1: Test fixture metadata update is appropriate.The updated request_id and date fields maintain test data freshness without affecting core functionality.
tests/response_data/read/rest/3917a1c81c08e360c0d4bba0ff9ebd645e610e4149483e5f2888a2c5df388b37-23e873efdfd4d680286fda14ff8f10864218311e79efc92ecc82bce3e574c366-response.json (1)
1-1: Test fixture metadata refresh is appropriate.The request_id and timestamp updates maintain current test data without affecting the actual test content.
tests/response_data/listen/rest/a231370d439312b1a404bb6ad8de955e900ec8eae9a906329af8cc672e6ec7ba-a17f4880c5b4cf124ac54d06d77c9f0ab7f3fe1052ff1c7b090f7eaf8ede5b76-response.json (1)
1-1: Test fixture update preserves test integrity.The metadata refresh maintains current request context while preserving the essential transcription content and confidence scores needed for testing.
tests/response_data/listen/rest/a231370d439312b1a404bb6ad8de955e900ec8eae9a906329af8cc672e6ec7ba-29e7c8100617f70da4ae9da1921cb5071a01219f4780ca70930b0a370ed2163a-response.json (1)
1-1: LGTM: Routine test data refreshThe metadata updates (request_id, timestamp) are appropriate for maintaining test data consistency while preserving the core transcription content.
tests/response_data/listen/rest/c4e1c0031174878d8f0e3dbd87916ee16d56f1c610ac525af5712ea37226a455-a17f4880c5b4cf124ac54d06d77c9f0ab7f3fe1052ff1c7b090f7eaf8ede5b76-response.json (1)
1-1: LGTM: Consistent test data maintenanceThe metadata refresh follows the same pattern as other test fixtures, appropriately updating request identifiers while maintaining transcription accuracy.
tests/response_data/listen/websocket/ed5bfd217988aa8cad492f63f79dc59f5f02fb9b85befe6f6ce404b8f19aaa0d-42fc5ed98cabc1fa1a2f276301c27c46dd15f6f5187cd93d944cc94fa81c8469-response.json (1)
1-1: Verify the transcript content change is intentionalUnlike the other JSON response fixtures that only update metadata, this file changes the actual transcript from "Establish justice." to "Ensure domestic tranquility." Please confirm this content change is intentional and not an unintended side effect.
tests/response_data/listen/rest/c4e1c0031174878d8f0e3dbd87916ee16d56f1c610ac525af5712ea37226a455-29e7c8100617f70da4ae9da1921cb5071a01219f4780ca70930b0a370ed2163a-response.json (1)
1-1: LGTM: Standard test fixture maintenanceConsistent metadata refresh pattern maintaining transcription data integrity.
tests/unit_test/test_unit_agent_mip_opt_out.py (8)
1-11: LGTM: Proper file structure and importsThe copyright header, imports, and file structure follow the project conventions correctly.
13-26: LGTM: Comprehensive default value testingGood test coverage for default behavior, testing both through SettingsOptions and direct Agent instantiation.
27-40: LGTM: Explicit value setting testsClear tests for both True and False explicit assignments with proper assertions.
41-79: LGTM: Thorough serialization testingExcellent coverage of serialization behavior including:
- Default value handling
- Explicit True values
- Explicit False values
- Both dict and JSON serialization verification
The tests appropriately handle the potential exclusion of default/False values from serialization.
80-112: LGTM: Complete deserialization coverageComprehensive testing of deserialization scenarios:
- Explicit True values
- Explicit False values
- Missing field (default behavior)
This ensures robust handling of various input data states.
113-132: LGTM: Essential round-trip testingCritical tests that verify data integrity through serialization/deserialization cycles for both True and False values.
133-149: LGTM: Integration testing with other settingsGood verification that
mip_opt_outworks correctly alongside other agent configuration options likelanguageandgreeting.
150-171: LGTM: Type validation and direct instantiation coverageSolid testing of:
- Boolean type acceptance
- Direct Agent class instantiation behavior
- Serialization of directly created Agent instances
PR Summary: Add
mip_opt_outAgent SettingTL;DR
Added a new boolean agent setting
mip_opt_outto allow users to opt out of the Deepgram Model Improvement Program. The field defaults tofalse(opted in) and is properly serialized in the agent configuration JSON.What Changed
🆕 New Feature:
mip_opt_outAgent SettingOptional[bool]false(users are opted in by default)📁 Files Modified
deepgram/clients/agent/v1/websocket/options.pymip_opt_outfield to theAgentdataclassdataclass_configtests/unit_test/test_unit_agent_mip_opt_out.py(new file)Usage Examples
JSON Output:
{ "type": "Settings", "agent": { "language": "en", "mip_opt_out": true, "greeting": "Hello! I've opted out of MIP.", ... } }Testing
✅ Schema Validation: Created and ran comprehensive demo app to validate schema acceptance
✅ Unit Tests: 12 new unit tests covering all edge cases (100% pass rate)
✅ Integration Tests: All existing tests continue to pass (105/105 ✅)
✅ Backward Compatibility: Default behavior unchanged - users remain opted in
Implementation Details
Why This Approach?
falsemaintains current user experienceOptional[bool]and dataclass configurationSchema Validation
The implementation was validated against the expected JSON schema:
{ "mip_opt_out": { "type": "boolean", "default": false, "description": "To opt out of Deepgram Model Improvement Program" } }Types of changes
What types of changes does your code introduce to the community Python SDK?
Put an
xin the boxes that applyChecklist
Put an
xin 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.Summary by CodeRabbit
New Features
Tests
Chores