2024-10-02 11:42:27 -07:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
2024-07-15 12:33:10 -07:00
|
|
|
// Create_Anthropic_Agent.cs
|
2024-05-24 12:37:16 -04:00
|
|
|
|
|
|
|
using AutoGen.Anthropic.Extensions;
|
|
|
|
using AutoGen.Anthropic.Utils;
|
|
|
|
using AutoGen.Core;
|
|
|
|
|
2025-01-28 17:13:36 -05:00
|
|
|
namespace AutoGen.Anthropic.Sample;
|
2024-05-24 12:37:16 -04:00
|
|
|
|
2024-06-30 19:21:34 -04:00
|
|
|
public static class Create_Anthropic_Agent
|
2024-05-24 12:37:16 -04:00
|
|
|
{
|
|
|
|
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"));
|
|
|
|
}
|
|
|
|
}
|