Skip to content

Commit

Permalink
feat: Use object type for InputSchema. Closes #56.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Oct 11, 2024
1 parent b0d5048 commit 26783c5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/libs/Anthropic/Anthropic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net4.6.2'">
<Reference Include="System.Net.Http" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/libs/Anthropic/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public static Message AsRequestMessage(this Message message)
/// <returns></returns>
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;
}
}
2 changes: 1 addition & 1 deletion src/libs/Anthropic/Generated/Anthropic.Models.Tool.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public sealed partial class Tool
/// </summary>
[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; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public sealed partial class ToolUseBlock
/// </summary>
[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; }

/// <summary>
/// The type of content block.<br/>
Expand Down
34 changes: 15 additions & 19 deletions src/libs/Anthropic/Generated/JsonSerializerContextTypes.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public sealed partial class JsonSerializerContextTypes
/// <summary>
///
/// </summary>
public global::Anthropic.ToolUseBlockInput? Type15 { get; set; }
public object? Type15 { get; set; }
/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -134,62 +134,58 @@ public sealed partial class JsonSerializerContextTypes
/// <summary>
///
/// </summary>
public global::Anthropic.ToolInputSchema? Type29 { get; set; }
public global::Anthropic.MessageStreamEvent? Type29 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.MessageStreamEvent? Type30 { get; set; }
public global::Anthropic.MessageStartEvent? Type30 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.MessageStartEvent? Type31 { get; set; }
public global::Anthropic.MessageStreamEventType? Type31 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.MessageStreamEventType? Type32 { get; set; }
public global::Anthropic.MessageDeltaEvent? Type32 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.MessageDeltaEvent? Type33 { get; set; }
public global::Anthropic.MessageDelta? Type33 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.MessageDelta? Type34 { get; set; }
public global::Anthropic.MessageDeltaUsage? Type34 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.MessageDeltaUsage? Type35 { get; set; }
public global::Anthropic.MessageStopEvent? Type35 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.MessageStopEvent? Type36 { get; set; }
public global::Anthropic.ContentBlockStartEvent? Type36 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.ContentBlockStartEvent? Type37 { get; set; }
public global::Anthropic.ContentBlockDeltaEvent? Type37 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.ContentBlockDeltaEvent? Type38 { get; set; }
public global::Anthropic.BlockDelta? Type38 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.BlockDelta? Type39 { get; set; }
public global::Anthropic.TextBlockDelta? Type39 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.TextBlockDelta? Type40 { get; set; }
public global::Anthropic.InputJsonBlockDelta? Type40 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.InputJsonBlockDelta? Type41 { get; set; }
public global::Anthropic.ContentBlockStopEvent? Type41 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.ContentBlockStopEvent? Type42 { get; set; }
/// <summary>
///
/// </summary>
public global::Anthropic.PingEvent? Type43 { get; set; }
public global::Anthropic.PingEvent? Type42 { get; set; }
}
}

0 comments on commit 26783c5

Please sign in to comment.