Migrate from Anthropic.SDK to official Anthropic package (#1083)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
Copilot 2025-12-10 08:58:41 -05:00 • committed by GitHub
commit f9239b0fb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 5 additions and 6 deletions

View file

@ -59,7 +59,7 @@
<!-- Testing dependencies -->
<ItemGroup>
<PackageVersion Include="Anthropic.SDK" Version="5.8.0" />
<PackageVersion Include="Anthropic" Version="11.0.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>

View file

@ -14,7 +14,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" />
<PackageReference Include="Anthropic.SDK" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
</ItemGroup>

View file

@ -1,4 +1,4 @@
using Anthropic.SDK;
using Anthropic;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@ -41,8 +41,8 @@ foreach (var tool in tools)
Console.WriteLine($"Connected to server with tools: {tool.Name}");
}
using var anthropicClient = new AnthropicClient(new APIAuthentication(builder.Configuration["ANTHROPIC_API_KEY"]))
.Messages
using var anthropicClient = new AnthropicClient(new() { APIKey = builder.Configuration["ANTHROPIC_API_KEY"] })
.AsIChatClient("claude-haiku-4-5-20251001")
.AsBuilder()
.UseFunctionInvocation()
.Build();

View file

@ -17,7 +17,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Anthropic.SDK" />
<PackageReference Include="Anthropic" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Microsoft.Extensions.AI" />
</ItemGroup>