-
-
Notifications
You must be signed in to change notification settings - Fork 2
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: Use official OpenAPI spec. #78
Conversation
WalkthroughThe pull request includes modifications to several files, primarily focusing on updating the Changes
Possibly related PRs
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 (
|
# Conflicts: # src/libs/Anthropic/openapi.yaml
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: 6
🧹 Outside diff range and nitpick comments (8)
src/libs/Anthropic/AnthropicClient.Streaming.cs (2)
13-19
: Update XML Documentation for AccuracyThe XML comments for
CreateMessageAsStreamAsync
have been updated to include information about theanthropicVersion
parameter. Ensure that the documentation accurately reflects the method's behavior and that the link provided is correct.
116-132
: Handle Exceptions AppropriatelyThe catch block for
HttpRequestException
wraps the exception in anApiException
. Verify that this captures all relevant details and does not suppress important information from the original exception.src/libs/Anthropic/Extensions/AnthropicClient.ChatClient.cs (6)
11-11
: Align Static Field Naming with ConventionsThe static field
s_defaultParameterSchema
has been renamed toDefaultParameterSchema
, which is more aligned with standard naming conventions. This improves code readability.
41-45
: Remove Commented-Out Code for ClarityLines 41~ to 45~ contain code that has been commented out. Unless this code is intended for future use and properly documented, consider removing it to enhance code cleanliness.
87-90
: Ensure All 'StopReason' Cases Are HandledIn the switch statement for
response.StopReason
, consider handling all possible enumeration values or providing a default case to ensure any new or unexpected values are accounted for.+ default: + completion.FinishReason = new ChatFinishReason(response.StopReason.ToString()); + break;
103-111
: Clarify Usage of Commented-Out CodeLines 103~ to 111~ contain commented-out code related to usage metrics. If this code is no longer needed, remove it. If it's intended for future implementation, add a TODO comment explaining its purpose.
Line range hint
152-217
: Review Message Construction LogicThe message construction in the
CreateRequest
method has changed significantly. Ensure that:
- Messages are correctly assembled from
chatMessages
.- The nested loop adds messages as intended, without duplications or omissions.
- Content blocks are properly converted to
InputMessage
instances.Consider refactoring the loops for clarity and correctness.
238-246
: Simplify 'ToolChoice' Conditional LogicThe nested conditional operators for
ToolChoice
assignment can be hard to read and maintain. Refactor the logic to improve readability.if (options?.Tools is { Count: > 0 }) { if (options.ToolMode is AutoChatToolMode) { request.ToolChoice = new ToolChoice(new ToolChoiceAuto()); } else if (options.ToolMode is RequiredChatToolMode r) { request.ToolChoice = r.RequiredFunctionName != null ? new ToolChoice(new ToolChoiceTool { Name = r.RequiredFunctionName }) : new ToolChoice(new ToolChoiceAny()); } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (294)
src/libs/Anthropic/Generated/Anthropic.AnthropicClient.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IAnthropicClient.CreateMessage.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IAnthropicClient.CreateMessageBatch.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IAnthropicClient.RetrieveMessageBatch.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IAnthropicClient.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesCancel.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesCancel2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesList.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesList2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesPost2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesResults.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesResults2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesRetrieve.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.BetaMessageBatchesRetrieve2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessageBatchesClient.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessagesClient.BetaMessagesCountTokensPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessagesClient.BetaMessagesCountTokensPost2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessagesClient.BetaMessagesPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessagesClient.MessagesPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessagesClient.PromptCachingBetaMessagesPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.IMessagesClient.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.ITextCompletionsClient.CompletePost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.ITextCompletionsClient.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesCancel.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesCancel2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesList.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesList2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesPost2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesResults.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesResults2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesRetrieve.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.BetaMessageBatchesRetrieve2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessageBatchesClient.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessagesClient.BetaMessagesCountTokensPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessagesClient.BetaMessagesCountTokensPost2.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessagesClient.BetaMessagesPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessagesClient.MessagesPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessagesClient.PromptCachingBetaMessagesPost.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.MessagesClient.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.APIError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.APIError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.APIErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.AnthropicBeta.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.AnthropicBeta.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.AnthropicBetaEnum.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.AuthenticationError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.AuthenticationError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.AuthenticationErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.Base64ImageSource.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.Base64ImageSource.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.Base64ImageSourceMediaType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.Base64ImageSourceType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaAPIError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaAPIError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaAPIErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaAuthenticationError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaAuthenticationError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaAuthenticationErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBase64ImageSource.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBase64ImageSource.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBase64ImageSourceMediaType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBase64ImageSourceType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBase64PDFSource.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBase64PDFSource.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBase64PDFSourceMediaType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBase64PDFSourceType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBashTool20241022.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBashTool20241022.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBashTool20241022CacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBashTool20241022CacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBashTool20241022CacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBashTool20241022Name.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaBashTool20241022Type.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCacheControlEphemeral.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCacheControlEphemeral.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCacheControlEphemeralType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCanceledResult.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCanceledResult.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCanceledResultType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaComputerUseTool20241022.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaComputerUseTool20241022.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaComputerUseTool20241022CacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaComputerUseTool20241022CacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaComputerUseTool20241022CacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaComputerUseTool20241022Name.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaComputerUseTool20241022Type.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDeltaEvent.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDeltaEvent.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDeltaEventDeltaDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDeltaEventDeltaDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDeltaEventDeltaDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDeltaEventType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStartEvent.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStartEvent.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStartEventContentBlockDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStartEventContentBlockDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStartEventContentBlockDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStartEventType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStopEvent.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStopEvent.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaContentBlockStopEventType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCountMessageTokensParams.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCountMessageTokensParams.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCountMessageTokensParamsToolDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCountMessageTokensParamsToolDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCountMessageTokensParamsToolDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCountMessageTokensResponse.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCountMessageTokensResponse.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCreateMessageBatchParams.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCreateMessageBatchParams.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCreateMessageParams.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCreateMessageParams.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCreateMessageParamsToolDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCreateMessageParamsToolDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaCreateMessageParamsToolDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErrorResponse.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErrorResponse.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErrorResponseErrorDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErrorResponseErrorDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErrorResponseErrorDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErrorResponseType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErroredResult.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErroredResult.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaErroredResultType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaExpiredResult.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaExpiredResult.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaExpiredResultType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputContentBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputContentBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputContentBlockDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputContentBlockDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputContentBlockDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputJsonContentBlockDelta.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputJsonContentBlockDelta.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputJsonContentBlockDeltaType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputMessage.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputMessage.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputMessageRole.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputSchema.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputSchema.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputSchemaProperties.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputSchemaProperties.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInputSchemaType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInvalidRequestError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInvalidRequestError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaInvalidRequestErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaListResponseMessageBatch.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaListResponseMessageBatch.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessage.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessage.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatch.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatch.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchIndividualRequestParams.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchIndividualRequestParams.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchIndividualResponse.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchIndividualResponse.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchProcessingStatus.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchResult.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchResult.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchResultDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchResultDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchResultDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageBatchType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageDelta.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageDelta.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageDeltaEvent.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageDeltaEvent.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageDeltaEventType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageDeltaStopReason.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageDeltaUsage.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageDeltaUsage.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageRole.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStartEvent.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStartEvent.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStartEventType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStopEvent.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStopEvent.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStopEventType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStopReason.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStreamEvent.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStreamEvent.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStreamEventDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStreamEventDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageStreamEventDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMessageType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMetadata.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaMetadata.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaNotFoundError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaNotFoundError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaNotFoundErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaOverloadedError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaOverloadedError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaOverloadedErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaPermissionError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaPermissionError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaPermissionErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRateLimitError.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRateLimitError.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRateLimitErrorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestCounts.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestCounts.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlockCacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlockCacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlockCacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlockSourceDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlockSourceDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlockSourceDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestImageBlockType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestPDFBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestPDFBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestPDFBlockCacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestPDFBlockCacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestPDFBlockCacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestPDFBlockType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestTextBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestTextBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestTextBlockCacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestTextBlockCacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestTextBlockCacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestTextBlockType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlockCacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlockCacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlockCacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlockContentVariant2ItemDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlockContentVariant2ItemDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlockContentVariant2ItemDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolResultBlockType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolUseBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolUseBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolUseBlockCacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolUseBlockCacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolUseBlockCacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolUseBlockInput.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolUseBlockInput.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaRequestToolUseBlockType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaResponseTextBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaResponseTextBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaResponseTextBlockType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaResponseToolUseBlock.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaResponseToolUseBlock.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaResponseToolUseBlockInput.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaResponseToolUseBlockInput.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaResponseToolUseBlockType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaSucceededResult.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaSucceededResult.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaSucceededResultType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextContentBlockDelta.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextContentBlockDelta.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextContentBlockDeltaType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextEditor20241022.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextEditor20241022.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextEditor20241022CacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextEditor20241022CacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextEditor20241022CacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextEditor20241022Name.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTextEditor20241022Type.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTool.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaTool.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolCacheControlDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolCacheControlDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolCacheControlDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoice.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoice.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceAny.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceAny.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceAnyType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceAuto.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceAuto.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceAutoType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceDiscriminator.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceDiscriminator.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceDiscriminatorType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceTool.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceTool.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolChoiceToolType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaToolType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaUsage.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.BetaUsage.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.CacheControlEphemeral.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.CacheControlEphemeralType.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.CompletionRequest.Json.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.CompletionRequest.g.cs
is excluded by!**/generated/**
src/libs/Anthropic/Generated/Anthropic.Models.CompletionResponse.Json.g.cs
is excluded by!**/generated/**
📒 Files selected for processing (6)
README.md
(1 hunks)src/helpers/FixOpenApiSpec/FixOpenApiSpec.csproj
(1 hunks)src/helpers/FixOpenApiSpec/Program.cs
(1 hunks)src/libs/Anthropic/AnthropicClient.Streaming.cs
(4 hunks)src/libs/Anthropic/Extensions/AnthropicClient.ChatClient.cs
(10 hunks)src/libs/Anthropic/Extensions/StringExtensions.cs
(5 hunks)
✅ Files skipped from review due to trivial changes (1)
- README.md
🔇 Additional comments (9)
src/libs/Anthropic/Extensions/StringExtensions.cs (3)
42-51
: Clarify Role and Content Assignment in 'AsToolCall' Method
The AsToolCall
method sets the Role
to InputMessageRole.User
and assigns a Content
containing a RequestToolResultBlock
. Confirm whether the role should be User
or Assistant
, and ensure that the Content
assignment aligns with the expected structure for tool calls.
13-17
: Update Method Return Type and Role Assignment
The AsUserMessage
method now returns an InputMessage
with Role = InputMessageRole.User
. Ensure that any code calling this method is updated to handle the new return type InputMessage
instead of Message
.
27-31
: Update Method Return Type and Role Assignment
The AsAssistantMessage
method now returns an InputMessage
with Role = InputMessageRole.Assistant
. Verify that callers of this method handle the InputMessage
type appropriately.
✅ Verification successful
Let me gather more information about the usage context and type expectations.
Let me check one more thing to understand the complete context of the API usage.
No Issues Found with Return Type Change
The verification shows that all usages of AsAssistantMessage()
are correctly handling the InputMessage
return type. The method is used in test scenarios and examples where the return type is implicitly used in the MessagesPostAsync
API call, which expects InputMessage
. The change is consistent with other extension methods in the same file (like AsUserMessage
and AsToolCall
) that also return InputMessage
.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find all usages of 'AsAssistantMessage' that expect a 'Message' type.
rg 'AsAssistantMessage\(' -A 1
Length of output: 591
Script:
#!/bin/bash
# Check the method signatures and type usage in test files
ast-grep --pattern 'var $_ = $$.AsAssistantMessage()'
# Check for any Message type usage in the codebase
rg 'Message' -B 1 -A 1 src/tests/Anthropic.IntegrationTests/Tests.CompleteHistory.cs
Length of output: 648
Script:
#!/bin/bash
# Check the MessagesPostAsync method signature and parameters
ast-grep --pattern 'MessagesPostAsync($$$)'
# Check the complete content of StringExtensions.cs to understand the full context
cat src/libs/Anthropic/Extensions/StringExtensions.cs
Length of output: 3979
src/libs/Anthropic/AnthropicClient.Streaming.cs (4)
35-35
: Ensure API Endpoint Consistency
The API path has been changed to "/v1/messages"
. Confirm that this endpoint is correct for the intended API version and that corresponding server-side support is available.
63-66
: Conditional Addition of 'anthropic-version' Header
The anthropic-version
header is added only when anthropicVersion
is provided. Ensure that omitting this header defaults to the desired API version on the server side.
87-114
: Improve Error Handling for 4XX Responses
Enhanced error handling for client errors (4XX responses) has been added. Ensure that the deserialization of ErrorResponse
works for all expected error formats and that any necessary error details are captured for troubleshooting.
24-25
: Change Parameter Type to 'CreateMessageParams'
The method now accepts a CreateMessageParams
instead of a CreateMessageRequest
. Verify that all calls to CreateMessageAsStreamAsync
use the correct parameter type to prevent runtime errors.
✅ Verification successful
All calls to CreateMessageAsStreamAsync
use the correct CreateMessageParams
type
The codebase scan shows only two occurrences of CreateMessageAsStreamAsync
:
- The method definition in
AnthropicClient.Streaming.cs
- A test case in
Tests.Streaming.cs
that correctly usesCreateMessageParams
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find all method calls to 'CreateMessageAsStreamAsync' with outdated parameter types.
rg 'CreateMessageAsStreamAsync\(' -A 1
Length of output: 499
src/libs/Anthropic/Extensions/AnthropicClient.ChatClient.cs (1)
26-28
: Update Request Creation with New Parameter Type
The CreateRequest
method now returns a CreateMessageParams
object. Ensure that any downstream methods and logic are compatible with this new parameter type.
src/helpers/FixOpenApiSpec/Program.cs (1)
47-53
: Verify whether clearing existing security schemes and requirements is intentional
Clearing the existing security schemes and security requirements removes all previously defined authentication methods. Ensure that this change is intentional and that removing existing security definitions does not negatively impact parts of the API that rely on them.
Also applies to: 55-69
.Select(x => new Tool | ||
{ | ||
Description = x.Description ?? string.Empty, | ||
Name = x.Name ?? string.Empty, | ||
InputSchema = x.Parameters ?? new ToolCustomInputSchema(), | ||
InputSchema = new InputSchema(), // x.Parameters ?? |
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.
Assign Appropriate Input Schema in 'AsAnthropicTools' Method
The InputSchema
is currently initialized as an empty InputSchema
. If x.Parameters
contains necessary schema information, consider assigning it to InputSchema
to ensure tools have the correct input specifications.
- InputSchema = new InputSchema(), // x.Parameters ??
+ InputSchema = x.Parameters ?? new InputSchema(),
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
.Select(x => new Tool | |
{ | |
Description = x.Description ?? string.Empty, | |
Name = x.Name ?? string.Empty, | |
InputSchema = x.Parameters ?? new ToolCustomInputSchema(), | |
InputSchema = new InputSchema(), // x.Parameters ?? | |
.Select(x => new Tool | |
{ | |
Description = x.Description ?? string.Empty, | |
Name = x.Name ?? string.Empty, | |
InputSchema = x.Parameters ?? new InputSchema(), |
public static InputMessage AsInputMessage(this Message message) | ||
{ | ||
message = message ?? throw new ArgumentNullException(nameof(message)); | ||
|
||
return new Message | ||
return new InputMessage | ||
{ | ||
Content = message.Content, | ||
Role = message.Role, | ||
StopSequence = message.StopSequence, | ||
Content = message.Content.Select(x => | ||
{ | ||
if (x.IsText) | ||
{ | ||
return new ContentVariant2Item2(new RequestTextBlock | ||
{ | ||
Text = x.Text!.Text, | ||
}); | ||
} | ||
if (x.IsToolUse) | ||
{ | ||
return new ContentVariant2Item2(new RequestToolUseBlock | ||
{ | ||
Id = x.ToolUse!.Id, | ||
Input = x.ToolUse.Input, | ||
Name = x.ToolUse!.Name, | ||
}); | ||
} | ||
|
||
return new ContentVariant2Item2(); | ||
}).ToList(), | ||
Role = InputMessageRole.Assistant, |
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.
🛠️ Refactor suggestion
Handle Unrecognized Content Types in 'AsInputMessage' Method
In the AsInputMessage
method, if a content item is neither Text
nor ToolUse
, it returns an empty ContentVariant2Item2
, which may lead to unexpected behavior. Consider adding explicit handling or logging for unrecognized content types to improve robustness.
+ else
+ {
+ // Handle unknown content types
+ throw new InvalidOperationException("Unrecognized content type in message.");
+ }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public static InputMessage AsInputMessage(this Message message) | |
{ | |
message = message ?? throw new ArgumentNullException(nameof(message)); | |
return new Message | |
return new InputMessage | |
{ | |
Content = message.Content, | |
Role = message.Role, | |
StopSequence = message.StopSequence, | |
Content = message.Content.Select(x => | |
{ | |
if (x.IsText) | |
{ | |
return new ContentVariant2Item2(new RequestTextBlock | |
{ | |
Text = x.Text!.Text, | |
}); | |
} | |
if (x.IsToolUse) | |
{ | |
return new ContentVariant2Item2(new RequestToolUseBlock | |
{ | |
Id = x.ToolUse!.Id, | |
Input = x.ToolUse.Input, | |
Name = x.ToolUse!.Name, | |
}); | |
} | |
return new ContentVariant2Item2(); | |
}).ToList(), | |
Role = InputMessageRole.Assistant, | |
public static InputMessage AsInputMessage(this Message message) | |
{ | |
message = message ?? throw new ArgumentNullException(nameof(message)); | |
return new InputMessage | |
{ | |
Content = message.Content.Select(x => | |
{ | |
if (x.IsText) | |
{ | |
return new ContentVariant2Item2(new RequestTextBlock | |
{ | |
Text = x.Text!.Text, | |
}); | |
} | |
if (x.IsToolUse) | |
{ | |
return new ContentVariant2Item2(new RequestToolUseBlock | |
{ | |
Id = x.ToolUse!.Id, | |
Input = x.ToolUse.Input, | |
Name = x.ToolUse!.Name, | |
}); | |
} | |
else | |
{ | |
// Handle unknown content types | |
throw new InvalidOperationException("Unrecognized content type in message."); | |
} | |
}).ToList(), | |
Role = InputMessageRole.Assistant, |
@@ -269,7 +264,7 @@ private static ToolParameterJsonSchema CreateSchema(AIFunction f) | |||
|
|||
foreach (AIFunctionParameterMetadata parameter in parameters) | |||
{ | |||
tool.Properties.Add(parameter.Name, parameter.Schema is JsonElement e ? e : s_defaultParameterSchema); | |||
tool.Properties.Add(parameter.Name, parameter.Schema is JsonElement e ? e : DefaultParameterSchema); |
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.
Null Check on 'parameter.Schema' Before Deserialization
In the CreateSchema
method, parameter.Schema
may be null
, leading to exceptions during deserialization. Add a null check to ensure stability.
+ if (parameter.Schema != null)
+ {
tool.Properties.Add(parameter.Name, parameter.Schema is JsonElement e ? e : DefaultParameterSchema);
+ }
+ else
+ {
+ tool.Properties.Add(parameter.Name, DefaultParameterSchema);
+ }
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
tool.Properties.Add(parameter.Name, parameter.Schema is JsonElement e ? e : DefaultParameterSchema); | |
if (parameter.Schema != null) | |
{ | |
tool.Properties.Add(parameter.Name, parameter.Schema is JsonElement e ? e : DefaultParameterSchema); | |
} | |
else | |
{ | |
tool.Properties.Add(parameter.Name, DefaultParameterSchema); | |
} |
private ChatClientMetadata? _metadata; | ||
|
||
/// <inheritdoc /> | ||
ChatClientMetadata IChatClient.Metadata => _metadata ??= new(nameof(AnthropicClient), this.BaseUri); | ||
|
||
/// <inheritdoc /> | ||
object? IChatClient.GetService(Type serviceType, object? key) | ||
object? IChatClient.GetService(Type? serviceType, object? key) |
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.
Handle Nullable 'serviceType' Parameter
The GetService
method now accepts a nullable Type?
for serviceType
. Ensure that null checks are in place to prevent NullReferenceException
.
- if (key is null && serviceType?.IsInstanceOfType(this) is true)
+ if (key is null && serviceType != null && serviceType.IsInstanceOfType(this))
Committable suggestion skipped: line range outside the PR's diff.
{ | ||
jsonOrYaml = OpenApi31Support.ConvertToOpenApi30(jsonOrYaml); | ||
} | ||
|
||
var openApiDocument = new OpenApiStringReader().Read(jsonOrYaml, out var diagnostics); | ||
|
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.
🛠️ Refactor suggestion
Add error handling after parsing the OpenAPI document
After parsing the OpenAPI document with OpenApiStringReader().Read
, it's important to check diagnostics.Errors
for any parsing errors before modifying the document. This ensures that issues with the initial OpenAPI specification are caught early and prevents potential exceptions when manipulating an invalid document.
You can implement error handling as follows:
if (diagnostics.Errors.Count > 0)
{
foreach (var error in diagnostics.Errors)
{
Console.WriteLine(error.Message);
}
Environment.Exit(1);
}
Place this code after line 17, before modifying openApiDocument
.
@@ -9,6 +9,7 @@ | |||
</PropertyGroup> | |||
|
|||
<ItemGroup> | |||
<PackageReference Include="AutoSDK" Version="0.27.1-dev.3" /> |
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.
💡 Codebase verification
Consider upgrading to the stable version 0.27.0 instead of using pre-release version 0.27.1-dev.3
The current implementation uses AutoSDK version 0.27.1-dev.3, which is a pre-release version. The latest stable version available on NuGet is 0.27.0. Using a pre-release version in a production environment could introduce instability or breaking changes. Unless there's a specific feature in 0.27.1-dev.3 that's required, it's recommended to use the stable version 0.27.0.
🔗 Analysis chain
Confirm the appropriateness of using a pre-release version of AutoSDK
The package version 0.27.1-dev.3
of AutoSDK
appears to be a development or pre-release version. Consider whether it's appropriate to depend on a pre-release package, as it might introduce instability or unexpected changes. If possible, evaluate using the latest stable release.
You can run the following script to check for the latest stable version of AutoSDK
:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Fetch the latest stable version of 'AutoSDK' from NuGet.
# Fetch all available versions of 'AutoSDK' and filter out pre-release versions
curl -s "https://api.nuget.org/v3-flatcontainer/autosdk/index.json" | jq -r '.versions[]' | grep -v -E '(-)'
# Get the highest stable version
LATEST_VERSION=$(curl -s "https://api.nuget.org/v3-flatcontainer/autosdk/index.json" | jq -r '.versions[]' | grep -v -E '(-)' | sort -V | tail -n 1)
echo "Latest stable version of AutoSDK is: $LATEST_VERSION"
Length of output: 400
Summary by CodeRabbit
Documentation
New Features
Refactor