Skip to content

Commit 167ee45

Browse files
committed
Added Support for ToolUse and Namespace renaming. V 8.0.2
1 parent 486e9cf commit 167ee45

28 files changed

+58
-40
lines changed

Anthropic.Playground/TestHelpers/ChatTestHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Anthropic.ObjectModels.ResponseModels;
2-
using Anthropic.ObjectModels.SharedModels;
1+
using Anthropic.ApiModels.ResponseModels;
2+
using Anthropic.ApiModels.SharedModels;
33
using Anthropic.Services;
44

55
namespace Anthropic.Playground.TestHelpers;

Anthropic.Playground/TestHelpers/ChatToolUseTestHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Anthropic.Extensions;
2-
using Anthropic.ObjectModels.ResponseModels;
3-
using Anthropic.ObjectModels.SharedModels;
1+
using Anthropic.ApiModels.ResponseModels;
2+
using Anthropic.ApiModels.SharedModels;
3+
using Anthropic.Extensions;
44
using Anthropic.Playground.SampleModels;
55
using Anthropic.Services;
66

Anthropic/Anthropic.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageIcon>Ranul-Anthropic-Icon.png</PackageIcon>
1111
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1212
<Title>Anthropic Claude C# .NET library by Ranul Betalgo</Title>
13-
<Version>8.0.1</Version>
13+
<Version>8.0.2</Version>
1414
<Authors>Tolga Kayhan, Betalgo, Ranul</Authors>
1515
<Company>Betalgo Up Ltd.</Company>
1616
<Product>Anthropic Claude C# .NET library by Ranul Betalgo</Product>

Anthropic/ApiModels/AnthropicOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Anthropic.ObjectModels;
1+
namespace Anthropic.ApiModels;
22

