deepgram / deepgram-python-sdk

Official Python SDK for Deepgram's automated speech recognition APIs.
https://developers.deepgram.com
MIT License
240 stars 64 forks source link

Expose All Response Types/Objects #464

Closed davidvonthenen closed 1 month ago

davidvonthenen commented 2 months ago

Proposed changes

Addresses: https://github.com/deepgram/deepgram-python-sdk/issues/457

This exposes all types/classes in the top-level result results. Users should be able to access any object in a response by name or ref. This explicitly lists the objects and also explicitly state which ones are being used as "common" objects; you can see these as commented out items that are contained in the imports. This is to easily see what is being exported where. Example:

from .client import (
    #### top level
    AsyncPrerecordedResponse,
    PrerecordedResponse,
    SyncPrerecordedResponse,
    #### shared
    # Average,
    # Intent,
    # Intents,
    # IntentsInfo,
    # Segment,
    # SentimentInfo,
    # Sentiment,
    # Sentiments,
    # SummaryInfo,
    # Topic,
    # Topics,
    # TopicsInfo,
    #### unique
    Alternative,
    Channel,
    Entity,
    Hit,
    ListenRESTMetadata,
    ModelInfo,
    Paragraph,
    Paragraphs,
    ListenRESTResults,
    Search,
    Sentence,
    Summaries,
    SummaryV1,
    SummaryV2,
    Translation,
    Utterance,
    Warning,
    Word,
)

This is backward compatible, and no modification of client code is required. I manually ran each example to ensure the appropriate response.

As a consequence of doing this PR, there was a (much needed) consolidation of the BaseResponse class. This in turn deleted a bunch of code that is now inherited.

Created a test build 3.7.0-dev.2 to verify all types are exposed. This checks out.

Types of changes

What types of changes does your code introduce to the community Python SDK? Put an x in the boxes that apply

Checklist

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

coderabbitai[bot] commented 2 months ago

[!WARNING]

Rate limit exceeded

@dvonthenen has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 13 seconds before requesting another review.

How to resolve this issue? After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.
How do rate limits work? CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://coderabbit.ai/docs/faq) for further information.
Commits Files that changed from the base of the PR and between a1fd3dcbb0da032436a2a66f6a364dd68f61e3ec and 7973bcbc22823135b2793d9c5d95ee6e51783a52.

Walkthrough

The changes involve a comprehensive restructuring of import statements and organization of classes across multiple files in the Deepgram SDK. New entities have been added, existing entities have been reorganized into categorized sections, and several classes have been renamed or removed to streamline the codebase. The modifications focus on improving clarity and maintainability without altering the core functionality of the SDK.

Changes

Files Change Summary
deepgram/__init__.py Restructured import statements, added new imports from .client, and reorganized response classes into categorized sections.
deepgram/client.py Significant restructuring of imports, added new response classes, and commented out unused imports.
deepgram/clients/__init__.py Organized imports from various modules into sections like "common," "unique," and "top level." New entities added from .listen and .manage.
deepgram/clients/analyze/__init__.py Restructured imports into distinct groups for better readability.
deepgram/clients/analyze/client.py Added new aliases for response types and reorganized source types for clarity.
deepgram/clients/analyze/v1/__init__.py Organized imports and added new source types and response imports.
deepgram/clients/analyze/v1/options.py Updated AnalyzeOptions class to inherit from BaseResponse, removed certain methods.
deepgram/clients/analyze/v1/response.py Removed several data classes that extended BaseResponse, simplifying the response structure.
deepgram/clients/common/__init__.py Introduced new aliases for various classes, enhancing the organization of imports.
deepgram/clients/common/v1/__init__.py Added new imports from shared, rest, and websocket response modules.
deepgram/clients/common/v1/rest_response.py Introduced new data classes for REST API response handling.
deepgram/clients/listen/__init__.py Reorganized imports into categories for better clarity, moved certain imports to "common" section.
deepgram/clients/listen/client.py Added new source types, updated websocket-related responses, and improved import organization.
deepgram/clients/manage/__init__.py Restructured imports into "top level" and "shared" sections, moving several entities for better organization.
deepgram/clients/manage/client.py Added multiple new response classes related to STT and TTS functionalities.
deepgram/clients/manage/v1/__init__.py Restructured imports into "top level" and "shared" sections.
deepgram/clients/manage/v1/options.py Updated options classes to inherit from BaseResponse, removing item access methods.
deepgram/clients/manage/v1/response.py Significant renaming of classes for clarity and consistency, with the BaseResponse class moved to a common module.
deepgram/clients/speak/__init__.py Restructured imports into sections, added new imports for websocket-related entities.
deepgram/clients/speak/client.py Organized imports, added new source types, and updated response types for clarity.
deepgram/clients/speak/v1/__init__.py Reorganized imports into categories, updated naming conventions for clarity.
deepgram/clients/speak/v1/rest/__init__.py Added new imports for source types and updated import structure for clarity.
deepgram/clients/speak/v1/rest/options.py Updated SpeakRESTOptions class to inherit from BaseResponse, removed item access methods.
deepgram/clients/speak/v1/rest/response.py Removed several response classes, focusing on SpeakRESTResponse and centralizing base response functionality.
deepgram/clients/speak/v1/websocket/__init__.py Reorganized import statements for clarity, moving classes under appropriate comments.
deepgram/clients/speak/v1/websocket/options.py Updated SpeakWSOptions class to inherit from BaseResponse, simplifying the class structure.
deepgram/clients/speak/v1/websocket/response.py Refactored response classes to inherit from BaseResponse, removing item access methods for a streamlined implementation.

Possibly related PRs

Suggested reviewers


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?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: -- `I pushed a fix in commit , please review it.` -- `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: -- `@coderabbitai generate unit testing code for this file.` -- `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: -- `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` -- `@coderabbitai read src/utils.ts and generate unit testing code.` -- `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` -- `@coderabbitai help me debug CodeRabbit configuration file.` 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) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
davidvonthenen commented 2 months ago

Units tests pass as well!