Skip to content
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

Implements Models API #445

Merged
merged 1 commit into from
Aug 14, 2024
Merged

Conversation

dvonthenen
Copy link
Contributor

@dvonthenen dvonthenen commented Jul 31, 2024

Proposed changes

This PR implements the Models API.

Types of changes

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

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update or tests (if none of the other choices 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.

  • I have read the CONTRIBUTING doc
  • I have lint'ed all of my code using repo standards
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

NA

Summary by CodeRabbit

  • New Features

    • Introduced new response types ModelResponse and ModelsResponse for enhanced model management functionality.
    • Added new asynchronous methods to list and retrieve models within specific projects.
    • Implemented example scripts for managing Deepgram projects and models.
    • Introduced a class ModelOptions to streamline model querying options.
  • Bug Fixes

    • Updated documentation for clarity, replacing outdated terminology in property descriptions.

Copy link
Contributor

coderabbitai bot commented Jul 31, 2024

Walkthrough

The recent updates to the Deepgram API client significantly enhance its functionality and usability. New response types, ModelResponse and ModelsResponse, improve the handling of model-related data. Additionally, the introduction of various asynchronous and synchronous methods for retrieving models and managing projects streamlines user interaction. Collectively, these changes expand the capabilities of the Deepgram services, making it easier for users to work with models effectively.

Changes

Files Change Summary
deepgram/__init__.py, deepgram/client.py, deepgram/clients/__init__.py, deepgram/clients/manage/__init__.py Added ModelResponse and ModelsResponse to enhance handling of model-related responses.
deepgram/clients/manage/client.py Introduced aliases ModelResponseLatest and ModelsResponseLatest for clarity.
deepgram/clients/manage/v1/__init__.py, deepgram/clients/manage/v1/async_client.py, deepgram/clients/manage/v1/client.py Added new asynchronous and synchronous methods for listing and retrieving models in projects.
deepgram/clients/manage/v1/response.py Introduced new data classes (BaseResponse, Stt, Metadata, Tts, ModelResponse, ModelsResponse) for structured response handling.
examples/manage/async_models/main.py, examples/manage/models/main.py New example scripts for managing models asynchronously and synchronously via the Deepgram API.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DeepgramClient
    participant API

    User->>DeepgramClient: Initiate model retrieval
    DeepgramClient->>API: Fetch models
    API-->>DeepgramClient: Return model data
    DeepgramClient-->>User: Display list of models
Loading
sequenceDiagram
    participant User
    participant DeepgramClient
    participant API

    User->>DeepgramClient: Request project-specific models
    DeepgramClient->>API: Fetch models for project
    API-->>DeepgramClient: Return project models
    DeepgramClient-->>User: Display project models
Loading

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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 19

Outside diff range, codebase verification and nitpick comments (4)
deepgram/clients/manage/v1/async_client.py (4)

244-258: Expand the docstring for list_project_models.

The docstring is minimal and could be expanded to provide more details about the function's purpose and parameters.

        """
        List all models for the current project.

+       Args:
+           project_id (str): The ID of the project.
+           timeout (Optional[httpx.Timeout]): The timeout setting for the request.
+           addons (Optional[Dict]): Additional options for the request.
+           headers (Optional[Dict]): Headers to include in the request.
+           **kwargs: Additional keyword arguments.
        """

259-287: Improve the docstring for get_project_models.

The docstring should include details about the parameters and the return value.

        """
        Gets a list of models for the current project.

        Reference:
        https://developers.deepgram.com/docs/model-metadata

+       Args:
+           project_id (str): The ID of the project.
+           timeout (Optional[httpx.Timeout]): The timeout setting for the request.
+           addons (Optional[Dict]): Additional options for the request.
+           headers (Optional[Dict]): Headers to include in the request.
+           **kwargs: Additional keyword arguments.
+
+       Returns:
+           ModelsResponse: A response object containing the list of models.
        """

321-335: Expand the docstring for list_models.

The docstring is minimal and could be expanded to provide more details about the function's purpose and parameters.

        """
        Please see get_models for more information.

+       Args:
+           timeout (Optional[httpx.Timeout]): The timeout setting for the request.
+           addons (Optional[Dict]): Additional options for the request.
+           headers (Optional[Dict]): Headers to include in the request.
+           **kwargs: Additional keyword arguments.
        """

336-362: Improve the docstring for get_models.

The docstring should include details about the parameters and the return value.

        """
        Gets a list of models available.

        Reference:
        https://developers.deepgram.com/docs/model-metadata

+       Args:
+           timeout (Optional[httpx.Timeout]): The timeout setting for the request.
+           addons (Optional[Dict]): Additional options for the request.
+           headers (Optional[Dict]): Headers to include in the request.
+           **kwargs: Additional keyword arguments.
+
+       Returns:
+           ModelsResponse: A response object containing the list of models.
        """
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 22dc7d0 and b372254.

Files selected for processing (11)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (2 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/manage/init.py (1 hunks)
  • deepgram/clients/manage/client.py (2 hunks)
  • deepgram/clients/manage/v1/init.py (1 hunks)
  • deepgram/clients/manage/v1/async_client.py (3 hunks)
  • deepgram/clients/manage/v1/client.py (3 hunks)
  • deepgram/clients/manage/v1/response.py (2 hunks)
  • examples/manage/async_models/main.py (1 hunks)
  • examples/manage/models/main.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • deepgram/clients/manage/client.py
Additional context used
Ruff
deepgram/clients/manage/__init__.py

32-32: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/clients/manage/v1/__init__.py

32-32: .response.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .response.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

examples/manage/models/main.py

7-7: logging imported but unused

Remove unused import: logging

(F401)


24-24: f-string without any placeholders

Remove extraneous f prefix

(F541)

examples/manage/async_models/main.py

8-8: logging imported but unused

Remove unused import: logging

(F401)


25-25: f-string without any placeholders

Remove extraneous f prefix

(F541)

deepgram/clients/__init__.py

171-171: .manage.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


172-172: .manage.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/__init__.py

163-163: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


164-164: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/client.py

167-167: .clients.ModelResponse imported but unused

Remove unused import

(F401)


168-168: .clients.ModelsResponse imported but unused

Remove unused import

(F401)

deepgram/clients/manage/v1/response.py

35-35: Undefined name Dict

(F821)


35-35: Undefined name Any

(F821)


35-35: Undefined name Any

(F821)

Additional comments not posted (18)
examples/manage/models/main.py (3)

1-4: LGTM!

The file header and initial imports are correct.


9-13: LGTM!

The imports and dotenv loading are correct.


76-78: LGTM!

The main entry point is correct.

examples/manage/async_models/main.py (1)

16-21: Ensure API key is securely loaded.

The API key is currently an empty string. Ensure it is securely loaded from environment variables or a secure source.

- deepgram: DeepgramClient = DeepgramClient("", config)
+ api_key = os.getenv("DEEPGRAM_API_KEY")
+ deepgram: DeepgramClient = DeepgramClient(api_key, config)
deepgram/client.py (3)

266-268: Docstring update for listen property.

The updated docstring improves clarity by specifying that it returns a "Listen dot-notation router."


273-275: Docstring update for read property.

The updated docstring improves clarity by specifying that it returns a "Read dot-notation router."


280-282: Docstring update for speak property.

The updated docstring improves clarity by specifying that it returns a "Speak dot-notation router."

deepgram/clients/manage/v1/response.py (5)

117-138: Ensure correct type conversion in Stt class.

The __getitem__ method in the Stt class should ensure that languages is converted to a list of strings.


140-150: Ensure correct type conversion in Metadata class.

The Metadata class is well-defined and follows the structure of the other response classes.


153-173: Ensure correct type conversion in Tts class.

The __getitem__ method in the Tts class should ensure that metadata is converted to a list of Metadata objects.


179-199: Ensure correct type conversion in ModelResponse class.

The __getitem__ method in the ModelResponse class should ensure that metadata is converted to a list of Metadata objects.


202-218: Ensure correct type conversion in ModelsResponse class.

The __getitem__ method in the ModelsResponse class should ensure that stt and tts are converted to lists of Stt and Tts objects, respectively.

deepgram/clients/manage/v1/client.py (6)

245-259: Docstring for list_project_models method.

The docstring for the list_project_models method is clear and concise.


260-288: Docstring for get_project_models method.

The docstring for the get_project_models method is clear and concise.


290-320: Docstring for get_project_model method.

The docstring for the get_project_model method is clear and concise.


322-336: Docstring for list_models method.

The docstring for the list_models method is clear and concise.


337-363: Docstring for get_models method.

The docstring for the get_models method is clear and concise.


365-393: Docstring for get_model method.

The docstring for the get_model method is clear and concise.

deepgram/clients/manage/__init__.py Show resolved Hide resolved
deepgram/client.py Show resolved Hide resolved
examples/manage/async_models/main.py Outdated Show resolved Hide resolved
examples/manage/async_models/main.py Outdated Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Outdated Show resolved Hide resolved
examples/manage/async_models/main.py Outdated Show resolved Hide resolved
examples/manage/models/main.py Show resolved Hide resolved
examples/manage/models/main.py Outdated Show resolved Hide resolved
deepgram/clients/manage/v1/async_client.py Outdated Show resolved Hide resolved
deepgram/clients/manage/v1/async_client.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Outside diff range, codebase verification and nitpick comments (1)
examples/manage/async_models/main.py (1)

8-8: Remove unused import.

The logging module is imported but not used in the code.

- import logging
Tools
Ruff

8-8: logging imported but unused

Remove unused import: logging

(F401)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b372254 and c7a86a7.

Files selected for processing (11)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (2 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/manage/init.py (1 hunks)
  • deepgram/clients/manage/client.py (2 hunks)
  • deepgram/clients/manage/v1/init.py (1 hunks)
  • deepgram/clients/manage/v1/async_client.py (3 hunks)
  • deepgram/clients/manage/v1/client.py (3 hunks)
  • deepgram/clients/manage/v1/response.py (2 hunks)
  • examples/manage/async_models/main.py (1 hunks)
  • examples/manage/models/main.py (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • deepgram/clients/manage/client.py
  • deepgram/clients/manage/v1/async_client.py
Additional context used
Ruff
deepgram/clients/manage/__init__.py

32-32: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/clients/manage/v1/__init__.py

32-32: .response.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .response.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

examples/manage/models/main.py

7-7: logging imported but unused

Remove unused import: logging

(F401)


24-24: f-string without any placeholders

Remove extraneous f prefix

(F541)

examples/manage/async_models/main.py

8-8: logging imported but unused

Remove unused import: logging

(F401)


25-25: f-string without any placeholders

Remove extraneous f prefix

(F541)

deepgram/clients/__init__.py

171-171: .manage.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


172-172: .manage.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/__init__.py

163-163: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


164-164: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/client.py

167-167: .clients.ModelResponse imported but unused

Remove unused import

(F401)


168-168: .clients.ModelsResponse imported but unused

Remove unused import

(F401)

Additional comments not posted (20)
examples/manage/models/main.py (2)

60-63: Fix incorrect variable usage.

The loop should iterate over listProjModels instead of listModels.

- for stt in listModels.stt:
+ for stt in listProjModels.stt:
- for tts in listModels.tts:
+ for tts in listProjModels.tts:

Likely invalid or redundant comment.


73-75: Improve exception handling.

Consider logging the exception for better debugging.

- print(f"Exception: {e}")
+ logging.error(f"Exception: {e}")

Likely invalid or redundant comment.

examples/manage/async_models/main.py (5)

25-25: Remove extraneous f-string prefix.

The f prefix is unnecessary here as there are no placeholders in the string.

- print(f"ListProjects failed.")
+ print("ListProjects failed.")
Tools
Ruff

25-25: f-string without any placeholders

Remove extraneous f prefix

(F541)


22-34: Check for empty project response.

The code assumes that projectResp.projects is not empty. Add a check to handle the case where no projects are returned.

+ if not projectResp.projects:
+     print("No projects found.")
+     sys.exit(1)
Tools
Ruff

25-25: f-string without any placeholders

Remove extraneous f prefix

(F541)


36-47: Handle case where no models are found.

The code should handle the case where listModels is not None but listModels.stt and listModels.tts are empty.

+ if not listModels.stt and not listModels.tts:
+     print("No models found.")

56-65: Fix incorrect variable usage.

The code uses listModels instead of listProjModels when iterating over project models.

- for stt in listModels.stt:
+ for stt in listProjModels.stt:
- for tts in listModels.tts:
+ for tts in listProjModels.tts:

74-76: Improve exception handling.

Log the exception details using the logging module for better debugging.

- print(f"Exception: {e}")
+ logging.error(f"Exception occurred: {e}", exc_info=True)
deepgram/clients/__init__.py (1)

171-172: Add ModelsResponse and ModelResponse to __all__.

The static analysis hint suggests these imports are unused. To make them available for external use, add them to the __all__ list.

+ __all__ = [
+     ...
+     "ModelsResponse",
+     "ModelResponse",
+ ]
Tools
Ruff

171-171: .manage.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


172-172: .manage.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/__init__.py (1)

163-164: Add ModelsResponse and ModelResponse to __all__.

The static analysis hint suggests these imports are unused. To make them available for external use, add them to the __all__ list.

+ __all__ = [
+     ...
+     "ModelsResponse",
+     "ModelResponse",
+ ]
Tools
Ruff

163-163: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


164-164: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/clients/manage/v1/response.py (5)

117-138: LGTM!

The Stt class is well-defined with appropriate type hints and functionality.


140-151: LGTM!

The Metadata class is well-defined with appropriate type hints and functionality.


153-174: LGTM!

The Tts class is well-defined with appropriate type hints and functionality.


179-218: LGTM!

The ModelResponse and ModelsResponse classes are well-defined with appropriate type hints and functionality.


5-5: Import missing type hints.

The Dict and Any types are used but not imported.

from typing import List, Optional, Dict, Any

Likely invalid or redundant comment.

deepgram/clients/manage/v1/client.py (6)

30-31: LGTM!

The imports for ModelResponse and ModelsResponse are necessary for the new functionality.


245-259: LGTM!

The list_project_models method is well-defined with appropriate functionality and error handling.


260-288: LGTM!

The get_project_models method is well-defined with appropriate functionality and error handling.


290-320: LGTM!

The get_project_model method is well-defined with appropriate functionality and error handling.


322-336: LGTM!

The list_models method is well-defined with appropriate functionality and error handling.


337-393: LGTM!

The get_models and get_model methods are well-defined with appropriate functionality and error handling.

examples/manage/models/main.py Outdated Show resolved Hide resolved
examples/manage/models/main.py Outdated Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c7a86a7 and 31b55da.

Files selected for processing (11)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (2 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/manage/init.py (1 hunks)
  • deepgram/clients/manage/client.py (2 hunks)
  • deepgram/clients/manage/v1/init.py (1 hunks)
  • deepgram/clients/manage/v1/async_client.py (3 hunks)
  • deepgram/clients/manage/v1/client.py (3 hunks)
  • deepgram/clients/manage/v1/response.py (2 hunks)
  • examples/manage/async_models/main.py (1 hunks)
  • examples/manage/models/main.py (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • deepgram/clients/manage/client.py
  • deepgram/clients/manage/v1/async_client.py
Additional context used
Ruff
deepgram/clients/manage/__init__.py

32-32: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/clients/manage/v1/__init__.py

32-32: .response.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .response.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

examples/manage/models/main.py

7-7: logging imported but unused

Remove unused import: logging

(F401)

examples/manage/async_models/main.py

8-8: logging imported but unused

Remove unused import: logging

(F401)

deepgram/clients/__init__.py

171-171: .manage.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


172-172: .manage.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/__init__.py

163-163: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


164-164: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/client.py

167-167: .clients.ModelResponse imported but unused

Remove unused import

(F401)


168-168: .clients.ModelsResponse imported but unused

Remove unused import

(F401)

Additional comments not posted (18)
deepgram/clients/manage/__init__.py (1)

32-33: Address unused imports.

The imports ModelResponse and ModelsResponse are currently unused. Consider adding them to __all__ or using them.

+ __all__ = [
+     "ManageClient",
+     "AsyncManageClient",
+     "ProjectOptions",
+     "KeyOptions",
+     "ScopeOptions",
+     "InviteOptions",
+     "UsageRequestOptions",
+     "UsageSummaryOptions",
+     "UsageFieldsOptions",
+     "Message",
+     "Project",
+     "ProjectsResponse",
+     "MembersResponse",
+     "Key",
+     "KeyResponse",
+     "KeysResponse",
+     "ScopesResponse",
+     "InvitesResponse",
+     "UsageRequest",
+     "UsageRequestsResponse",
+     "UsageSummaryResponse",
+     "UsageFieldsResponse",
+     "Balance",
+     "BalancesResponse",
+     "ModelResponse",
+     "ModelsResponse",
+ ]
Tools
Ruff

32-32: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/clients/manage/v1/__init__.py (1)

32-33: Address unused imports.

The imports ModelResponse and ModelsResponse are currently unused. Consider adding them to __all__ or using them.

+ __all__ = [
+     "ManageClient",
+     "AsyncManageClient",
+     "ProjectOptions",
+     "KeyOptions",
+     "ScopeOptions",
+     "InviteOptions",
+     "UsageRequestOptions",
+     "UsageSummaryOptions",
+     "UsageFieldsOptions",
+     "Message",
+     "Project",
+     "ProjectsResponse",
+     "MembersResponse",
+     "Key",
+     "KeyResponse",
+     "KeysResponse",
+     "ScopesResponse",
+     "InvitesResponse",
+     "UsageRequest",
+     "UsageRequestsResponse",
+     "UsageSummaryResponse",
+     "UsageFieldsResponse",
+     "Balance",
+     "BalancesResponse",
+     "ModelResponse",
+     "ModelsResponse",
+ ]
Tools
Ruff

32-32: .response.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .response.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

examples/manage/models/main.py (4)

7-7: Remove unused import.

The import logging is unused and can be removed.

- import logging
Tools
Ruff

7-7: logging imported but unused

Remove unused import: logging

(F401)


24-24: Remove extraneous f prefix.

The f-string on this line does not contain any placeholders.

- print(f"ListProjects failed.")
+ print("ListProjects failed.")

81-83: Improve exception handling.

Consider logging the exception for better debugging.

- print(f"Exception: {e}")
+ logging.error(f"Exception: {e}")

67-71: Fix incorrect variable usage.

The loop should iterate over listProjModels instead of listModels.

- for stt in listModels.stt:
+ for stt in listProjModels.stt:
- for tts in listModels.tts:
+ for tts in listProjModels.tts:
examples/manage/async_models/main.py (2)

8-8: Acknowledge the necessity of the logging import.

The logging module is required for cases where verboselogs log levels are not used. Thank you for the clarification!

Tools
Ruff

8-8: logging imported but unused

Remove unused import: logging

(F401)


82-84: Improve exception handling.

Log the exception details using the logging module for better debugging.

- print(f"Exception: {e}")
+ logging.error(f"Exception occurred: {e}", exc_info=True)

Likely invalid or redundant comment.

deepgram/client.py (3)

266-268: LGTM!

The updated docstring provides better clarity by using "dot-notation router" instead of "instance".


273-275: LGTM!

The updated docstring provides better clarity by using "dot-notation router" instead of "instance".


280-282: LGTM!

The updated docstring provides better clarity by using "dot-notation router" instead of "instance".

deepgram/clients/manage/v1/response.py (1)

140-151: LGTM!

The Metadata class is well-structured and provides useful methods for response handling.

deepgram/clients/manage/v1/client.py (6)

245-259: LGTM!

The list_project_models method is well-structured and provides useful functionality for model management.


260-299: LGTM!

The get_project_models method is well-structured and provides useful functionality for model management.


301-343: LGTM!

The get_project_model method is well-structured and provides useful functionality for model management.


345-359: LGTM!

The list_models method is well-structured and provides useful functionality for model management.


360-395: LGTM!

The get_models method is well-structured and provides useful functionality for model management.


397-435: LGTM!

The get_model method is well-structured and provides useful functionality for model management.

examples/manage/async_models/main.py Outdated Show resolved Hide resolved
examples/manage/async_models/main.py Show resolved Hide resolved
examples/manage/async_models/main.py Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Outdated Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Outdated Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 31b55da and a6aafe7.

Files selected for processing (11)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (2 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/manage/init.py (1 hunks)
  • deepgram/clients/manage/client.py (2 hunks)
  • deepgram/clients/manage/v1/init.py (1 hunks)
  • deepgram/clients/manage/v1/async_client.py (3 hunks)
  • deepgram/clients/manage/v1/client.py (3 hunks)
  • deepgram/clients/manage/v1/response.py (2 hunks)
  • examples/manage/async_models/main.py (1 hunks)
  • examples/manage/models/main.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • examples/manage/async_models/main.py
Files skipped from review as they are similar to previous changes (4)
  • deepgram/clients/manage/client.py
  • deepgram/clients/manage/v1/client.py
  • deepgram/clients/manage/v1/response.py
  • examples/manage/models/main.py
Additional context used
Ruff
deepgram/clients/manage/__init__.py

32-32: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/clients/manage/v1/__init__.py

32-32: .response.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


33-33: .response.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/clients/__init__.py

171-171: .manage.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


172-172: .manage.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/__init__.py

163-163: .client.ModelsResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)


164-164: .client.ModelResponse imported but unused; consider removing, adding to __all__, or using a redundant alias

(F401)

deepgram/client.py

167-167: .clients.ModelResponse imported but unused

Remove unused import

(F401)


168-168: .clients.ModelsResponse imported but unused

Remove unused import

(F401)

Additional comments not posted (4)
deepgram/clients/manage/v1/async_client.py (4)

259-299: LGTM!

The method implementation and docstring are correct.


300-342: LGTM!

The method implementation and docstring are correct.


359-394: LGTM!

The method implementation and docstring are correct.


396-434: LGTM!

The method implementation and docstring are correct.

deepgram/__init__.py Show resolved Hide resolved
deepgram/client.py Show resolved Hide resolved
deepgram/clients/manage/__init__.py Show resolved Hide resolved
deepgram/clients/manage/v1/async_client.py Outdated Show resolved Hide resolved
deepgram/clients/manage/v1/async_client.py Outdated Show resolved Hide resolved
deepgram/clients/manage/__init__.py Show resolved Hide resolved
deepgram/clients/manage/v1/__init__.py Show resolved Hide resolved
deepgram/clients/manage/v1/__init__.py Show resolved Hide resolved
deepgram/clients/__init__.py Show resolved Hide resolved
deepgram/clients/__init__.py Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a6aafe7 and 8c0d65a.

Files selected for processing (12)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (2 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/manage/init.py (1 hunks)
  • deepgram/clients/manage/client.py (2 hunks)
  • deepgram/clients/manage/v1/init.py (1 hunks)
  • deepgram/clients/manage/v1/async_client.py (3 hunks)
  • deepgram/clients/manage/v1/client.py (3 hunks)
  • deepgram/clients/manage/v1/response.py (2 hunks)
  • examples/manage/async_models/main.py (1 hunks)
  • examples/manage/models/main.py (1 hunks)
  • examples/speech-to-text/websocket/microphone/main.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • examples/speech-to-text/websocket/microphone/main.py
Files skipped from review as they are similar to previous changes (9)
  • deepgram/init.py
  • deepgram/client.py
  • deepgram/clients/init.py
  • deepgram/clients/manage/init.py
  • deepgram/clients/manage/client.py
  • deepgram/clients/manage/v1/init.py
  • deepgram/clients/manage/v1/async_client.py
  • examples/manage/async_models/main.py
  • examples/manage/models/main.py
Additional comments not posted (12)
deepgram/clients/manage/v1/response.py (6)

20-43: Add missing type hints.

The BaseResponse class methods should have type hints for better clarity and type checking.

    def __getitem__(self, key: str) -> Any:
    def __setitem__(self, key: str, val: Any) -> None:
    def eval(self, key: str) -> str:

133-137: Remove unnecessary conversion in __getitem__.

The conversion of languages to strings in the __getitem__ method is redundant since they are already strings.

    def __getitem__(self, key):
        _dict = self.to_dict()
        if "languages" in _dict:
-            _dict["languages"] = [str(languages) for languages in _dict["languages"]]
        return _dict[key]

141-150: LGTM!

The Metadata class is correctly defined with appropriate attributes.


169-175: Remove unnecessary conversion in __getitem__.

The conversion of metadata to a list of Metadata objects in the __getitem__ method is redundant since it is already a single Metadata object.

    def __getitem__(self, key):
        _dict = self.to_dict()
        if "metadata" in _dict:
-            _dict["metadata"] = [Metadata.from_dict(metadata) for metadata in _dict["metadata"]]
        return _dict[key]

197-203: Remove unnecessary conversion in __getitem__.

The conversion of metadata to a list of Metadata objects in the __getitem__ method is redundant since it is already a single Metadata object.

    def __getitem__(self, key):
        _dict = self.to_dict()
        if "metadata" in _dict:
-            _dict["metadata"] = [Metadata.from_dict(metadata) for metadata in _dict["metadata"]]
        return _dict[key]

215-221: Remove unnecessary conversion in __getitem__.

The conversion of stt and tts to lists of Stt and Tts objects in the __getitem__ method is redundant since they are already lists of these objects.

    def __getitem__(self, key):
        _dict = self.to_dict()
        if "stt" in _dict:
-            _dict["stt"] = [Stt.from_dict(stt) for stt in _dict["stt"]]
        if "tts" in _dict:
-            _dict["tts"] = [Tts.from_dict(tts) for tts in _dict["tts"]]
        return _dict[key]
deepgram/clients/manage/v1/client.py (6)

245-258: LGTM!

The list_project_models method correctly wraps around get_project_models.


260-299: LGTM!

The get_project_models method is correctly implemented with appropriate logging and URL construction.


301-343: LGTM!

The get_project_model method is correctly implemented with appropriate logging and response processing.


346-358: LGTM!

The list_models method correctly wraps around get_models.


360-395: LGTM!

The get_models method is correctly implemented with appropriate logging and URL construction.


397-435: LGTM!

The get_model method is correctly implemented with appropriate logging and response processing.

lukeocodes
lukeocodes previously approved these changes Aug 1, 2024
@dvonthenen dvonthenen changed the title Implements Models API [HOLD] Implements Models API Aug 1, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range, codebase verification and nitpick comments (1)
deepgram/clients/manage/v1/response.py (1)

Line range hint 12-34:
Add missing type hints.

The BaseResponse class methods should have type hints for better clarity and type checking.

    def __getitem__(self, key: str) -> Any:
    def __setitem__(self, key: str, val: Any) -> None:
    def __str__(self) -> str:
    def eval(self, key: str) -> str:
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8c0d65a and 84c6bed.

Files selected for processing (12)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (2 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/manage/init.py (1 hunks)
  • deepgram/clients/manage/client.py (2 hunks)
  • deepgram/clients/manage/v1/init.py (1 hunks)
  • deepgram/clients/manage/v1/async_client.py (3 hunks)
  • deepgram/clients/manage/v1/client.py (3 hunks)
  • deepgram/clients/manage/v1/response.py (1 hunks)
  • examples/manage/async_models/main.py (1 hunks)
  • examples/manage/models/main.py (1 hunks)
  • examples/speech-to-text/websocket/microphone/main.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • examples/speech-to-text/websocket/microphone/main.py
Files skipped from review as they are similar to previous changes (10)
  • deepgram/init.py
  • deepgram/client.py
  • deepgram/clients/init.py
  • deepgram/clients/manage/init.py
  • deepgram/clients/manage/client.py
  • deepgram/clients/manage/v1/init.py
  • deepgram/clients/manage/v1/async_client.py
  • deepgram/clients/manage/v1/client.py
  • examples/manage/async_models/main.py
  • examples/manage/models/main.py
Additional comments not posted (2)
deepgram/clients/manage/v1/response.py (2)

111-122: LGTM!

The Metadata class is well-defined and straightforward.


88-108: Remove unnecessary conversion in __getitem__.

The conversion of languages to strings in the __getitem__ method is redundant since they are already strings.

    def __getitem__(self, key):
        _dict = self.to_dict()
        if "languages" in _dict:
-            _dict["languages"] = [str(languages) for languages in _dict["languages"]]
        return _dict[key]

Likely invalid or redundant comment.

deepgram/clients/manage/v1/response.py Outdated Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Outside diff range, codebase verification and nitpick comments (5)
examples/text-to-speech/websocket/simple/main.py (2)

16-20: Consider using a more descriptive variable name for _story.

The variable _story could be renamed to something more descriptive, such as text_input, to improve readability.

- _story = "Hello world."
+ text_input = "Hello world."
msg = json.dumps({"type": "TextInput", "text": text_input})

8-8: DEEPGRAM_API_KEY Environment Variable Not Set

The DEEPGRAM_API_KEY environment variable is not set, which could lead to authentication issues when running the script. Please ensure this variable is properly configured in your environment before executing the script.

Analysis chain

Verify the presence of DEEPGRAM_API_KEY.

Ensure that the DEEPGRAM_API_KEY environment variable is set before running this script to avoid authentication issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the DEEPGRAM_API_KEY environment variable is set.

# Test: Print the DEEPGRAM_API_KEY environment variable. Expect: It should not be empty.
echo "DEEPGRAM_API_KEY: ${DEEPGRAM_API_KEY:-'Not Set'}"

Length of output: 70

examples/manage/models/main.py (1)

84-86: Improve exception handling.

Consider logging the exception for better debugging and consistency with best practices.

- print(f"Exception: {e}")
+ import logging
+ logging.error(f"Exception: {e}")
deepgram/clients/manage/v1/async_client.py (2)

245-256: Enhance the docstring for list_project_models.

The docstring should provide more details about the parameters and the return value.

        """
        Lists models for a specific project.

        Args:
            project_id (str): The ID of the project.
            options (Optional[Union[Dict, ModelOptions]]): Additional options for the request.
            timeout (Optional[httpx.Timeout]): The timeout setting for the request.
            addons (Optional[Dict]): Additional options for the request.
            headers (Optional[Dict]): Headers to include in the request.
            **kwargs: Additional keyword arguments.

        Returns:
            ModelsResponse: A response object containing the model details.
        """

360-371: Enhance the docstring for list_models.

The docstring should provide more details about the parameters and the return value.

        """
        Lists all available models.

        Args:
            options (Optional[Union[Dict, ModelOptions]]): Additional options for the request.
            timeout (Optional[httpx.Timeout]): The timeout setting for the request.
            addons (Optional[Dict]): Additional options for the request.
            headers (Optional[Dict]): Headers to include in the request.
            **kwargs: Additional keyword arguments.

        Returns:
            ModelsResponse: A response object containing the model details.
        """
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 84c6bed and 479b476.

Files selected for processing (14)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (2 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/manage/init.py (1 hunks)
  • deepgram/clients/manage/client.py (2 hunks)
  • deepgram/clients/manage/v1/init.py (1 hunks)
  • deepgram/clients/manage/v1/async_client.py (3 hunks)
  • deepgram/clients/manage/v1/client.py (3 hunks)
  • deepgram/clients/manage/v1/options.py (1 hunks)
  • deepgram/clients/manage/v1/response.py (1 hunks)
  • examples/manage/async_models/main.py (1 hunks)
  • examples/manage/models/main.py (1 hunks)
  • examples/speech-to-text/websocket/microphone/main.py (1 hunks)
  • examples/text-to-speech/websocket/simple/main.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • examples/speech-to-text/websocket/microphone/main.py
Additional context used
Learnings (6)
deepgram/clients/manage/__init__.py (2)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/manage/v1/__init__.py:32-32
Timestamp: 2024-07-31T20:47:50.008Z
Learning: To make `ModelResponse` available for external use in `deepgram/clients/manage/v1/__init__.py`, it should be added to the `__all__` list.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/__init__.py:172-172
Timestamp: 2024-07-31T20:47:51.397Z
Learning: To make `ModelResponse` and `ModelsResponse` available for external use, add them to the `__all__` list in the `deepgram/clients/__init__.py` file.
deepgram/clients/manage/v1/__init__.py (2)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/manage/v1/__init__.py:32-32
Timestamp: 2024-07-31T20:47:50.008Z
Learning: To make `ModelResponse` available for external use in `deepgram/clients/manage/v1/__init__.py`, it should be added to the `__all__` list.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/__init__.py:172-172
Timestamp: 2024-07-31T20:47:51.397Z
Learning: To make `ModelResponse` and `ModelsResponse` available for external use, add them to the `__all__` list in the `deepgram/clients/__init__.py` file.
deepgram/clients/manage/client.py (2)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/manage/v1/__init__.py:32-32
Timestamp: 2024-07-31T20:47:50.008Z
Learning: To make `ModelResponse` available for external use in `deepgram/clients/manage/v1/__init__.py`, it should be added to the `__all__` list.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/__init__.py:172-172
Timestamp: 2024-07-31T20:47:51.397Z
Learning: To make `ModelResponse` and `ModelsResponse` available for external use, add them to the `__all__` list in the `deepgram/clients/__init__.py` file.
deepgram/clients/__init__.py (2)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/manage/v1/__init__.py:32-32
Timestamp: 2024-07-31T20:47:50.008Z
Learning: To make `ModelResponse` available for external use in `deepgram/clients/manage/v1/__init__.py`, it should be added to the `__all__` list.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/__init__.py:172-172
Timestamp: 2024-07-31T20:47:51.397Z
Learning: To make `ModelResponse` and `ModelsResponse` available for external use, add them to the `__all__` list in the `deepgram/clients/__init__.py` file.
deepgram/__init__.py (3)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/manage/v1/__init__.py:32-32
Timestamp: 2024-07-31T20:47:50.008Z
Learning: To make `ModelResponse` available for external use in `deepgram/clients/manage/v1/__init__.py`, it should be added to the `__all__` list.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/__init__.py:172-172
Timestamp: 2024-07-31T20:47:51.397Z
Learning: To make `ModelResponse` and `ModelsResponse` available for external use, add them to the `__all__` list in the `deepgram/clients/__init__.py` file.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/__init__.py:163-164
Timestamp: 2024-07-31T20:47:09.717Z
Learning: To make new entities available for external use in the `deepgram/__init__.py` file, add them to the `__all__` list.
deepgram/client.py (1)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/__init__.py:172-172
Timestamp: 2024-07-31T20:47:51.397Z
Learning: To make `ModelResponse` and `ModelsResponse` available for external use, add them to the `__all__` list in the `deepgram/clients/__init__.py` file.
Additional comments not posted (28)
deepgram/clients/manage/__init__.py (1)

32-33: Verify the usage of ModelResponse and ModelsResponse.

Ensure that ModelResponse and ModelsResponse are used in the codebase or added to the __all__ list if they are meant to be part of the public API.

Verification successful

ModelResponse and ModelsResponse are actively used in the codebase. These classes are imported and utilized in various files, confirming their relevance and integration into the project's functionality. No further action is required regarding their usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `ModelResponse` and `ModelsResponse` in the codebase.

# Test: Search for occurrences of `ModelResponse` and `ModelsResponse`. Expect: They are used or exported.
rg --type python 'ModelResponse|ModelsResponse'

Length of output: 80


Script:

#!/bin/bash
# Description: Verify the usage of `ModelResponse` and `ModelsResponse` in the codebase.

# Test: Search for occurrences of `ModelResponse` and `ModelsResponse` in Python files.
rg 'ModelResponse|ModelsResponse' --glob '*.py'

Length of output: 3816

deepgram/clients/manage/v1/__init__.py (1)

32-33: Verify the usage of ModelResponse and ModelsResponse.

Ensure that ModelResponse and ModelsResponse are used in the codebase or added to the __all__ list if they are meant to be part of the public API.

Verification successful

ModelResponse and ModelsResponse are used throughout the codebase. They are defined in deepgram/clients/manage/v1/response.py and utilized in several other files. If these classes are intended to be part of the public API, ensure they are included in the __all__ list in the relevant __init__.py files.

  • Check deepgram/clients/manage/v1/__init__.py to include them in __all__ if necessary.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `ModelResponse` and `ModelsResponse` in the codebase.

# Test: Search for occurrences of `ModelResponse` and `ModelsResponse`. Expect: They are used or exported.
rg --type python 'ModelResponse|ModelsResponse'

Length of output: 80


Script:

#!/bin/bash
# Description: Verify the usage of `ModelResponse` and `ModelsResponse` in the codebase.

# Corrected: Search for occurrences of `ModelResponse` and `ModelsResponse` without specifying file type.
rg 'ModelResponse|ModelsResponse'

Length of output: 3802

deepgram/clients/manage/client.py (2)

36-36: Alias ModelResponse looks good.

The alias ModelResponse is correctly defined as ModelResponseLatest.

Ensure that this alias is used consistently throughout the codebase.

Verification successful

Alias ModelResponse is used consistently across the codebase.

The alias ModelResponse appears in multiple files, indicating consistent usage. This includes import statements and function signatures, confirming its integration.

  • deepgram/__init__.py
  • deepgram/client.py
  • deepgram/clients/manage/v1/async_client.py
  • deepgram/clients/manage/v1/client.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of `ModelResponse` alias in the codebase.

# Test: Search for the alias usage. Expect: Consistent usage of `ModelResponse`.
rg --type python -A 5 $'ModelResponse'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify usage of `ModelResponse` alias in the codebase.

# Test: Search for the alias usage without specifying file type.
rg 'ModelResponse'

Length of output: 1767


37-37: Alias ModelsResponse looks good.

The alias ModelsResponse is correctly defined as ModelsResponseLatest.

Ensure that this alias is used consistently throughout the codebase.

Verification successful

Let's rerun the script with the correct file type for Python files to verify the usage of the ModelsResponse alias.


Alias ModelsResponse is used consistently across the codebase.

The alias ModelsResponse is correctly utilized in multiple files, indicating consistent usage throughout the codebase. No issues were found.

  • Files include deepgram/client.py, deepgram/__init__.py, deepgram/clients/__init__.py, deepgram/clients/manage/__init__.py, and several files in the deepgram/clients/manage/v1/ directory.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of `ModelsResponse` alias in the codebase.

# Test: Search for the alias usage. Expect: Consistent usage of `ModelsResponse`.
rg --type python -A 5 $'ModelsResponse'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify usage of `ModelsResponse` alias in the codebase.

# Test: Search for the alias usage. Expect: Consistent usage of `ModelsResponse`.
rg --type py -A 5 $'ModelsResponse'

Length of output: 10085

examples/manage/models/main.py (2)

35-35: Verify the correctness of get_models operation.

Ensure that the get_models method returns the expected structure and data.

Verification successful

The get_models operation is correctly implemented.

The get_models method in both client.py and async_client.py constructs a request to retrieve models and processes the response into a ModelsResponse object. The implementation appears to be correct and aligned with the expected behavior.

  • Files:
    • deepgram/clients/manage/v1/client.py
    • deepgram/clients/manage/v1/async_client.py
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the structure and data returned by `get_models`.

# Test: Check if `get_models` method is correctly implemented and returns expected data.
rg --type python -A 5 $'def get_models'

Length of output: 71


Script:

#!/bin/bash
# Corrected: Verify the structure and data returned by `get_models`.

# Test: Locate the `get_models` method definition and examine its implementation.
rg --type py -A 5 $'def get_models'

Length of output: 971


Script:

#!/bin/bash
# Extract the full implementation of the `get_models` method from both files for analysis.

# Extract from client.py
rg --type py -A 20 'def get_models' deepgram/clients/manage/v1/client.py

# Extract from async_client.py
rg --type py -A 20 'def get_models' deepgram/clients/manage/v1/async_client.py

Length of output: 1577


Script:

#!/bin/bash
# Extract more lines to capture the full implementation of the `get_models` method.

# Extract from client.py
rg --type py -A 50 'def get_models' deepgram/clients/manage/v1/client.py

# Extract from async_client.py
rg --type py -A 50 'def get_models' deepgram/clients/manage/v1/async_client.py

Length of output: 3891


62-62: Verify the correctness of get_project_models operation.

Ensure that the get_project_models method returns the expected structure and data.

deepgram/clients/__init__.py (2)

171-171: Addition of ModelsResponse looks good.

ModelsResponse is correctly added to the module's public interface.

Ensure it is included in the __all__ list for proper export.


172-172: Addition of ModelResponse looks good.

ModelResponse is correctly added to the module's public interface.

Ensure it is included in the __all__ list for proper export.

Verification successful

ModelResponse is correctly exported.

The ModelResponse class is included in multiple __init__.py files, indicating it is part of the module's public API. The absence of an __all__ list suggests that the module relies on implicit exports, which is acceptable in this context. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify inclusion of `ModelResponse` in `__all__` list.

# Test: Check if `ModelResponse` is part of the `__all__` list.
rg --type python -A 5 $'__all__'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify inclusion of `ModelResponse` in `__all__` list.

# Test: Check if `ModelResponse` is part of the `__all__` list.
rg --type py -A 5 $'__all__'

Length of output: 27


Script:

#!/bin/bash
# Description: Search for the definition and usage of `ModelResponse`.

# Test: Find where `ModelResponse` is defined and used in the codebase.
rg 'ModelResponse'

Length of output: 1767

examples/manage/async_models/main.py (4)

21-23: Check for empty project response.

The code assumes that projectResp.projects is not empty. Add a check to handle the case where no projects are returned.


36-39: Handle case where no models are found.

The code should handle the case where listModels is not None but listModels.stt and listModels.tts are empty.


89-91: Improve exception handling.

Log the exception details using the logging module for better debugging.


8-8: Retain the logging import.

The logging module is necessary when not using log levels found in verboselogs.

deepgram/__init__.py (1)

163-164: Add ModelsResponse and ModelResponse to __all__.

To make these entities available for external use, add them to the __all__ list.

deepgram/clients/manage/v1/options.py (1)

32-49: Review ModelOptions class implementation.

The ModelOptions class is well-implemented with JSON serialization and dictionary-like access. Ensure that the include_outdated attribute is correctly utilized in the codebase.

deepgram/client.py (1)

266-280: Docstring updates improve clarity.

The change from "instance" to "dot-notation router" in the docstrings enhances clarity regarding the returned objects.

deepgram/clients/manage/v1/response.py (3)

111-123: Metadata class is well-defined.

The Metadata class is correctly defined with appropriate use of dataclass configuration for optional fields.


88-108: Remove unnecessary conversion in __getitem__.

The conversion of languages to strings in the __getitem__ method is redundant since they are already strings.

    def __getitem__(self, key):
        _dict = self.to_dict()
        if "languages" in _dict:
-            _dict["languages"] = [str(languages) for languages in _dict["languages"]]
        return _dict[key]

Likely invalid or redundant comment.


179-194: Remove unnecessary conversion in __getitem__.

The conversion of stt and tts to lists of Stt and Tts objects in the __getitem__ method is redundant since they are already lists of these objects.

    def __getitem__(self, key):
        _dict = self.to_dict()
        if "stt" in _dict:
-            _dict["stt"] = [Stt.from_dict(stt) for stt in _dict["stt"]]
        if "tts" in _dict:
-            _dict["tts"] = [Tts.from_dict(tts) for tts in _dict["tts"]]
        return _dict[key]

Likely invalid or redundant comment.

deepgram/clients/manage/v1/client.py (6)

246-265: Delegation in list_project_models is appropriate.

The method correctly delegates functionality to get_project_models, maintaining consistency and reducing code duplication.


267-315: get_project_models is well-implemented.

The method retrieves models for a specific project with appropriate logging and error handling.


317-359: get_project_model is well-implemented.

The method retrieves a single model for a specific project with appropriate logging and error handling.


362-375: Delegation in list_models is appropriate.

The asynchronous method correctly delegates functionality to get_models, maintaining consistency and reducing code duplication.


377-421: get_models is well-implemented.

The method retrieves all available models with appropriate logging and error handling.


423-461: get_model is well-implemented.

The method retrieves information for a specific model with appropriate logging and error handling.

deepgram/clients/manage/v1/async_client.py (4)

266-314: LGTM!

The get_project_models function is well-implemented with appropriate logging and parameter handling.


316-358: LGTM!

The get_project_model function is well-structured with comprehensive logging and parameter handling.


376-420: LGTM!

The get_models function is well-implemented with appropriate logging and parameter handling.


422-460: LGTM!

The get_model function is well-structured with comprehensive logging and parameter handling.

deepgram/client.py Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Show resolved Hide resolved
deepgram/clients/manage/v1/response.py Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 479b476 and b882f27.

Files selected for processing (14)
  • deepgram/init.py (1 hunks)
  • deepgram/client.py (2 hunks)
  • deepgram/clients/init.py (1 hunks)
  • deepgram/clients/manage/init.py (1 hunks)
  • deepgram/clients/manage/client.py (2 hunks)
  • deepgram/clients/manage/v1/init.py (1 hunks)
  • deepgram/clients/manage/v1/async_client.py (3 hunks)
  • deepgram/clients/manage/v1/client.py (3 hunks)
  • deepgram/clients/manage/v1/options.py (1 hunks)
  • deepgram/clients/manage/v1/response.py (1 hunks)
  • examples/manage/async_models/main.py (1 hunks)
  • examples/manage/models/main.py (1 hunks)
  • examples/speech-to-text/websocket/microphone/main.py (1 hunks)
  • examples/text-to-speech/websocket/simple/main.py (1 hunks)
Files skipped from review due to trivial changes (2)
  • deepgram/clients/init.py
  • examples/speech-to-text/websocket/microphone/main.py
Files skipped from review as they are similar to previous changes (12)
  • deepgram/init.py
  • deepgram/client.py
  • deepgram/clients/manage/init.py
  • deepgram/clients/manage/client.py
  • deepgram/clients/manage/v1/init.py
  • deepgram/clients/manage/v1/async_client.py
  • deepgram/clients/manage/v1/client.py
  • deepgram/clients/manage/v1/options.py
  • deepgram/clients/manage/v1/response.py
  • examples/manage/async_models/main.py
  • examples/manage/models/main.py
  • examples/text-to-speech/websocket/simple/main.py
Additional context used
Learnings (1)
Common learnings
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/client.py:167-168
Timestamp: 2024-08-14T19:03:11.476Z
Learning: In the `deepgram/client.py` file, `ModelResponse` and `ModelsResponse` imports are kept intentionally to expose return objects at various levels of packaging, even if they are not used directly in the file.

@dvonthenen dvonthenen changed the title [HOLD] Implements Models API Implements Models API Aug 14, 2024
@dvonthenen dvonthenen merged commit 5d7b655 into deepgram:main Aug 14, 2024
4 checks passed
@dvonthenen dvonthenen deleted the get-model-support branch August 14, 2024 22:24
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.

3 participants