Change sample to use official Anthropic C# package (#2471)

Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
This commit is contained in:
Stephen Toub
2025-11-28 19:10:54 +00:00
committed by GitHub
co-authored by Roger Barreto
parent 67de7bcd93
commit a3909b8b5b
3 changed files with 8 additions and 12 deletions
@@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Anthropic.SDK" />
<PackageReference Include="Anthropic" />
<PackageReference Include="AWSSDK.Extensions.Bedrock.MEAI" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" />
</ItemGroup>
@@ -12,19 +12,16 @@ const string Topic = "Goldendoodles make the best pets.";
IChatClient aws = new AmazonBedrockRuntimeClient(
Environment.GetEnvironmentVariable("BEDROCK_ACCESSKEY"!),
Environment.GetEnvironmentVariable("BEDROCK_SECRETACCESSKEY")!,
Amazon.RegionEndpoint.USEast1).AsIChatClient("amazon.nova-pro-v1:0");
Amazon.RegionEndpoint.USEast1)
.AsIChatClient("amazon.nova-pro-v1:0");
IChatClient anthropic = new Anthropic.SDK.AnthropicClient(
Environment.GetEnvironmentVariable("ANTHROPIC_APIKEY")!).Messages.AsBuilder()
.ConfigureOptions(o =>
{
o.ModelId ??= "claude-sonnet-4-20250514";
o.MaxOutputTokens ??= 10 * 1024;
})
.Build();
IChatClient anthropic = new Anthropic.AnthropicClient(
new() { APIKey = Environment.GetEnvironmentVariable("ANTHROPIC_APIKEY") })
.AsIChatClient("claude-sonnet-4-20250514");
IChatClient openai = new OpenAI.OpenAIClient(
Environment.GetEnvironmentVariable("OPENAI_APIKEY")!).GetChatClient("gpt-4o-mini").AsIChatClient();
Environment.GetEnvironmentVariable("OPENAI_APIKEY")!).GetChatClient("gpt-4o-mini")
.AsIChatClient();
// Define our agents.
AIAgent researcher = new ChatClientAgent(aws,