-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat:Title: Update documentation for API endpoints and usage examples #32
Conversation
WalkthroughThe pull request introduces several new functionalities to the AI21 API, including methods for creating messages and threads, retrieving thread run results, and managing user data sources and tokens. New classes and methods are defined to facilitate these operations, enhancing the API's capabilities for interaction and data handling. Changes
Possibly related PRs
Poem
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (12)
src/libs/AI21/Generated/AI21.Models.RunOptimization.g.cs (2)
11-17
: Add XML documentation comments for the enum values.The XML documentation comments for the
Cost
andLatency
enum values are empty. Please provide a clear description of what each value represents to improve the code documentation and maintainability.
41-49
: Consider making the method case-insensitive.The
ToEnum
method is correctly implemented and follows best practices. However, to improve the user experience and handle different casing of the string values, consider making the method case-insensitive.You can achieve this by converting the input string to lowercase before the switch expression:
public static RunOptimization? ToEnum(string value) { + value = value.ToLowerInvariant(); return value switch { "cost" => RunOptimization.Cost, "latency" => RunOptimization.Latency, _ => null, }; }
src/libs/AI21/Generated/AI21.Models.LibrarySearchRequestLabelsFilterMode.g.cs (1)
9-19
: Add meaningful XML comments for the enum values.The enum is correctly defined, and the default value comment is helpful. However, consider adding meaningful XML comments for the
AND
andOR
enum values to provide more context about their usage.src/libs/AI21/Generated/AI21.Models.PostThreadRunRequest.g.cs (1)
33-37
: Consider using a more specific type for theAdditionalProperties
property.The
AdditionalProperties
property is of typeIDictionary<string, object>
, which allows storing anyobject
value. Consider using a more specific type, if possible, to provide better type safety and code clarity.src/libs/AI21/Generated/AI21.Models.CreateMessageRequest.g.cs (1)
27-32
: Add a description to the XML documentation comment.The
Content
property is correctly defined with therequired
keyword andstring
type. The property is also correctly annotated withJsonPropertyName
andJsonRequired
attributes. However, the XML documentation comment is empty.Add a description to the XML documentation comment to provide information about the property. For example:
/// <summary> +/// The content of the message. /// </summary>
src/libs/AI21/Generated/AI21.Models.CreateThreadResponse.g.cs (1)
6-8
: Fill in the missing XML documentation comments.Most of the XML documentation comments for the class and its properties are empty. It's important to provide meaningful documentation for better code readability and maintainability.
Fill in the missing XML documentation comments to describe the purpose and details of the class and its properties. For example:
/// <summary> /// Represents the response object returned when creating a new thread. /// </summary> public sealed partial class CreateThreadResponse { // ... /// <summary> /// Gets or sets the date and time when the thread was created. /// </summary> [global::System.Text.Json.Serialization.JsonPropertyName("created_at")] [global::System.Text.Json.Serialization.JsonRequired] public required global::System.DateTime CreatedAt { get; set; } // ... }Also applies to: 20-22, 27-29, 34-36
src/libs/AI21/Generated/AI21.Models.DataSourceMetadata.g.cs (1)
6-51
: LGTM, but consider adding meaningful XML documentation comments.The
DataSourceMetadata
class is well-structured and follows the necessary conventions. However, the XML documentation comments are empty and do not provide any useful information about the class. Consider adding meaningful descriptions to enhance the code's readability and maintainability.src/libs/AI21/Generated/AI21.Models.RunStatus.g.cs (1)
6-47
: Add XML comments for better code documentation.The
RunStatus
enum is well-defined with appropriate values covering common run statuses. However, the XML comments for the enum and its values are empty, which reduces the code documentation quality.Consider adding meaningful XML comments to describe the purpose of the enum and each of its values. This will enhance the code documentation and make it easier for other developers to understand the code.
src/libs/AI21/Generated/AI21.Models.CreateMessageResponse.g.cs (1)
11-22
: Consider adding a brief description for theRole
property.While the XML documentation comment for the
Role
property provides detailed information about the possible values and their meanings, it would be beneficial to include a brief one-line description summarizing the purpose of the property. This would provide a quick overview for developers reading the code./// <summary> +/// Represents the role of an individual message in the conversation. /// The role of an individual message.<br/> /// - `user`: Input provided by the user. Any instructions given here that conflict<br/> /// with instructions given in the `system` prompt take precedence over the `system`<br/> /// prompt instructions.<br/> /// - `assistant`: Response generated by the model.<br/> /// - `system`: Initial instructions provided to the system to provide general guidance<br/> /// on the tone and voice of the generated message. An initial system message is<br/> /// optional but recommended to provide guidance on the tone of the chat. For<br/> /// example, "You are a helpful chatbot with a background in earth sciences and a<br/> /// charming French accent." /// </summary>
src/libs/AI21/Generated/AI21.Models.PostThreadRunResponse.g.cs (3)
11-16
: Consider removing the redundantJsonRequired
attribute.The property definition looks good. The use of
required
keyword ensures the property will always have a non-null value.However, the
JsonRequired
attribute is redundant here as therequired
keyword already ensures the property is non-nullable. Consider removing it for cleaner code.[global::System.Text.Json.Serialization.JsonPropertyName("thread_id")] - [global::System.Text.Json.Serialization.JsonRequired] public required string ThreadId { get; set; }
32-38
: Consider removing the redundantJsonRequired
attribute.The property definition looks good. The use of an enumeration for the
Status
property is a good practice to restrict the possible values.However, as with the previous properties, the
JsonRequired
attribute is redundant here as therequired
keyword already ensures the property is non-nullable. Consider removing it for cleaner code.[global::System.Text.Json.Serialization.JsonPropertyName("status")] [global::System.Text.Json.Serialization.JsonConverter(typeof(global::OpenApiGenerator.JsonConverters.RunStatusJsonConverter))] - [global::System.Text.Json.Serialization.JsonRequired] public required global::AI21.RunStatus Status { get; set; }
57-69
: Consider removing the redundantJsonRequired
attribute.The
CreatedAt
andUpdatedAt
property definitions look good. The use ofDateTime
type is appropriate to represent timestamps.However, as with the previous properties, the
JsonRequired
attribute is redundant here as therequired
keyword already ensures the properties are non-nullable. Consider removing it for cleaner code.[global::System.Text.Json.Serialization.JsonPropertyName("created_at")] - [global::System.Text.Json.Serialization.JsonRequired] public required global::System.DateTime CreatedAt { get; set; } [global::System.Text.Json.Serialization.JsonPropertyName("updated_at")] - [global::System.Text.Json.Serialization.JsonRequired] public required global::System.DateTime UpdatedAt { get; set; }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (36)
- src/libs/AI21/Generated/AI21.Ai21Api.CreateMessageStudioV1AssistantThreadsThreadIdMessagesPost.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Ai21Api.CreateThreadStudioV1AssistantThreadsPost.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Ai21Api.GetThreadRunResultStudioV1AssistantThreadsThreadIdRunsRunIdGet.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Ai21Api.GetUserDataSourcesInfoStudioV1ConnectorsConnectedUsersUserIdDataSourcesGet.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Ai21Api.GetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPost.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Ai21Api.PostThreadRunStudioV1AssistantThreadsThreadIdRunsPost.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.ConnectorsDataSources.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.ConnectorsToken.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.CreateMessageRequest.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.CreateMessageResponse.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.CreateThreadRequest.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.CreateThreadResponse.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.DataSourceMetadata.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.GetThreadRunResponse.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.LibraryAnswerRequest.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.LibraryAnswerRequestLabelsFilterMode.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.LibrarySearchRequest.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.LibrarySearchRequestLabelsFilterMode.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.PostThreadRunRequest.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.PostThreadRunResponse.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.RunOptimization.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.RunStatus.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.Models.ThreadMessage.g.cs (1 hunks)
- src/libs/AI21/Generated/AI21.RAGEngineClient.V1LibraryAnswer.g.cs (3 hunks)
- src/libs/AI21/Generated/AI21.RAGEngineClient.V1LibrarySearch.g.cs (3 hunks)
- src/libs/AI21/Generated/JsonConverters.LibraryAnswerRequestLabelsFilterMode.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonConverters.LibraryAnswerRequestLabelsFilterModeNullable.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonConverters.LibrarySearchRequestLabelsFilterMode.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonConverters.LibrarySearchRequestLabelsFilterModeNullable.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonConverters.RunOptimization.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonConverters.RunOptimizationNullable.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonConverters.RunStatus.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonConverters.RunStatusNullable.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonSerializerContext.g.cs (1 hunks)
- src/libs/AI21/Generated/JsonSerializerContextTypes.g.cs (1 hunks)
- src/libs/AI21/openapi.yaml (11 hunks)
Additional comments not posted (89)
src/libs/AI21/Generated/AI21.Models.ConnectorsToken.g.cs (1)
1-24
: LGTM!The
ConnectorsToken
class is well-defined and follows best practices:
- The class is appropriately marked as
sealed partial
for a generated class.- Nullable reference types are enabled to catch potential null reference exceptions.
- The
Token
property is marked asrequired
, ensuring it is always set during deserialization.- The
AdditionalProperties
property is marked with[JsonExtensionData]
to handle additional properties flexibly.- The class follows standard naming conventions and has appropriate XML documentation comments.
Great job!
src/libs/AI21/Generated/AI21.Models.CreateThreadRequest.g.cs (1)
1-23
: LGTM!The
CreateThreadRequest
class is well-defined and follows good practices:
- The class is
sealed partial
, which is suitable for generated code files.- The
Messages
property is nullable, aligning with the#nullable enable
directive.- The
AdditionalProperties
property withJsonExtensionData
attribute provides flexibility to handle evolving JSON schemas.- The class and properties have XML documentation comments, enhancing code readability and API documentation generation.
- The class follows standard naming conventions and the file is properly organized.
Great job!
src/libs/AI21/Generated/AI21.Models.ConnectorsDataSources.g.cs (3)
9-23
: LGTM!The class definition looks good. The use of
sealed
andpartial
modifiers is appropriate for a generated model class.
14-16
: LGTM!The
DataSources
property is correctly defined with the appropriate type, modifiers, and attributes.
21-22
: LGTM!The
AdditionalProperties
property is correctly defined with the appropriate type, attribute, and initialization.src/libs/AI21/Generated/AI21.Models.RunOptimization.g.cs (1)
29-37
: LGTM!The
ToValueString
method is correctly implemented and follows best practices. The switch expression provides a clean and efficient way to map the enum values to their string representations, and theArgumentOutOfRangeException
ensures that invalid enum values are handled appropriately.src/libs/AI21/Generated/AI21.Models.LibraryAnswerRequestLabelsFilterMode.g.cs (3)
9-19
: LGTM!The enum is well-defined with appropriate values and a default value. The naming is clear and self-explanatory.
29-37
: LGTM!The
ToValueString
method is well-implemented using a switch expression to map the enum values to their string representations. The method also correctly handles invalid enum values by throwing anArgumentOutOfRangeException
.
41-49
: LGTM!The
ToEnum
method is well-implemented using a switch expression to map the string values to their corresponding enum values. The method also correctly handles invalid string values by returningnull
.src/libs/AI21/Generated/AI21.Models.LibrarySearchRequestLabelsFilterMode.g.cs (2)
29-37
: LGTM!The
ToValueString
method is correctly implemented using a switch expression and handles all possible enum values by throwing anArgumentOutOfRangeException
for invalid values.
41-49
: LGTM!The
ToEnum
method is correctly implemented using a switch expression and handles all possible string values by returningnull
for invalid values.src/libs/AI21/Generated/AI21.Models.PostThreadRunRequest.g.cs (2)
1-39
: ThePostThreadRunRequest
class is well-defined and follows best practices.The class definition is clear, concise, and follows C# naming conventions. The use of attributes for JSON serialization is appropriate, and the
sealed
andpartial
modifiers are used correctly.
28-31
: Verify the custom JSON converter for theOptimization
property.The
Optimization
property uses a custom JSON converterRunOptimizationJsonConverter
. Ensure that the converter is implemented correctly and handles the serialization and deserialization of theRunOptimization
enumeration properly.Verification successful
Verification Successful: Custom JSON Converter Implementation
The
RunOptimizationJsonConverter
class is correctly implemented to handle the serialization and deserialization of theRunOptimization
enum. Both theRead
andWrite
methods are present and utilize appropriate logic for converting the enum to and from JSON.
- The
Read
method processes JSON tokens and deserializes them into theRunOptimization
type.- The
Write
method serializes theRunOptimization
enum to a string using an extension method.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the `RunOptimizationJsonConverter`. # Test: Search for the `RunOptimizationJsonConverter` class. # Expect: The class should be defined and implement the `JsonConverter<RunOptimization>` interface. rg --type cs $'class RunOptimizationJsonConverter'Length of output: 249
Script:
#!/bin/bash # Description: Extract the implementation details of the `RunOptimizationJsonConverter` class. # Use ast-grep to find the implementation of the `RunOptimizationJsonConverter` class. ast-grep --lang csharp --pattern $'class RunOptimizationJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::AI21.RunOptimization> { $$$ }'Length of output: 166
Script:
#!/bin/bash # Description: Extract method implementations of the `RunOptimizationJsonConverter` class. # Use rg to find method definitions within the `RunOptimizationJsonConverter` class. rg --type cs -A 10 'class RunOptimizationJsonConverter'Length of output: 1256
Script:
#!/bin/bash # Description: Extract the `Write` method implementation of the `RunOptimizationJsonConverter` class. # Use rg to find the `Write` method within the `RunOptimizationJsonConverter` class. rg --type cs -A 10 'public override void Write' src/libs/AI21/Generated/JsonConverters.RunOptimization.g.csLength of output: 543
src/libs/AI21/Generated/AI21.Models.ThreadMessage.g.cs (1)
1-40
: TheThreadMessage
class structure and properties look good!The class is well-defined with clear properties and XML documentation explaining their purpose. The
Role
andContent
properties capture the essential information for a thread message, while theAdditionalProperties
property allows for flexibility in storing extra metadata.Just a friendly reminder that since this file appears to be auto-generated (based on the
.g.cs
extension), any direct modifications made here might be overwritten when the file is regenerated. If changes are needed, it's best to update the source file or adjust the generation tool configuration.src/libs/AI21/Generated/AI21.Models.CreateMessageRequest.g.cs (2)
11-25
: LGTM!The
Role
property is correctly defined with therequired
keyword andstring
type. The XML documentation comment provides clear and detailed information about the property. The property is also correctly annotated withJsonPropertyName
andJsonRequired
attributes.
34-38
: LGTM!The
AdditionalProperties
property is correctly defined as a dictionary of string keys and object values. The XML documentation comment provides a clear explanation of the purpose of the property. The property is also correctly annotated with theJsonExtensionData
attribute to store additional properties.src/libs/AI21/Generated/JsonConverters.RunStatus.g.cs (2)
9-36
: LGTM!The
Read
method correctly handles the deserialization of theRunStatus
enum based on the JSON token type. The use of theToEnum
extension method ensures proper conversion of the string value to the corresponding enum value. The method also provides a default value if the deserialization fails or the token type is not supported.
39-47
: LGTM!The
Write
method correctly serializes theRunStatus
enum to a JSON string value using theToValueString
extension method. The null check for thewriter
parameter ensures that the method fails fast if the writer is not provided.src/libs/AI21/Generated/AI21.Models.CreateThreadResponse.g.cs (1)
1-47
: The class structure and serialization attributes look good!The
CreateThreadResponse
class is well-structured with appropriate properties and JSON serialization attributes. TheAdditionalProperties
property is a nice addition to handle properties not explicitly defined in the schema. Thesealed
andpartial
modifiers are used appropriately.src/libs/AI21/Generated/AI21.Models.DataSourceMetadata.g.cs (6)
11-17
: LGTM!The
Name
property is correctly defined with the appropriate attributes and type.
18-24
: LGTM!The
Type
property is correctly defined with the appropriate attributes and type.
25-31
: LGTM!The
Description
property is correctly defined with the appropriate attributes and type.
32-38
: LGTM!The
Icon
property is correctly defined with the appropriate attributes and type.
39-45
: LGTM!The
Connected
property is correctly defined with the appropriate attributes and type.
46-50
: LGTM!The
AdditionalProperties
property is correctly defined with the appropriate attribute, type, and initialization. The XML documentation comment provides a clear explanation of its purpose.src/libs/AI21/Generated/JsonConverters.RunOptimization.g.cs (2)
9-36
: LGTM!The
Read
method correctly handles deserialization of theRunOptimization
enum from both string and number JSON token types. The usage of theToEnum
extension method ensures that the string value is correctly mapped to the corresponding enum value. The method also throws an appropriate exception for unsupported token types.
39-47
: LGTM!The
Write
method correctly serializes theRunOptimization
enum value to its string representation using theToValueString
extension method. The null check for thewriter
parameter ensures that the method fails fast if the writer is not provided.src/libs/AI21/Generated/JsonConverters.RunStatusNullable.g.cs (2)
9-36
: LGTM!The
Read
method correctly handles deserialization ofRunStatus?
enum values from both string and number JSON token types. The usage of theRunStatusExtensions.ToEnum
method for string tokens ensures proper conversion to the corresponding enum value. The method also appropriately throws an exception for unsupported token types.
39-54
: LGTM!The
Write
method correctly handles serialization ofRunStatus?
enum values to JSON. It appropriately checks for null values and writes a null JSON value in that case. For non-null values, it uses theRunStatusExtensions.ToValueString
method to convert the enum value to its string representation and writes it as a JSON string value. The null check for thewriter
parameter ensures proper error handling.src/libs/AI21/Generated/JsonConverters.LibraryAnswerRequestLabelsFilterMode.g.cs (1)
6-48
: LGTM!The custom JSON converter for the
LibraryAnswerRequestLabelsFilterMode
enum is implemented correctly:
- The
Read
method properly handles deserialization from both string and number representations of the enum.- The
Write
method correctly serializes the enum to its string representation.- The class follows the expected structure and conventions for a custom JSON converter in C#.
Great job!
src/libs/AI21/Generated/JsonConverters.LibrarySearchRequestLabelsFilterMode.g.cs (1)
1-49
: LGTM!The custom JSON converter for the
LibrarySearchRequestLabelsFilterMode
enum is implemented correctly and follows best practices:
- It handles both string and number representations of the enum values.
- It performs proper error handling and null checks.
- It is a sealed class to prevent unintended inheritance and improve performance.
- It follows the standard naming conventions and is well-structured.
The code is clean, efficient, and ready to be merged.
src/libs/AI21/Generated/JsonConverters.RunOptimizationNullable.g.cs (2)
9-36
: LGTM!The
Read
method correctly handles deserialization of nullableRunOptimization
values from both string and number JSON token types. The use of theToEnum
extension method ensures that the string value is correctly mapped to the corresponding enum value. The method also throws an appropriate exception for unsupported token types.
39-54
: LGTM!The
Write
method correctly handles serialization of nullableRunOptimization
values to JSON. The null check for the writer ensures that the method fails fast if the writer is not provided. The method correctly writes a null value for nullRunOptimization
values. The use of theToValueString
extension method ensures that the enum value is correctly converted to its string representation for serialization.src/libs/AI21/Generated/JsonConverters.LibraryAnswerRequestLabelsFilterModeNullable.g.cs (2)
9-36
: LGTM!The
Read
method is correctly handling the deserialization of the enum based on the JSON token type. It covers all possible scenarios and falls back to the default value when needed. The implementation looks good.
39-54
: LGTM!The
Write
method is correctly handling the serialization of the enum. It properly checks for null values and writes the string representation of the enum value when not null. The implementation looks good.src/libs/AI21/Generated/JsonConverters.LibrarySearchRequestLabelsFilterModeNullable.g.cs (1)
1-56
: LGTM!The JSON converter class implementation looks good and follows the expected structure and conventions. The
Read
andWrite
methods handle the serialization and deserialization of theAI21.LibrarySearchRequestLabelsFilterMode
enum type correctly.To ensure the correctness of the enum value conversions, please verify that the
AI21.LibrarySearchRequestLabelsFilterModeExtensions
class is implemented properly with theToEnum
andToValueString
methods. You can use the following script to search for the implementation:Verification successful
Enum Conversion Methods Verified
The
LibrarySearchRequestLabelsFilterModeExtensions
class contains theToEnum
andToValueString
methods, which are correctly implemented to handle conversions between string values and theLibrarySearchRequestLabelsFilterMode
enum. This confirms the functionality required by the JSON converter class.
src/libs/AI21/Generated/AI21.Models.LibrarySearchRequestLabelsFilterMode.g.cs
: Contains the implementation ofToEnum
andToValueString
methods.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the enum conversion methods. # Test: Search for the `ToEnum` method implementation. # Expect: The method should convert a string value to the corresponding enum value. ast-grep --lang csharp --pattern $'class LibrarySearchRequestLabelsFilterModeExtensions { $$$ ToEnum(string $_) { $$$ } $$$ }' # Test: Search for the `ToValueString` method implementation. # Expect: The method should convert an enum value to its string representation. ast-grep --lang csharp --pattern $'class LibrarySearchRequestLabelsFilterModeExtensions { $$$ ToValueString(LibrarySearchRequestLabelsFilterMode $_) { $$$ } $$$ }'Length of output: 1006
Script:
#!/bin/bash # Description: Use ripgrep to search for the `LibrarySearchRequestLabelsFilterModeExtensions` class and its methods. # Search for the `LibrarySearchRequestLabelsFilterModeExtensions` class definition. rg 'class\s+LibrarySearchRequestLabelsFilterModeExtensions' -A 10 # Search for the `ToEnum` method within the `LibrarySearchRequestLabelsFilterModeExtensions` class. rg 'ToEnum\s*\(' -A 5 # Search for the `ToValueString` method within the `LibrarySearchRequestLabelsFilterModeExtensions` class. rg 'ToValueString\s*\(' -A 5Length of output: 92823
src/libs/AI21/Generated/AI21.Models.RunStatus.g.cs (2)
57-72
: LGTM!The
ToValueString
method correctly converts theRunStatus
enum to its string representation using a switch expression. It covers all possible enum values and throws an appropriate exception for any invalid value.
76-91
: LGTM!The
ToEnum
method correctly converts a string to its correspondingRunStatus
enum value using a switch expression. It covers all possible string values and returns null for any invalid value.src/libs/AI21/Generated/AI21.Models.LibrarySearchRequest.g.cs (1)
38-43
: LGTM!The addition of the
LabelsFilterMode
property to theLibrarySearchRequest
class looks good. It provides a useful feature for controlling the label filtering behavior during searches. The property is properly annotated for JSON serialization, and the default value ofAND
is sensible. The code changes are also well-documented with XML comments.src/libs/AI21/Generated/AI21.Models.CreateMessageResponse.g.cs (1)
1-70
: TheCreateMessageResponse
class is well-structured and follows best practices.The class definition adheres to C# conventions, utilizes appropriate attributes for JSON serialization, and includes clear XML documentation comments for each property. The use of the
sealed
andpartial
keywords, along with the#nullable enable
directive andrequired
keyword, demonstrates a good understanding of C# language features and promotes code quality.src/libs/AI21/Generated/AI21.Models.GetThreadRunResponse.g.cs (1)
1-84
: TheGetThreadRunResponse
class looks good overall!The class appears to be a generated model class for deserializing a JSON response from an API. It follows standard C# naming conventions and has appropriate JSON serialization attributes. The use of the
required
keyword ensures that the properties are non-nullable and must be present in the JSON response. TheJsonExtensionData
attribute is used effectively to handle additional properties in the JSON that are not explicitly defined in the class.The class is well-structured and the XML documentation comments provide clear descriptions for each property.
src/libs/AI21/Generated/AI21.Models.PostThreadRunResponse.g.cs (6)
4-10
: LGTM!The class definition looks good. The use of
sealed
andpartial
keywords is appropriate for a model class.
18-23
: See the previous comment.The same comments as for the
ThreadId
property apply here.
25-30
: See the previous comment.The same comments as for the
ThreadId
property apply here.
40-46
: See the previous comment.The same comments as for the
Status
property apply here.
48-55
: See the previous comment.The same comments as for the
ThreadId
property apply here. The XML documentation comment provides useful information about theId
property.
71-82
: LGTM!The
Object
property definition looks good, and the same comments as for theThreadId
property apply here.The
AdditionalProperties
property is used to store any additional properties present in the JSON that are not explicitly defined in the class. TheJsonExtensionData
attribute is used to indicate that this property should be used to store these additional properties. This is a good practice to handle scenarios where the JSON may contain properties that are not known at compile time.src/libs/AI21/Generated/AI21.Models.LibraryAnswerRequest.g.cs (1)
38-43
: LGTM!The new
LabelsFilterMode
property is a great addition to theLibraryAnswerRequest
class. It provides flexibility in specifying how labels should be combined when processing requests.The code segment is well-documented, follows the coding style and conventions used in the file, and uses appropriate attributes for JSON serialization. The default value of
AND
for theLabelsFilterMode
property seems reasonable.src/libs/AI21/Generated/AI21.Ai21Api.GetUserDataSourcesInfoStudioV1ConnectorsConnectedUsersUserIdDataSourcesGet.g.cs (1)
1-89
: LGTM!The generated API client code follows standard practices and conventions. It provides a clean and well-documented method for retrieving user data sources info. The use of partial methods allows customizing the behavior without modifying the generated code. The error handling and response deserialization are implemented correctly.
I didn't find any issues with the code. Great job!
src/libs/AI21/Generated/AI21.Ai21Api.GetThreadRunResultStudioV1AssistantThreadsThreadIdRunsRunIdGet.g.cs (1)
1-95
: LGTM!The generated code follows best practices and has no issues. The method signature and XML documentation are clear and follow C# naming conventions. The method handles exceptions and ensures a successful status code. The method deserializes the response content into a
GetThreadRunResponse
object. The partial methods allow for customization and extension of the generated code.src/libs/AI21/Generated/AI21.Ai21Api.CreateThreadStudioV1AssistantThreadsPost.g.cs (2)
30-95
: LGTM!The
CreateThreadStudioV1AssistantThreadsPostAsync
method follows the standard pattern for sending HTTP requests and processing responses in C#. It uses theEnsureSuccessStatusCode
method to handle error responses and theSystem.Text.Json
serializer for JSON serialization and deserialization. The method is well-structured and easy to understand.
105-117
: LGTM!The second overload of the
CreateThreadStudioV1AssistantThreadsPostAsync
method provides a convenient way to call the first overload without having to create aCreateThreadRequest
object explicitly. It uses optional parameters to allow the caller to omit theIList<ThreadMessage>
parameter if it is not needed. The method is a good addition to the API and improves its usability.src/libs/AI21/Generated/JsonSerializerContext.g.cs (8)
44-44
: LGTM!Adding the
RunStatusJsonConverter
enables proper serialization and deserialization ofRunStatus
enum values.
45-45
: LGTM!Adding the
RunStatusNullableJsonConverter
enables proper handling of null values when serializing and deserializing nullableRunStatus
enum.
46-46
: LGTM!Adding the
RunOptimizationJsonConverter
enables proper serialization and deserialization ofRunOptimization
enum values.
47-47
: LGTM!Adding the
RunOptimizationNullableJsonConverter
enables proper handling of null values when serializing and deserializing nullableRunOptimization
enum.
48-48
: LGTM!Adding the
LibraryAnswerRequestLabelsFilterModeJsonConverter
enables proper serialization and deserialization of filter mode values in library answer requests.
49-49
: LGTM!Adding the
LibraryAnswerRequestLabelsFilterModeNullableJsonConverter
enables proper handling of null values when serializing and deserializing nullable filter mode values in library answer requests.
52-52
: LGTM!Adding the
LibrarySearchRequestLabelsFilterModeJsonConverter
enables proper serialization and deserialization of filter mode values in library search requests.
53-53
: LGTM!Adding the
LibrarySearchRequestLabelsFilterModeNullableJsonConverter
enables proper handling of null values when serializing and deserializing nullable filter mode values in library search requests.src/libs/AI21/Generated/AI21.RAGEngineClient.V1LibrarySearch.g.cs (2)
104-106
: LGTM!The addition of the optional
labelsFilterMode
parameter enhances the functionality of the library search by allowing more granular control over label filtering. The XML documentation comment provides a clear description, and the default value ensures backward compatibility.
123-123
: Looks good!The
labelsFilterMode
parameter is correctly included in theLibrarySearchRequest
object, ensuring that the new functionality is properly utilized in the search request.Also applies to: 137-137
src/libs/AI21/Generated/AI21.Ai21Api.PostThreadRunStudioV1AssistantThreadsThreadIdRunsPost.g.cs (1)
1-134
: LGTM!The generated code for making HTTP requests to the AI21 API endpoint is well-structured and follows best practices. The use of partial methods allows for customization of the request and response processing, and the code handles exceptions and ensures a successful response status code.
Since this is a generated file, it should not be modified directly. The code looks good as is.
src/libs/AI21/Generated/AI21.RAGEngineClient.V1LibraryAnswer.g.cs (2)
104-106
: LGTM!The addition of the
labelsFilterMode
parameter with a default value ofAND
is a good enhancement to theV1LibraryAnswerAsync
method. It allows for more granular control over how labels are filtered when processing the library answer response content, while maintaining the existing behavior if the parameter is not explicitly provided.
126-126
: Looks good!The
labelsFilterMode
parameter is correctly incorporated into the method signature and assigned to the corresponding property in the request object. The changes are consistent with the introduction of the new parameter.Also applies to: 141-141
src/libs/AI21/Generated/AI21.Ai21Api.CreateMessageStudioV1AssistantThreadsThreadIdMessagesPost.g.cs (1)
1-140
: The code looks good and follows best practices.
- The code follows a standard pattern for making HTTP requests using
HttpClient
.- The partial methods allow for customization of the request and response processing.
- The code handles exceptions and ensures a successful response status code.
- The code is generated and follows a consistent naming convention.
- The code is well-documented with XML comments.
src/libs/AI21/Generated/JsonSerializerContextTypes.g.cs (10)
208-210
: Verify the impact of the property type change.The property
Type48
has been changed fromglobal::System.Collections.Generic.IList<global::AI21.Message>?
toglobal::System.Collections.Generic.IList<global::AI21.DataSourceMetadata>?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.Verification successful
No impact on the rest of the codebase.
The property
Type48
is not used elsewhere in the codebase, indicating that the change in its type does not affect other parts of the application. This suggests that the property might be newly introduced or not yet integrated into other components.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Type48` property and its new type `global::System.Collections.Generic.IList<global::AI21.DataSourceMetadata>?` in the codebase. # Test: Search for the usage of `Type48` property. Expect: Only occurrences with the new type. rg --type cs -A 5 $'Type48'Length of output: 622
Script:
#!/bin/bash # Description: Conduct a comprehensive search for the usage of `Type48` in the codebase to verify its impact. # Test: Search for any usage of `Type48` in the codebase. rg --type cs 'Type48'Length of output: 188
212-214
: Verify the impact of the property type change.The property
Type49
has been changed fromglobal::AI21.Message?
toglobal::AI21.DataSourceMetadata?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.Verification successful
No further impact found for the property type change.
The property
Type49
with the new typeglobal::AI21.DataSourceMetadata?
is only present in the filesrc/libs/AI21/Generated/JsonSerializerContextTypes.g.cs
and is not used elsewhere in the codebase. This indicates that the change does not affect other parts of the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Type49` property and its new type `global::AI21.DataSourceMetadata?` in the codebase. # Test: Search for the usage of `Type49` property. Expect: Only occurrences with the new type. rg --type cs -A 5 $'Type49'Length of output: 577
Script:
#!/bin/bash # Description: Search for the usage of `Type49` property across the entire codebase to verify consistency with the new type. # Test: Search for the usage of `Type49` property. Expect: Consistent usage with the new type. rg --type cs -A 5 'Type49'Length of output: 577
228-230
: Verify the impact of the property type change.The property
Type53
has been changed fromglobal::System.Collections.Generic.IList<global::AI21.ConversationalRagSource>?
toglobal::AI21.Message?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.Verification successful
Verification successful: No impact found from the property type change.
The property
Type53
has been changed toglobal::AI21.Message?
, and there are no other references to this property in the codebase. This indicates that the change does not affect other parts of the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Type53` property and its new type `global::AI21.Message?` in the codebase. # Test: Search for the usage of `Type53` property. Expect: Only occurrences with the new type. rg --type cs -A 5 $'Type53'Length of output: 562
Script:
#!/bin/bash # Description: Search for all occurrences of `Type53` in the codebase to verify its usage and ensure the type change is handled. # Search for all occurrences of `Type53` in C# files. rg --type cs 'Type53'Length of output: 135
220-222
: Verify the impact of the property type change.The property
Type51
has been changed fromglobal::AI21.ConversationalRagFlowPublicFieldsRetrievalStrategy?
toglobal::AI21.ConversationalRagFlowPublicFields?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.Verification successful
No further impact found for the property type change.
The change of the property
Type51
toglobal::AI21.ConversationalRagFlowPublicFields?
appears to be isolated to its declaration, with no other references found in the codebase. This suggests that the change does not affect other parts of the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Type51` property and its new type `global::AI21.ConversationalRagFlowPublicFields?` in the codebase. # Test: Search for the usage of `Type51` property. Expect: Only occurrences with the new type. rg --type cs -A 5 $'Type51'Length of output: 626
Script:
#!/bin/bash # Description: Search for the usage of the new type `global::AI21.ConversationalRagFlowPublicFields?` in the codebase. # Test: Search for occurrences of `global::AI21.ConversationalRagFlowPublicFields?`. rg --type cs 'global::AI21.ConversationalRagFlowPublicFields\?'Length of output: 205
204-206
: Verify the impact of the property type change.The property
Type47
has been changed fromglobal::AI21.ConversationalRagFlowPublicFields?
toglobal::AI21.ConnectorsDataSources?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.Verification successful
Change to
Type47
property is consistent with the codebase.The property
Type47
has been updated to use the typeglobal::AI21.ConnectorsDataSources?
, which is consistent with its usage in the API-related method. This change aligns with the data model used for API interactions and does not introduce any apparent issues. Ensure that any dependencies on this type are updated accordingly.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Type47` property and its new type `global::AI21.ConnectorsDataSources?` in the codebase. # Test: Search for the usage of `Type47` property. Expect: Only occurrences with the new type. rg --type cs -A 5 $'Type47'Length of output: 625
Script:
#!/bin/bash # Description: Search for the usage of the new type `global::AI21.ConnectorsDataSources?` in the codebase. # Test: Search for occurrences of `global::AI21.ConnectorsDataSources?` to verify its usage and impact. rg --type cs 'global::AI21.ConnectorsDataSources?'Length of output: 471
216-218
: Verify the impact of the property type change.The property
Type50
has been changed fromglobal::AI21.MessageRole?
toglobal::AI21.ConnectorsToken?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.
232-234
: Verify the impact of the property type change.The property
Type54
has been changed fromglobal::AI21.ConversationalRagSource?
toglobal::AI21.MessageRole?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.Verification successful
No impact found from the property type change.
The property
Type54
has been changed toglobal::AI21.MessageRole?
, and it appears to be unused elsewhere in the codebase. The typeglobal::AI21.MessageRole
is already well-integrated, minimizing the risk of issues. No further action is required.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Type54` property and its new type `global::AI21.MessageRole?` in the codebase. # Test: Search for the usage of `Type54` property. Expect: Only occurrences with the new type. rg --type cs -A 5 $'Type54'Length of output: 605
Script:
#!/bin/bash # Search for all occurrences of `Type54` in the codebase to verify its usage. rg --type cs 'Type54' # Search for all occurrences of `global::AI21.MessageRole` to verify its usage and ensure consistency. rg --type cs 'global::AI21.MessageRole'Length of output: 2112
240-242
: Verify the impact of the property type change.The property
Type56
has been changed fromglobal::AI21.CorrectionType?
toglobal::AI21.ConversationalRagResult?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.Change in property type is consistent and verified.
The property
Type56
has been changed to useglobal::AI21.ConversationalRagResult?
, which is consistent with its usage in other parts of the codebase, particularly in API-related methods. This change aligns with the data model and does not introduce any inconsistencies. No further action is required.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Type56` property and its new type `global::AI21.ConversationalRagResult?` in the codebase. # Test: Search for the usage of `Type56` property. Expect: Only occurrences with the new type. rg --type cs -A 5 $'Type56'Length of output: 632
Script:
#!/bin/bash # Description: Search for the usage of the type `global::AI21.ConversationalRagResult?` in the codebase. # Test: Search for occurrences of `ConversationalRagResult` to verify its usage and ensure consistency. rg --type cs -A 5 $'ConversationalRagResult'Length of output: 3643
236-238
: Verify the impact of the property type change.The property
Type55
has been changed fromglobal::AI21.Correction?
toglobal::AI21.ConversationalRagFlowPublicFieldsRetrievalStrategy?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.Verification successful
The property type change is properly integrated.
The property
Type55
has been updated to use the new typeglobal::AI21.ConversationalRagFlowPublicFieldsRetrievalStrategy?
, which is consistently used across the codebase. The presence of JSON converters and default values indicates that the type is well-supported, and no issues have been identified with this change.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `Type55` property and its new type `global::AI21.ConversationalRagFlowPublicFieldsRetrievalStrategy?` in the codebase. # Test: Search for the usage of `Type55` property. Expect: Only occurrences with the new type. rg --type cs -A 5 $'Type55'Length of output: 617
Script:
#!/bin/bash # Description: Verify the usage of the new type `global::AI21.ConversationalRagFlowPublicFieldsRetrievalStrategy?` in the codebase. # Test: Search for the usage of `global::AI21.ConversationalRagFlowPublicFieldsRetrievalStrategy?`. rg --type cs 'global::AI21.ConversationalRagFlowPublicFieldsRetrievalStrategy?'Length of output: 3444
224-226
: Verify the impact of the property type change.The property
Type52
has been changed fromglobal::AI21.ConversationalRagResult?
toglobal::System.Collections.Generic.IList<global::AI21.Message>?
, indicating a modification in the underlying data model. Please ensure that this change is properly propagated and handled throughout the codebase to maintain consistency and avoid any unintended consequences.
src/libs/AI21/openapi.yaml (13)
1257-1280
: LGTM!The new endpoint to get user token looks good. It follows the OpenAPI spec conventions and has the required request/response schemas defined.
1281-1304
: LGTM!The new endpoint to get user data sources info looks good. It follows the OpenAPI spec conventions and has the required request/response schemas defined.
1329-1351
: LGTM!The new endpoint to create a thread looks good. It follows the OpenAPI spec conventions and has the required request/response schemas defined.
1352-1382
: LGTM!The new endpoint to create a message looks good. It follows the OpenAPI spec conventions and has the required request/response schemas defined.
1383-1413
: LGTM!The new endpoint to post a thread run looks good. It follows the OpenAPI spec conventions and has the required request/response schemas defined.
1414-1445
: LGTM!The new endpoint to get thread run result looks good. It follows the OpenAPI spec conventions and has the required request/response schemas defined.
1793-1803
: LGTM!The new schema
ConnectorsDataSources
looks good. It follows the OpenAPI spec conventions and has the required properties defined.
1804-1812
: LGTM!The new schema
ConnectorsToken
looks good. It follows the OpenAPI spec conventions and has the required properties defined.
1990-2003
: LGTM!The new schema
CreateMessageRequest
looks good. It follows the OpenAPI spec conventions and has the required properties defined.
2004-2037
: LGTM!The new schema
CreateMessageResponse
looks good. It follows the OpenAPI spec conventions and has the required properties defined with the correct formats.
2038-2047
: LGTM!The new schema
CreateThreadRequest
looks good. It follows the OpenAPI spec conventions and has the optional properties defined.
2048-2072
: LGTM!The new schema
CreateThreadResponse
looks good. It follows the OpenAPI spec conventions and has the required properties defined with the correct formats.
2112-2136
: LGTM!The new schema
DataSourceMetadata
looks good. It follows the OpenAPI spec conventions and has the required properties defined with the correct types.
public async global::System.Threading.Tasks.Task<global::AI21.ConnectorsToken> GetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostAsync( | ||
string userId, | ||
global::System.Threading.CancellationToken cancellationToken = default) | ||
{ | ||
PrepareArguments( | ||
client: _httpClient); | ||
PrepareGetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostArguments( | ||
httpClient: _httpClient, | ||
userId: ref userId); | ||
|
||
using var httpRequest = new global::System.Net.Http.HttpRequestMessage( | ||
method: global::System.Net.Http.HttpMethod.Post, | ||
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/studio/v1/connectors/connected-users/{userId}/tokens", global::System.UriKind.RelativeOrAbsolute)); | ||
|
||
PrepareRequest( | ||
client: _httpClient, | ||
request: httpRequest); | ||
PrepareGetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostRequest( | ||
httpClient: _httpClient, | ||
httpRequestMessage: httpRequest, | ||
userId: userId); | ||
|
||
using var response = await _httpClient.SendAsync( | ||
request: httpRequest, | ||
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, | ||
cancellationToken: cancellationToken).ConfigureAwait(false); | ||
|
||
ProcessResponse( | ||
client: _httpClient, | ||
response: response); | ||
ProcessGetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostResponse( | ||
httpClient: _httpClient, | ||
httpResponseMessage: response); | ||
|
||
var __content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
|
||
ProcessResponseContent( | ||
client: _httpClient, | ||
response: response, | ||
content: ref __content); | ||
ProcessGetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostResponseContent( | ||
httpClient: _httpClient, | ||
httpResponseMessage: response, | ||
content: ref __content); | ||
|
||
try | ||
{ | ||
response.EnsureSuccessStatusCode(); | ||
} | ||
catch (global::System.Net.Http.HttpRequestException ex) | ||
{ | ||
throw new global::System.InvalidOperationException(__content, ex); | ||
} | ||
|
||
return | ||
global::System.Text.Json.JsonSerializer.Deserialize(__content, global::AI21.SourceGenerationContext.Default.ConnectorsToken) ?? | ||
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); | ||
} |
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.
LGTM! Consider refactoring to improve readability and maintainability.
The method follows a standard pattern for making an HTTP request and processing the response. It has good error handling and uses the recommended System.Text.Json
for JSON serialization.
Consider refactoring the method to extract the HTTP request logic into a separate method for better readability and maintainability. For example:
private async Task<string> SendRequestAsync(string userId, CancellationToken cancellationToken)
{
PrepareArguments(client: _httpClient);
PrepareGetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostArguments(httpClient: _httpClient, userId: ref userId);
using var httpRequest = new HttpRequestMessage(
method: HttpMethod.Post,
requestUri: new Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/studio/v1/connectors/connected-users/{userId}/tokens", UriKind.RelativeOrAbsolute));
PrepareRequest(client: _httpClient, request: httpRequest);
PrepareGetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostRequest(httpClient: _httpClient, httpRequestMessage: httpRequest, userId: userId);
using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);
ProcessResponse(client: _httpClient, response: response);
ProcessGetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostResponse(httpClient: _httpClient, httpResponseMessage: response);
var content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
ProcessResponseContent(client: _httpClient, response: response, content: ref content);
ProcessGetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostResponseContent(httpClient: _httpClient, httpResponseMessage: response, content: ref content);
response.EnsureSuccessStatusCode();
return content;
}
public async Task<ConnectorsToken> GetUserTokenStudioV1ConnectorsConnectedUsersUserIdTokensPostAsync(
string userId,
CancellationToken cancellationToken = default)
{
var content = await SendRequestAsync(userId, cancellationToken);
return JsonSerializer.Deserialize(content, SourceGenerationContext.Default.ConnectorsToken) ??
throw new InvalidOperationException($"Response deserialization failed for \"{content}\" ");
}
This refactoring extracts the HTTP request logic into a separate SendRequestAsync
method, which returns the response content as a string. The main method then deserializes the response content into a ConnectorsToken
object.
This refactoring improves readability by separating the HTTP request logic from the deserialization logic. It also improves maintainability by making the method shorter and easier to understand.
Summary by CodeRabbit
Release Notes
New Features
Improvements
These updates improve the overall usability and functionality of the AI21 API, facilitating smoother interactions for users.