Get start with AutoGen for dotnet
Firstly, add AutoGen
package to your project.
dotnet add package AutoGen
Note
For more information about installing packages, please check out the installation guide.
Then you can start with the following code snippet to create a conversable agent and chat with it.
using AutoGen;
using AutoGen.Core;
using AutoGen.OpenAI;
using AutoGen.OpenAI.Extension;
using OpenAI;
var openAIKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new Exception("Please set OPENAI_API_KEY environment variable.");
var openAIClient = new OpenAIClient(openAIKey);
var model = "gpt-4o-mini";
var assistantAgent = new OpenAIChatAgent(
name: "assistant",
systemMessage: "You are an assistant that help user to do some tasks.",
chatClient: openAIClient.GetChatClient(model))
.RegisterMessageConnector()
.RegisterPrintMessage(); // register a hook to print message nicely to console
// set human input mode to ALWAYS so that user always provide input
var userProxyAgent = new UserProxyAgent(
name: "user",
humanInputMode: HumanInputMode.ALWAYS)
.RegisterPrintMessage();
// start the conversation
await userProxyAgent.InitiateChatAsync(
receiver: assistantAgent,
message: "Hey assistant, please do me a favor.",
maxRound: 10);
Tutorial
Getting started with AutoGen.Net by following the tutorial series.
Examples
You can find more examples under the sample project.
Report a bug or request a feature
You can report a bug or request a feature by creating a new issue in the github issue and specifying label the label "donet"