Skip to content

Commit ff89a78

Browse files
authored
Merge pull request #24 from anthropics/release-please--branches--main--changes--next
release: 10.2.1
2 parents bab3e3b + 9054d88 commit ff89a78

19 files changed

+6477
-205
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tab_width = 4
2121
end_of_line = crlf
2222
insert_final_newline = true
2323

24+
dotnet_diagnostic.CA1510.severity = none # Use ArgumentNullException throw helper
2425
dotnet_diagnostic.IDE0060.severity = none # Caused by resource with no methods and no subresources
2526
dotnet_diagnostic.IDE1006.severity = none # Some names may not match up with C# conventions
2627
dotnet_diagnostic.IDE0290.severity = none # Don't prefer primary constructors

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "10.2.0"
2+
".": "10.2.1"
33
}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 10.2.1 (2025-11-20)
4+
5+
Full Changelog: [v10.2.0...v10.2.1](https://github.com/anthropics/anthropic-sdk-csharp/compare/v10.2.0...v10.2.1)
6+
37
## 10.2.0 (2025-11-20)
48

59
Full Changelog: [v10.1.2...v10.2.0](https://github.com/anthropics/anthropic-sdk-csharp/compare/v10.1.2...v10.2.0)

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,33 @@ await foreach (var message in client.Messages.CreateStreaming(parameters))
156156
}
157157
```
158158

159+
## `IChatClient`
160+
161+
The SDK provides an implementation of the `IChatClient` interface from the `Microsoft.Extensions.AI.Abstractions` library.
162+
This enables `AnthropicClient` (and `Anthropic.Services.IBetaService`) to be used with other libraries that integrate with
163+
these core abstractions. For example, tools in the MCP C# SDK (`ModelContextProtocol`) library can be used directly with an `AnthropicClient`
164+
exposed via `IChatClient`.
165+
166+
```csharp
167+
using Anthropic;
168+
using Microsoft.Extensions.AI;
169+
using ModelContextProtocol.Client;
170+
171+
// Configured using the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL environment variables
172+
IChatClient chatClient = client.AsIChatClient("claude-haiku-4-5")
173+
.AsBuilder()
174+
.UseFunctionInvocation()
175+
.Build();
176+
177+
// Using McpClient from the MCP C# SDK
178+
McpClient learningServer = await McpClient.CreateAsync(
179+
new HttpClientTransport(new() { Endpoint = new("https://learn.microsoft.com/api/mcp") }));
180+
181+
ChatOptions options = new() { Tools = [.. await learningServer.ListToolsAsync()] };
182+
183+
Console.WriteLine(await chatClient.GetResponseAsync("Tell me about IChatClient", options));
184+
```
185+
159186
## Binary responses
160187

161188
The SDK defines methods that return binary responses, which are used for API responses that shouldn't necessarily be parsed, like non-JSON data.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<ItemGroup>
3+
<ProjectReference Include="..\..\src\Anthropic\Anthropic.csproj" />
4+
<PackageReference Include="Microsoft.Extensions.AI" Version="10.0.0" />
5+
</ItemGroup>
6+
<PropertyGroup>
7+
<OutputType>Exe</OutputType>
8+
<TargetFramework>net8.0</TargetFramework>
9+
<ImplicitUsings>enable</ImplicitUsings>
10+
<Nullable>enable</Nullable>
11+
</PropertyGroup>
12+
</Project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Anthropic;
2+
using Microsoft.Extensions.AI;
3+
4+
// Configured using the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL environment variables
5+
IChatClient chatClient = new AnthropicClient()
6+
.AsIChatClient("claude-haiku-4-5")
7+
.AsBuilder()
8+
.UseFunctionInvocation()
9+
.Build();
10+
11+
ChatOptions options = new()
12+
{
13+
Tools =
14+
[
15+
AIFunctionFactory.Create(
16+
() => Environment.UserName,
17+
"get_current_user_name",
18+
"Gets the current user's name."
19+
),
20+
],
21+
};
22+
23+
await foreach (
24+
var update in chatClient.GetStreamingResponseAsync(
25+
"Write a Haiku about the current user's name",
26+
options
27+
)
28+
)
29+
{
30+
Console.Write(update);
31+
}
32+
Console.WriteLine();

src/Anthropic.Foundry/Anthropic.Foundry.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.4.1" />
1414
<PackageReference Include="Azure.Identity" Version="1.17.0" />
1515
</ItemGroup>
16+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
17+
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
18+
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
19+
</ItemGroup>
1620
<PropertyGroup>
1721
<BuildPackage>true</BuildPackage>
1822
<Deterministic>true</Deterministic>
@@ -39,9 +43,6 @@
3943
<SupportedFrameworks>net8.0;net9.0;netstandard2.0</SupportedFrameworks>
4044
</PropertyGroup>
4145
<ItemGroup>
42-
<None Include="../Anthropic/GlobalShims.cs">
43-
<Link>%(RecursiveDir)/%(FileName)%(Extension)</Link>
44-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
45-
</None>
46+
<Compile Include="../Anthropic/GlobalShims.cs" />
4647
</ItemGroup>
4748
</Project>

src/Anthropic.Foundry/AnthropicFoundryClient.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
#if NETSTANDARD2_0
2-
global using ValueTask = System.Threading.Tasks.Task;
3-
#endif
4-
5-
using Anthropic;
61
using Anthropic.Core;
72

83
namespace Anthropic.Foundry;
@@ -65,6 +60,6 @@ CancellationToken cancellationToken
6560
{
6661
_azureCredentials.Apply(requestMessage);
6762

68-
return ValueTask.CompletedTask;
63+
return default;
6964
}
7065
}

0 commit comments

Comments
 (0)