33
public class AnthropicOptions
44
{

Anthropic/ApiModels/AnthropicProviderType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Anthropic.ObjectModels;
1+
namespace Anthropic.ApiModels;
22

33
/// <summary>
44
/// Anthropic Provider Type

Anthropic/ApiModels/IObjectInterfaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Anthropic.ObjectModels;
1+
namespace Anthropic.ApiModels;
22

33
public interface IObjectInterfaces
44
{

Anthropic/ApiModels/JsonConverters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Text.Json;
22
using System.Text.Json.Serialization;
3-
using Anthropic.ObjectModels.SharedModels;
3+
using Anthropic.ApiModels.SharedModels;
44

5-
namespace Anthropic.ObjectModels;
5+
namespace Anthropic.ApiModels;
66

77
internal class JsonConverters
88
{

Anthropic/ApiModels/RequestModels/MessageRequest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Text.Json.Serialization;
2-
using Anthropic.ObjectModels;
3-
using Anthropic.ObjectModels.SharedModels;
2+
using Anthropic.ApiModels.SharedModels;
43

54
namespace Anthropic.ApiModels.RequestModels;
65

Anthropic/ApiModels/ResponseModels/BaseResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System.Net;
22
using System.Net.Http.Headers;
33
using System.Text.Json.Serialization;
4-
using Anthropic.ObjectModels.SharedModels;
4+
using Anthropic.ApiModels.SharedModels;
55

6-
namespace Anthropic.ObjectModels.ResponseModels;
6+
namespace Anthropic.ApiModels.ResponseModels;
77

88
public class TypeBaseResponse : IType
99
{

Anthropic/ApiModels/ResponseModels/MessageResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Text.Json.Serialization;
2-
using Anthropic.ObjectModels.SharedModels;
2+
using Anthropic.ApiModels.SharedModels;
33

4-
namespace Anthropic.ObjectModels.ResponseModels;
4+
namespace Anthropic.ApiModels.ResponseModels;
55

66
public class PingResponse : BaseResponse, IStreamResponse
77
{

Anthropic/ApiModels/ResponseModels/RateLimitInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Net.Http.Headers;
22
using Anthropic.Extensions;
33

4-
namespace Anthropic.ObjectModels.ResponseModels;
4+
namespace Anthropic.ApiModels.ResponseModels;
55

66
/// <summary>
77
/// Represents rate limit information from Anthropic API headers.

Anthropic/ApiModels/ResponseModels/ResponseHeaderValues.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Anthropic.Extensions;
22

3-
namespace Anthropic.ObjectModels.ResponseModels;
3+
namespace Anthropic.ApiModels.ResponseModels;
44

55
/// <summary>
66
/// Represents the values of various headers in an HTTP response.

Anthropic/ApiModels/SharedModels/ContentBlock.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Text.Json.Serialization;
2-
using Anthropic.ObjectModels.ResponseModels;
2+
using Anthropic.ApiModels.ResponseModels;
33

4-
namespace Anthropic.ObjectModels.SharedModels;
4+
namespace Anthropic.ApiModels.SharedModels;
55

66
public class ContentBlock : TypeBaseResponse
77
{
@@ -30,6 +30,14 @@ public class ContentBlock : TypeBaseResponse
3030
[JsonIgnore]
3131
public bool IsToolUse => Type == "tool_use";
3232

33+
[JsonPropertyName("tool_use_id")]
34+
35+
public string? ToolUseId { get; set; }
36+
37+
[JsonPropertyName("content")]
38+
39+
public List<ContentBlock>? Content { get; set; }
40+
3341
public static ContentBlock CreateText(string? text)
3442
{
3543
return new()
@@ -62,4 +70,15 @@ public static ContentBlock CreateToolUse(object input, string? id, string? name)
6270
Input = input
6371
};
6472
}
73+
74+
public static ContentBlock CreateToolResult(object input, string toolUseId, List<ContentBlock>? content)
75+
{
76+
return new()
77+
{
78+
Type = "tool_result",
79+
ToolUseId = toolUseId,
80+
Input = input,
81+
Content = content
82+
};
83+
}
6584
}

Anthropic/ApiModels/SharedModels/ImageSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Text.Json.Serialization;
2-
using Anthropic.ObjectModels.ResponseModels;
2+
using Anthropic.ApiModels.ResponseModels;
33

4-
namespace Anthropic.ObjectModels.SharedModels;
4+
namespace Anthropic.ApiModels.SharedModels;
55

66
public class ImageSource : TypeBaseResponse
77
{

Anthropic/ApiModels/SharedModels/Message.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json.Serialization;
22

3-
namespace Anthropic.ObjectModels.SharedModels;
3+
namespace Anthropic.ApiModels.SharedModels;
44

55
public class Message
66
{

Anthropic/ApiModels/SharedModels/Metadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json.Serialization;
22

3-
namespace Anthropic.ObjectModels.SharedModels;
3+
namespace Anthropic.ApiModels.SharedModels;
44

55
/// <summary>
66
/// Represents metadata about the request.

Anthropic/ApiModels/SharedModels/Tool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json.Serialization;
22

3-
namespace Anthropic.ObjectModels.SharedModels;
3+
namespace Anthropic.ApiModels.SharedModels;
44

55
/// <summary>
66
/// Represents a tool definition that the model may use.

Anthropic/ApiModels/SharedModels/ToolChoice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json.Serialization;
22

3-
namespace Anthropic.ObjectModels.SharedModels;
3+
namespace Anthropic.ApiModels.SharedModels;
44

55
/// <summary>
66
/// Represents how the model should use the provided tools.

Anthropic/ApiModels/SharedModels/ToolParameters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json.Serialization;
22

3-
namespace Anthropic.ObjectModels.SharedModels;
3+
namespace Anthropic.ApiModels.SharedModels;
44

55
/// <summary>
66
/// Function parameter is a JSON Schema object.

Anthropic/ApiModels/SharedModels/Usage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Text.Json.Serialization;
22

3-
namespace Anthropic.ObjectModels.SharedModels;
3+
namespace Anthropic.ApiModels.SharedModels;
44

55
public class Usage
66
{

Anthropic/ApiModels/StaticValues.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Anthropic.ObjectModels;
1+
namespace Anthropic.ApiModels;
22

33
internal class StaticValues
44
{

Anthropic/Extensions/AnthropicServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Anthropic.ObjectModels;
1+
using Anthropic.ApiModels;
22
using Anthropic.Services;
33
using Microsoft.Extensions.DependencyInjection;
44

Anthropic/Extensions/ContentBlockExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System.Text.Json;
2-
using Anthropic.ObjectModels.SharedModels;
2+
using Anthropic.ApiModels.SharedModels;
33

44
namespace Anthropic.Extensions;
55

Anthropic/Extensions/HttpClientExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Net.Http.Json;
33
using System.Text.Json;
44
using System.Text.Json.Serialization;
5-
using Anthropic.ObjectModels.ResponseModels;
5+
using Anthropic.ApiModels.ResponseModels;
66

77
namespace Anthropic.Extensions;
88

Anthropic/Extensions/ModelExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Anthropic.ObjectModels;
1+
using Anthropic.ApiModels;
22

33
namespace Anthropic.Extensions;
44

Anthropic/Extensions/StreamHandleExtension.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
using System.Text;
33
using System.Text.Json;
44
using System.Text.Json.Serialization;
5-
using Anthropic.ObjectModels;
6-
using Anthropic.ObjectModels.ResponseModels;
7-
using Anthropic.ObjectModels.SharedModels;
5+
using Anthropic.ApiModels;
6+
using Anthropic.ApiModels.ResponseModels;
7+
using Anthropic.ApiModels.SharedModels;
88
using static Anthropic.Extensions.StreamPartialResponse;
99

1010
namespace Anthropic.Extensions;

Anthropic/Services/AnthropicMessagesService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Runtime.CompilerServices;
22
using Anthropic.ApiModels.RequestModels;
3+
using Anthropic.ApiModels.ResponseModels;
34
using Anthropic.Extensions;
4-
using Anthropic.ObjectModels.ResponseModels;
55

66
namespace Anthropic.Services;
77

Anthropic/Services/AnthropicService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Anthropic.EndpointProviders;
2-
using Anthropic.ObjectModels;
1+
using Anthropic.ApiModels;
2+
using Anthropic.EndpointProviders;
33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.Extensions.Options;
55

0 commit comments

Comments
 (0)