From 26783c5c9aee94fd70ea4e113799c0dafc8eb32b Mon Sep 17 00:00:00 2001 From: HavenDV Date: Sat, 12 Oct 2024 00:31:21 +0400 Subject: [PATCH] feat: Use object type for InputSchema. Closes #56. --- src/libs/Anthropic/Anthropic.csproj | 6 ++-- .../Anthropic/Extensions/StringExtensions.cs | 7 +++- .../Generated/Anthropic.Models.Tool.g.cs | 2 +- .../Anthropic.Models.ToolUseBlock.g.cs | 2 +- .../Generated/JsonSerializerContextTypes.g.cs | 34 ++++++++----------- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/libs/Anthropic/Anthropic.csproj b/src/libs/Anthropic/Anthropic.csproj index 5fd8d5e..099db2c 100644 --- a/src/libs/Anthropic/Anthropic.csproj +++ b/src/libs/Anthropic/Anthropic.csproj @@ -25,17 +25,17 @@ - + - + - + diff --git a/src/libs/Anthropic/Extensions/StringExtensions.cs b/src/libs/Anthropic/Extensions/StringExtensions.cs index 4e1f49d..c497227 100755 --- a/src/libs/Anthropic/Extensions/StringExtensions.cs +++ b/src/libs/Anthropic/Extensions/StringExtensions.cs @@ -81,6 +81,11 @@ public static Message AsRequestMessage(this Message message) /// public static string AsJson(this object args) { - return JsonSerializer.Serialize(args, SourceGenerationContext.Default.ToolUseBlockInput); + if (args is JsonElement element) + { + return element.GetRawText(); + } + + return string.Empty; } } \ No newline at end of file diff --git a/src/libs/Anthropic/Generated/Anthropic.Models.Tool.g.cs b/src/libs/Anthropic/Generated/Anthropic.Models.Tool.g.cs index f108b66..81863df 100644 --- a/src/libs/Anthropic/Generated/Anthropic.Models.Tool.g.cs +++ b/src/libs/Anthropic/Generated/Anthropic.Models.Tool.g.cs @@ -32,7 +32,7 @@ public sealed partial class Tool /// [global::System.Text.Json.Serialization.JsonPropertyName("input_schema")] [global::System.Text.Json.Serialization.JsonRequired] - public required global::Anthropic.ToolInputSchema InputSchema { get; set; } + public required object InputSchema { get; set; } /// /// Additional properties that are not explicitly defined in the schema diff --git a/src/libs/Anthropic/Generated/Anthropic.Models.ToolUseBlock.g.cs b/src/libs/Anthropic/Generated/Anthropic.Models.ToolUseBlock.g.cs index 7ffef78..536bfdf 100644 --- a/src/libs/Anthropic/Generated/Anthropic.Models.ToolUseBlock.g.cs +++ b/src/libs/Anthropic/Generated/Anthropic.Models.ToolUseBlock.g.cs @@ -30,7 +30,7 @@ public sealed partial class ToolUseBlock /// [global::System.Text.Json.Serialization.JsonPropertyName("input")] [global::System.Text.Json.Serialization.JsonRequired] - public required global::Anthropic.ToolUseBlockInput Input { get; set; } + public required object Input { get; set; } /// /// The type of content block.
diff --git a/src/libs/Anthropic/Generated/JsonSerializerContextTypes.g.cs b/src/libs/Anthropic/Generated/JsonSerializerContextTypes.g.cs index ec629a8..865cbe2 100644 --- a/src/libs/Anthropic/Generated/JsonSerializerContextTypes.g.cs +++ b/src/libs/Anthropic/Generated/JsonSerializerContextTypes.g.cs @@ -78,7 +78,7 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Anthropic.ToolUseBlockInput? Type15 { get; set; } + public object? Type15 { get; set; } /// /// /// @@ -134,62 +134,58 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Anthropic.ToolInputSchema? Type29 { get; set; } + public global::Anthropic.MessageStreamEvent? Type29 { get; set; } /// /// /// - public global::Anthropic.MessageStreamEvent? Type30 { get; set; } + public global::Anthropic.MessageStartEvent? Type30 { get; set; } /// /// /// - public global::Anthropic.MessageStartEvent? Type31 { get; set; } + public global::Anthropic.MessageStreamEventType? Type31 { get; set; } /// /// /// - public global::Anthropic.MessageStreamEventType? Type32 { get; set; } + public global::Anthropic.MessageDeltaEvent? Type32 { get; set; } /// /// /// - public global::Anthropic.MessageDeltaEvent? Type33 { get; set; } + public global::Anthropic.MessageDelta? Type33 { get; set; } /// /// /// - public global::Anthropic.MessageDelta? Type34 { get; set; } + public global::Anthropic.MessageDeltaUsage? Type34 { get; set; } /// /// /// - public global::Anthropic.MessageDeltaUsage? Type35 { get; set; } + public global::Anthropic.MessageStopEvent? Type35 { get; set; } /// /// /// - public global::Anthropic.MessageStopEvent? Type36 { get; set; } + public global::Anthropic.ContentBlockStartEvent? Type36 { get; set; } /// /// /// - public global::Anthropic.ContentBlockStartEvent? Type37 { get; set; } + public global::Anthropic.ContentBlockDeltaEvent? Type37 { get; set; } /// /// /// - public global::Anthropic.ContentBlockDeltaEvent? Type38 { get; set; } + public global::Anthropic.BlockDelta? Type38 { get; set; } /// /// /// - public global::Anthropic.BlockDelta? Type39 { get; set; } + public global::Anthropic.TextBlockDelta? Type39 { get; set; } /// /// /// - public global::Anthropic.TextBlockDelta? Type40 { get; set; } + public global::Anthropic.InputJsonBlockDelta? Type40 { get; set; } /// /// /// - public global::Anthropic.InputJsonBlockDelta? Type41 { get; set; } + public global::Anthropic.ContentBlockStopEvent? Type41 { get; set; } /// /// /// - public global::Anthropic.ContentBlockStopEvent? Type42 { get; set; } - /// - /// - /// - public global::Anthropic.PingEvent? Type43 { get; set; } + public global::Anthropic.PingEvent? Type42 { get; set; } } } \ No newline at end of file