-
Notifications
You must be signed in to change notification settings - Fork 32
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
Implement Models API #322
Implement Models API #322
Conversation
WalkthroughThe recent changes to the Deepgram project enhance model management capabilities within the SDK. Key updates include the addition of new projects and methods for retrieving models, as well as improved logging. New data structures such as Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add 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: 0
Outside diff range, codebase verification and nitpick comments (8)
Deepgram/Models/Manage/v1/ModelsResponse.cs (1)
1-4
: Add file-level documentation.Consider adding a file-level comment to describe the purpose of this file.
+// This file defines the ModelsResponse record which encapsulates the response for model management APIs.
Deepgram/Models/Manage/v1/Metadata.cs (2)
1-4
: Add file-level documentation.Consider adding a file-level comment to describe the purpose of this file.
+// This file defines the Metadata record which encapsulates various metadata attributes for models.
7-43
: Properties inMetadata
are not utilized in the codebase.The properties
Accent
,Color
,Gender
,Image
, andSample
defined inDeepgram/Models/Manage/v1/Metadata.cs
are not referenced or used elsewhere in the codebase. This indicates that these properties are not being properly utilized, which needs to be addressed.
Deepgram/Models/Manage/v1/Metadata.cs
: PropertiesAccent
,Color
,Gender
,Image
,Sample
.Analysis chain
LGTM! Ensure proper usage in the codebase.
The
Metadata
record is well-defined with nullable properties and appropriate JSON attributes.Ensure that the properties
Accent
,Color
,Gender
,Image
, andSample
are correctly utilized in the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Metadata` properties in the codebase. # Test: Search for the usage of `Metadata` properties. Expect: Proper utilization of `Accent`, `Color`, `Gender`, `Image`, and `Sample`. rg --type cs -A 5 $'Metadata'Length of output: 26913
Script:
#!/bin/bash # Description: Verify the usage of specific `Metadata` properties in the codebase. # Test: Search for the usage of `Accent` property in Metadata. rg --type cs -A 5 'Accent' # Test: Search for the usage of `Color` property in Metadata. rg --type cs -A 5 'Color' # Test: Search for the usage of `Gender` property in Metadata. rg --type cs -A 5 'Gender' # Test: Search for the usage of `Image` property in Metadata. rg --type cs -A 5 'Image' # Test: Search for the usage of `Sample` property in Metadata. rg --type cs -A 5 'Sample'Length of output: 15508
Script:
#!/bin/bash # Description: Verify the usage of specific `Metadata` properties in the codebase. # Test: Search for the usage of `Accent` property in the codebase. rg --type cs 'Accent' # Test: Search for the usage of `Color` property in the codebase. rg --type cs 'Color' # Test: Search for the usage of `Gender` property in the codebase. rg --type cs 'Gender' # Test: Search for the usage of `Image` property in the codebase. rg --type cs 'Image' # Test: Search for the usage of `Sample` property in the codebase. rg --type cs 'Sample'Length of output: 2995
Deepgram/Models/Manage/v1/Tts.cs (1)
31-35
: Fix typographical error in the summary comment.The word "Lanugage" should be corrected to "Language".
- /// Lanugage of the model + /// Language of the modelDeepgram/Models/Manage/v1/ModelResponse.cs (1)
31-35
: Fix typographical error in the summary comment.The word "Lanugage" should be corrected to "Language".
- /// Lanugage of the model + /// Language of the modelDeepgram/Models/Manage/v1/Stt.cs (1)
31-35
: Fix typographical error in the summary comment.The word "Lanugage" should be corrected to "Language".
- /// Lanugage of the model + /// Language of the modelDeepgram/Clients/Manage/v1/Client.cs (2)
126-143
: Update function call to match new signatureThe function call to
GetProjectModels
inexamples/manage/models/Program.cs
needs to be updated to match the new method signature.
- File:
examples/manage/models/Program.cs
- Line: 1
Ensure the function call includes the additional parameters:
CancellationTokenSource? cancellationToken = default, Dictionary<string, string>? addons = null, Dictionary<string, string>? headers = null
.Analysis chain
LGTM! But verify the function usage in the codebase.
The code changes are approved.
However, ensure that all function calls to
GetProjectModels
match the new method signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `GetProjectModels` match the new method signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type cs -A 5 $'GetProjectModels'Length of output: 2421
168-186
: Verify the function usage in the codebase.The code changes are approved, but ensure that all function calls to
GetModels
match the new method signature.
- The usage in
examples/manage/models/Program.cs
does not match the new method signature. Update it to pass the required parameters.- Verify all implementations of
IManageClient
to ensure they match the new signature.Analysis chain
LGTM! But verify the function usage in the codebase.
The code changes are approved.
However, ensure that all function calls to
GetModels
match the new method signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `GetModels` match the new method signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type cs -A 5 $'GetModels'Length of output: 2849
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (14)
- Deepgram.Dev.sln (3 hunks)
- Deepgram/ClientFactory.cs (1 hunks)
- Deepgram/Clients/Interfaces/v1/IManageClient.cs (1 hunks)
- Deepgram/Clients/Manage/v1/Client.cs (3 hunks)
- Deepgram/Clients/Manage/v1/UriSegments.cs (2 hunks)
- Deepgram/Models/Manage/v1/KeySchema.cs (1 hunks)
- Deepgram/Models/Manage/v1/Metadata.cs (1 hunks)
- Deepgram/Models/Manage/v1/ModelResponse.cs (1 hunks)
- Deepgram/Models/Manage/v1/ModelsResponse.cs (1 hunks)
- Deepgram/Models/Manage/v1/Stt.cs (1 hunks)
- Deepgram/Models/Manage/v1/Tts.cs (1 hunks)
- README.md (1 hunks)
- examples/manage/models/Models.csproj (1 hunks)
- examples/manage/models/Program.cs (1 hunks)
Files skipped from review due to trivial changes (4)
- Deepgram/ClientFactory.cs
- Deepgram/Models/Manage/v1/KeySchema.cs
- README.md
- examples/manage/models/Models.csproj
Additional context used
Learnings (1)
Deepgram.Dev.sln (1)
Learnt from: dvonthenen PR: deepgram/deepgram-dotnet-sdk#253 File: Deepgram.Dev.sln:0-0 Timestamp: 2024-03-28T19:45:21.188Z Learning: References to "Prerecorded" and other project names in the documentation and build scripts have been updated as part of the PR changes. Remaining mentions of "Prerecorded" in `Deepgram/README.md`, `examples/README.md`, and `README.md` were noted for potential review.
Additional comments not posted (38)
Deepgram/Models/Manage/v1/ModelsResponse.cs (1)
7-22
: LGTM! Ensure proper usage in the codebase.The
ModelsResponse
record is well-defined with nullable properties and appropriate JSON attributes.Ensure that the properties
Stt
andTts
are correctly utilized in the codebase.Verification successful
Proper usage of
Stt
andTts
properties confirmed.The
Stt
andTts
properties ofModelsResponse
are being correctly utilized in the codebase, specifically in theexamples/manage/models/Program.cs
file.
examples/manage/models/Program.cs
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `ModelsResponse` properties in the codebase. # Test: Search for the usage of `ModelsResponse` properties. Expect: Proper utilization of `Stt` and `Tts`. rg --type cs -A 5 $'ModelsResponse'Length of output: 4213
Script:
#!/bin/bash # Description: Verify the usage of `Stt` and `Tts` properties in the codebase. # Test: Search for the usage of `Stt` property in the codebase. rg --type cs -A 5 '\.Stt' # Test: Search for the usage of `Tts` property in the codebase. rg --type cs -A 5 '\.Tts'Length of output: 1981
Deepgram/Clients/Manage/v1/UriSegments.cs (2)
1-1
: Update the copyright year.The copyright year has been updated to 2024.
20-20
: LGTM! Ensure proper usage of the new constant.The addition of the
MODELS
constant is appropriate for managing model-related URIs.Ensure that the new constant
MODELS
is correctly utilized in the codebase.Verification successful
The new constant
MODELS
is correctly utilized in the codebase.The constant
MODELS
is used appropriately in theDeepgram/Clients/Manage/v1/Client.cs
file for constructing URIs related to model management.
- File:
Deepgram/Clients/Manage/v1/Client.cs
- Lines:
var uri = GetUri(_options, $"{UriSegments.PROJECTS}/{projectId}/{UriSegments.MODELS}");
var uri = GetUri(_options, $"{UriSegments.PROJECTS}/{projectId}/{UriSegments.MODELS}/{modelId}");
var uri = GetUri(_options, $"{UriSegments.MODELS}");
var uri = GetUri(_options, $"{UriSegments.MODELS}/{modelId}");
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new constant `MODELS` in the codebase. # Test: Search for the usage of the `MODELS` constant. Expect: Proper utilization of the `MODELS` constant. rg --type cs -A 5 $'UriSegments.MODELS'Length of output: 2374
Deepgram/Models/Manage/v1/Tts.cs (6)
12-14
: LGTM!The
Name
property is correctly defined with appropriate JSON serialization attributes.
19-21
: LGTM!The
CanonicalName
property is correctly defined with appropriate JSON serialization attributes.
26-28
: LGTM!The
Architecture
property is correctly defined with appropriate JSON serialization attributes.
38-42
: LGTM!The
Version
property is correctly defined with appropriate JSON serialization attributes.
45-49
: LGTM!The
Uuid
property is correctly defined with appropriate JSON serialization attributes.
52-56
: LGTM!The
Metadata
property is correctly defined with appropriate JSON serialization attributes.Deepgram/Models/Manage/v1/ModelResponse.cs (6)
12-14
: LGTM!The
Name
property is correctly defined with appropriate JSON serialization attributes.
19-21
: LGTM!The
CanonicalName
property is correctly defined with appropriate JSON serialization attributes.
26-28
: LGTM!The
Architecture
property is correctly defined with appropriate JSON serialization attributes.
38-42
: LGTM!The
Version
property is correctly defined with appropriate JSON serialization attributes.
45-49
: LGTM!The
Uuid
property is correctly defined with appropriate JSON serialization attributes.
52-56
: LGTM!The
Metadata
property is correctly defined with appropriate JSON serialization attributes.Deepgram/Models/Manage/v1/Stt.cs (8)
12-14
: LGTM!The
Name
property is correctly defined with appropriate JSON serialization attributes.
19-21
: LGTM!The
CanonicalName
property is correctly defined with appropriate JSON serialization attributes.
26-28
: LGTM!The
Architecture
property is correctly defined with appropriate JSON serialization attributes.
38-42
: LGTM!The
Version
property is correctly defined with appropriate JSON serialization attributes.
45-49
: LGTM!The
Uuid
property is correctly defined with appropriate JSON serialization attributes.
52-56
: LGTM!The
Batch
property is correctly defined with appropriate JSON serialization attributes.
59-63
: LGTM!The
Streaming
property is correctly defined with appropriate JSON serialization attributes.
66-70
: LGTM!The
FormattedOutput
property is correctly defined with appropriate JSON serialization attributes.examples/manage/models/Program.cs (7)
1-17
: Initialization and setup look good.The initial setup, including library initialization and logging configuration, is correctly implemented.
18-35
: Client creation and project retrieval look good.The manage client is correctly created, and projects are retrieved with appropriate error handling and logging.
37-57
: Model retrieval and logging look good.The models are correctly retrieved, and the results are logged with appropriate error handling.
59-68
: Specific model retrieval and logging look good.The specific model is correctly retrieved, and the result is logged with appropriate error handling.
70-90
: Project-specific model retrieval and logging look good.The models for a specific project are correctly retrieved, and the results are logged with appropriate error handling.
92-101
: Specific project model retrieval and logging look good.The specific model for a project is correctly retrieved, and the result is logged with appropriate error handling.
103-107
: Library termination and program exit look good.The library is correctly terminated, and the program waits for a key press to exit.
Deepgram/Clients/Interfaces/v1/IManageClient.cs (4)
58-64
:GetProjectModels
method looks good.The method retrieves all models associated with a given project ID with appropriate parameters and return type.
66-73
:GetProjectModel
method looks good.The method retrieves a specific model associated with a given project ID and model ID with appropriate parameters and return type.
76-82
:GetModels
method looks good.The method retrieves all models available in Deepgram with appropriate parameters and return type.
84-90
:GetModel
method looks good.The method retrieves a specific model within Deepgram using the model ID with appropriate parameters and return type.
Deepgram.Dev.sln (2)
158-159
: New project entry formodels
looks good.The new project entry for
models
is correctly added with its corresponding GUID and path.
160-161
: Updated project entry forModels
looks good.The existing project
Models
is correctly updated with a new GUID and path.Deepgram/Clients/Manage/v1/Client.cs (2)
188-207
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
GetModel
match the new method signature.Verification successful
The function usage of
GetModel
matches the new method signature.
examples/manage/models/Program.cs
: TheGetModel
method is called with the requiredmodelId
parameter, and the additional parameters are optional, aligning with the new method signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `GetModel` match the new method signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type cs -A 5 $'GetModel'Length of output: 5177
Script:
#!/bin/bash # Description: Verify that the usage of GetModel in examples/manage/models/Program.cs matches the new method signature. # Test: Search for the function usage and display the surrounding context. rg --type cs -A 10 'GetModel' examples/manage/models/Program.csLength of output: 1363
145-165
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
GetProjectModel
match the new method signature.Verification successful
Ensure all instances of
GetProjectModel
usage match the new method signature.The initial search indicates that the function is used correctly in
examples/manage/models/Program.cs
. However, to be thorough, we should verify that there are no other instances where the function might be used incorrectly.
All instances of
GetProjectModel
usage match the new method signature.The function
GetProjectModel
is used correctly inexamples/manage/models/Program.cs
, and there are no other instances that deviate from the new method signature.
examples/manage/models/Program.cs
: Correct usage with the new method signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `GetProjectModel` match the new method signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type cs -A 5 $'GetProjectModel'Length of output: 4950
Script:
#!/bin/bash # Description: Verify all function calls to `GetProjectModel` match the new method signature across the entire codebase. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type cs -A 5 'GetProjectModel'Length of output: 4950
d2af56a
to
eaa4eec
Compare
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: 2
Outside diff range, codebase verification and nitpick comments (5)
Deepgram/Models/Manage/v1/ModelResponse.cs (1)
31-31
: Correct typographical error in comment.The comment for the
Language
property contains a typographical error: "Lanugage" should be "Language."- /// Lanugage of the model + /// Language of the modelDeepgram/Models/Manage/v1/Stt.cs (1)
31-31
: Fix typo in comment.The word "Lanugages" should be corrected to "Languages."
- /// Lanugages of the model + /// Languages of the modelexamples/manage/models/Program.cs (2)
62-67
: Clarify log message for null model response.The message "No invites found" is misleading in the context of models. Consider updating it to reflect the actual operation.
- Console.WriteLine("No invites found"); + Console.WriteLine("No models found");
98-102
: Clarify log message for null project model response.Update the message to reflect the context of models instead of invites.
- Console.WriteLine("\n\nNo invites found\n\n"); + Console.WriteLine("\n\nNo models found\n\n");Deepgram/Clients/Interfaces/v1/IManageClient.cs (1)
87-87
: Fix parameter name inGetModel
method.The parameter name
projectId
should be corrected tomodelId
to match the method's purpose.- /// <param name="projectId">Id of Model</param> + /// <param name="modelId">Id of Model</param>
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (15)
- Deepgram.Dev.sln (3 hunks)
- Deepgram/ClientFactory.cs (1 hunks)
- Deepgram/Clients/Interfaces/v1/IManageClient.cs (1 hunks)
- Deepgram/Clients/Manage/v1/Client.cs (3 hunks)
- Deepgram/Clients/Manage/v1/UriSegments.cs (2 hunks)
- Deepgram/Models/Manage/v1/KeySchema.cs (1 hunks)
- Deepgram/Models/Manage/v1/Metadata.cs (1 hunks)
- Deepgram/Models/Manage/v1/ModelResponse.cs (1 hunks)
- Deepgram/Models/Manage/v1/ModelSchema.cs (1 hunks)
- Deepgram/Models/Manage/v1/ModelsResponse.cs (1 hunks)
- Deepgram/Models/Manage/v1/Stt.cs (1 hunks)
- Deepgram/Models/Manage/v1/Tts.cs (1 hunks)
- README.md (1 hunks)
- examples/manage/models/Models.csproj (1 hunks)
- examples/manage/models/Program.cs (1 hunks)
Files skipped from review due to trivial changes (4)
- Deepgram/ClientFactory.cs
- Deepgram/Models/Manage/v1/KeySchema.cs
- README.md
- examples/manage/models/Models.csproj
Additional context used
Learnings (1)
Deepgram.Dev.sln (1)
Learnt from: dvonthenen PR: deepgram/deepgram-dotnet-sdk#253 File: Deepgram.Dev.sln:0-0 Timestamp: 2024-03-28T19:45:21.188Z Learning: References to "Prerecorded" and other project names in the documentation and build scripts have been updated as part of the PR changes. Remaining mentions of "Prerecorded" in `Deepgram/README.md`, `examples/README.md`, and `README.md` were noted for potential review.
Additional comments not posted (13)
Deepgram/Models/Manage/v1/ModelsResponse.cs (1)
1-22
: LGTM! TheModelsResponse
record is well-structured.The use of nullable lists with JSON serialization attributes is appropriate and aligns with best practices.
Deepgram/Models/Manage/v1/ModelSchema.cs (1)
1-23
: LGTM! TheModelSchema
class is well-implemented.The use of
JsonSerializer
in theToString
method is a practical approach for serialization, and the handling of nullable properties is consistent.Deepgram/Clients/Manage/v1/UriSegments.cs (1)
Line range hint
1-20
:
LGTM! The addition ofMODELS
constant is consistent.Defining URI segments as constants helps maintain consistency and ease of change across the SDK.
Deepgram/Models/Manage/v1/Metadata.cs (1)
1-43
: Well-structured Metadata record.The
Metadata
record is well-structured, using nullable types and JSON attributes effectively for optional fields. This facilitates flexible JSON serialization and deserialization.Deepgram/Models/Manage/v1/Tts.cs (1)
1-57
: Consistent use of JSON attributes in Tts record.The
Tts
record is well-designed, with consistent use of nullable types and JSON attributes for optional fields. The inclusion of a nestedMetadata
object is handled correctly.Deepgram/Models/Manage/v1/ModelResponse.cs (1)
1-57
: Well-structured ModelResponse record.The
ModelResponse
record is well-structured, with appropriate use of nullable types and JSON attributes for optional fields. The design aligns with best practices for JSON serialization.examples/manage/models/Program.cs (1)
41-45
: Improve null check handling.Similar to the previous suggestion, consider using
??
to handle null values gracefully instead of exiting the application.- if (modelListResp == null) - { - Console.WriteLine("GetModels failed."); - Environment.Exit(1); - } + if (modelListResp == null) + { + Console.WriteLine("GetModels failed. Exiting..."); + return; + }Likely invalid or redundant comment.
Deepgram.Dev.sln (2)
158-159
: LGTM: New project "models" added.The addition of the "models" project is clear and follows the standard format for solution files.
160-161
: LGTM: New project "Models" added.The addition of the "Models" project appears well-integrated and follows the expected solution structure.
Deepgram/Clients/Manage/v1/Client.cs (4)
150-170
: LGTM: MethodGetProjectModel
is correctly implemented.The method includes detailed logging and handles parameters effectively.
173-196
: LGTM: MethodGetModels
is well-implemented.The method is well-structured, with comprehensive logging and parameter handling.
Ensure that the
ModelSchema
default initialization aligns with expected behavior.
198-217
: LGTM: MethodGetModel
is correctly implemented.The method includes detailed logging and handles parameters effectively.
126-148
: LGTM: MethodGetProjectModels
is well-implemented.The method is well-structured, with comprehensive logging and parameter handling.
Ensure that the
ModelSchema
default initialization aligns with expected behavior.Verification successful
ModelSchema Default Initialization is Appropriate
The
ModelSchema
class's default initialization aligns with its intended use inGetProjectModels
. TheIncludeOutdated
property is nullable and ignored when null, which is suitable for the method's requirements.
ModelSchema.cs
: The default state ofModelSchema
is appropriate for its usage in methods likeGetProjectModels
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage and initialization of ModelSchema in the codebase. # Test: Search for ModelSchema usage. Expect: Proper initialization and usage. rg --type cs 'ModelSchema'Length of output: 1323
Script:
#!/bin/bash # Description: Retrieve the definition of the ModelSchema class to verify its default initialization. # Test: Extract the ModelSchema class definition. ast-grep --lang csharp --pattern 'class ModelSchema { $$$ }'Length of output: 62
Script:
#!/bin/bash # Description: Search for the definition of the ModelSchema class using rg. # Test: Find the definition of the ModelSchema class. rg --type cs 'class ModelSchema'Length of output: 100
Script:
#!/bin/bash # Description: Extract the contents of ModelSchema.cs to review its implementation. # Test: Display the contents of ModelSchema.cs to verify its default initialization. cat Deepgram/Models/Manage/v1/ModelSchema.csLength of output: 775
Proposed changes
Implements the Models API. Example in
examples/manage/models
.Types of changes
What types of changes does your code introduce to the community .NET SDK?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
NA
Summary by CodeRabbit
New Features
ModelResponse
,ModelsResponse
,Stt
, andTts
added to support better model configuration and responses.Documentation
Chores