Skip to content

Commit

Permalink
Added Support for ToolUse and Namespace renaming. V 8.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhantolga committed Jul 22, 2024
1 parent 486e9cf commit 167ee45
Show file tree
Hide file tree
Showing 28 changed files with 58 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Anthropic.Playground/TestHelpers/ChatTestHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Anthropic.ObjectModels.ResponseModels;
using Anthropic.ObjectModels.SharedModels;
using Anthropic.ApiModels.ResponseModels;
using Anthropic.ApiModels.SharedModels;
using Anthropic.Services;

namespace Anthropic.Playground.TestHelpers;
Expand Down
6 changes: 3 additions & 3 deletions Anthropic.Playground/TestHelpers/ChatToolUseTestHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Anthropic.Extensions;
using Anthropic.ObjectModels.ResponseModels;
using Anthropic.ObjectModels.SharedModels;
using Anthropic.ApiModels.ResponseModels;
using Anthropic.ApiModels.SharedModels;
using Anthropic.Extensions;
using Anthropic.Playground.SampleModels;
using Anthropic.Services;

Expand Down
2 changes: 1 addition & 1 deletion Anthropic/Anthropic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageIcon>Ranul-Anthropic-Icon.png</PackageIcon>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>Anthropic Claude C# .NET library by Ranul Betalgo</Title>
<Version>8.0.1</Version>
<Version>8.0.2</Version>
<Authors>Tolga Kayhan, Betalgo, Ranul</Authors>
<Company>Betalgo Up Ltd.</Company>
<Product>Anthropic Claude C# .NET library by Ranul Betalgo</Product>
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/AnthropicOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Anthropic.ObjectModels;
namespace Anthropic.ApiModels;

