mirror of
https://github.com/microsoft/autogen.git
synced 2025-07-23 17:01:35 +00:00

* Reference project Revert "Set up the Agent. Basic Example set up, boilerplate for connector, ran into signing issue." This reverts commit 0afe04f2 End to end working anthropic agent + unit tests Set up the Agent. Basic Example set up, boilerplate for connector, ran into signing issue. * Add pragma warning * - Remove Message type - tabbing fix white space in csproj - Remove redundant inheritance - Edit Anthropic.Tests' rootnamespace - Create AutoGen.Anthropic.Samples * short-cut agent extension method * Pass system message in the constructor and throw if there's system message in Imessages --------- Co-authored-by: luongdavid <luongdavid@microsoft.com>
29 lines
1.0 KiB
C#
29 lines
1.0 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// AnthropicSamples.cs
|
|
|
|
using AutoGen.Anthropic.Extensions;
|
|
using AutoGen.Anthropic.Utils;
|
|
using AutoGen.Core;
|
|
|
|
namespace AutoGen.Anthropic.Samples;
|
|
|
|
public static class AnthropicSamples
|
|
{
|
|
public static async Task RunAsync()
|
|
{
|
|
#region create_anthropic_agent
|
|
var apiKey = Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY") ?? throw new Exception("Missing ANTHROPIC_API_KEY environment variable.");
|
|
var anthropicClient = new AnthropicClient(new HttpClient(), AnthropicConstants.Endpoint, apiKey);
|
|
var agent = new AnthropicClientAgent(anthropicClient, "assistant", AnthropicConstants.Claude3Haiku);
|
|
#endregion
|
|
|
|
#region register_middleware
|
|
var agentWithConnector = agent
|
|
.RegisterMessageConnector()
|
|
.RegisterPrintMessage();
|
|
#endregion register_middleware
|
|
|
|
await agentWithConnector.SendAsync(new TextMessage(Role.Assistant, "Hello", from: "user"));
|
|
}
|
|
}
|