public class AnthropicOptions
{
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/AnthropicProviderType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Anthropic.ObjectModels;
namespace Anthropic.ApiModels;

/// <summary>
/// Anthropic Provider Type
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/IObjectInterfaces.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Anthropic.ObjectModels;
namespace Anthropic.ApiModels;

public interface IObjectInterfaces
{
Expand Down
4 changes: 2 additions & 2 deletions Anthropic/ApiModels/JsonConverters.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Anthropic.ObjectModels.SharedModels;
using Anthropic.ApiModels.SharedModels;

namespace Anthropic.ObjectModels;
namespace Anthropic.ApiModels;

internal class JsonConverters
{
Expand Down
3 changes: 1 addition & 2 deletions Anthropic/ApiModels/RequestModels/MessageRequest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Text.Json.Serialization;
using Anthropic.ObjectModels;
using Anthropic.ObjectModels.SharedModels;
using Anthropic.ApiModels.SharedModels;

namespace Anthropic.ApiModels.RequestModels;

Expand Down
4 changes: 2 additions & 2 deletions Anthropic/ApiModels/ResponseModels/BaseResponse.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Net;
using System.Net.Http.Headers;
using System.Text.Json.Serialization;
using Anthropic.ObjectModels.SharedModels;
using Anthropic.ApiModels.SharedModels;

namespace Anthropic.ObjectModels.ResponseModels;
namespace Anthropic.ApiModels.ResponseModels;

public class TypeBaseResponse : IType
{
Expand Down
4 changes: 2 additions & 2 deletions Anthropic/ApiModels/ResponseModels/MessageResponse.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Anthropic.ObjectModels.SharedModels;
using Anthropic.ApiModels.SharedModels;

namespace Anthropic.ObjectModels.ResponseModels;
namespace Anthropic.ApiModels.ResponseModels;

public class PingResponse : BaseResponse, IStreamResponse
{
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/ResponseModels/RateLimitInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Net.Http.Headers;
using Anthropic.Extensions;

namespace Anthropic.ObjectModels.ResponseModels;
namespace Anthropic.ApiModels.ResponseModels;

/// <summary>
/// Represents rate limit information from Anthropic API headers.
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/ResponseModels/ResponseHeaderValues.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Anthropic.Extensions;

namespace Anthropic.ObjectModels.ResponseModels;
namespace Anthropic.ApiModels.ResponseModels;

/// <summary>
/// Represents the values of various headers in an HTTP response.
Expand Down
23 changes: 21 additions & 2 deletions Anthropic/ApiModels/SharedModels/ContentBlock.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Anthropic.ObjectModels.ResponseModels;
using Anthropic.ApiModels.ResponseModels;

namespace Anthropic.ObjectModels.SharedModels;
namespace Anthropic.ApiModels.SharedModels;

public class ContentBlock : TypeBaseResponse
{
Expand Down Expand Up @@ -30,6 +30,14 @@ public class ContentBlock : TypeBaseResponse
[JsonIgnore]
public bool IsToolUse => Type == "tool_use";

[JsonPropertyName("tool_use_id")]

public string? ToolUseId { get; set; }

[JsonPropertyName("content")]

public List<ContentBlock>? Content { get; set; }

public static ContentBlock CreateText(string? text)
{
return new()
Expand Down Expand Up @@ -62,4 +70,15 @@ public static ContentBlock CreateToolUse(object input, string? id, string? name)
Input = input
};
}

public static ContentBlock CreateToolResult(object input, string toolUseId, List<ContentBlock>? content)
{
return new()
{
Type = "tool_result",
ToolUseId = toolUseId,
Input = input,
Content = content
};
}
}
4 changes: 2 additions & 2 deletions Anthropic/ApiModels/SharedModels/ImageSource.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Anthropic.ObjectModels.ResponseModels;
using Anthropic.ApiModels.ResponseModels;

namespace Anthropic.ObjectModels.SharedModels;
namespace Anthropic.ApiModels.SharedModels;

public class ImageSource : TypeBaseResponse
{
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/SharedModels/Message.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Anthropic.ObjectModels.SharedModels;
namespace Anthropic.ApiModels.SharedModels;

public class Message
{
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/SharedModels/Metadata.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Anthropic.ObjectModels.SharedModels;
namespace Anthropic.ApiModels.SharedModels;

/// <summary>
/// Represents metadata about the request.
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/SharedModels/Tool.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Anthropic.ObjectModels.SharedModels;
namespace Anthropic.ApiModels.SharedModels;

/// <summary>
/// Represents a tool definition that the model may use.
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/SharedModels/ToolChoice.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Anthropic.ObjectModels.SharedModels;
namespace Anthropic.ApiModels.SharedModels;

/// <summary>
/// Represents how the model should use the provided tools.
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/SharedModels/ToolParameters.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Anthropic.ObjectModels.SharedModels;
namespace Anthropic.ApiModels.SharedModels;

/// <summary>
/// Function parameter is a JSON Schema object.
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/SharedModels/Usage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Anthropic.ObjectModels.SharedModels;
namespace Anthropic.ApiModels.SharedModels;

public class Usage
{
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/ApiModels/StaticValues.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Anthropic.ObjectModels;
namespace Anthropic.ApiModels;

internal class StaticValues
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Anthropic.ObjectModels;
using Anthropic.ApiModels;
using Anthropic.Services;
using Microsoft.Extensions.DependencyInjection;

Expand Down
2 changes: 1 addition & 1 deletion Anthropic/Extensions/ContentBlockExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json;
using Anthropic.ObjectModels.SharedModels;
using Anthropic.ApiModels.SharedModels;

namespace Anthropic.Extensions;

Expand Down
2 changes: 1 addition & 1 deletion Anthropic/Extensions/HttpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
using Anthropic.ObjectModels.ResponseModels;
using Anthropic.ApiModels.ResponseModels;

namespace Anthropic.Extensions;

Expand Down
2 changes: 1 addition & 1 deletion Anthropic/Extensions/ModelExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Anthropic.ObjectModels;
using Anthropic.ApiModels;

namespace Anthropic.Extensions;

Expand Down
6 changes: 3 additions & 3 deletions Anthropic/Extensions/StreamHandleExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Anthropic.ObjectModels;
using Anthropic.ObjectModels.ResponseModels;
using Anthropic.ObjectModels.SharedModels;
using Anthropic.ApiModels;
using Anthropic.ApiModels.ResponseModels;
using Anthropic.ApiModels.SharedModels;
using static Anthropic.Extensions.StreamPartialResponse;

namespace Anthropic.Extensions;
Expand Down
2 changes: 1 addition & 1 deletion Anthropic/Services/AnthropicMessagesService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Runtime.CompilerServices;
using Anthropic.ApiModels.RequestModels;
using Anthropic.ApiModels.ResponseModels;
using Anthropic.Extensions;
using Anthropic.ObjectModels.ResponseModels;

namespace Anthropic.Services;

Expand Down
4 changes: 2 additions & 2 deletions Anthropic/Services/AnthropicService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Anthropic.EndpointProviders;
using Anthropic.ObjectModels;
using Anthropic.ApiModels;
using Anthropic.EndpointProviders;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

Expand Down

0 comments on commit 167ee45

Please sign in to comment.