Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Use AutoGen.Net agent as model in AG Studio #3182

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
This tutorial shows how to use AutoGen.Net agent as model in AG Studio

## Step 1. Create Dotnet empty web app and install AutoGen and AutoGen.WebAPI package

```bash
dotnet new web
dotnet add package AutoGen
dotnet add package AutoGen.WebAPI
```

## Step 2. Replace the Program.cs with following code

```bash
using AutoGen.Core;
using AutoGen.Service;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

var helloWorldAgent = new HelloWorldAgent();
app.UseAgentAsOpenAIChatCompletionEndpoint(helloWorldAgent);

app.Run();

class HelloWorldAgent : IAgent
{
public string Name => "HelloWorld";

public Task<IMessage> GenerateReplyAsync(IEnumerable<IMessage> messages, GenerateReplyOptions? options = null, CancellationToken cancellationToken = default)
{
return Task.FromResult<IMessage>(new TextMessage(Role.Assistant, "Hello World!", from: this.Name));
}
}
```

## Step 3: Start the web app

Run the following command to start web api

```bash
dotnet RUN
```

The web api will listen at `http://localhost:5264/v1/chat/completion

![terminal](../images/articles/UseAutoGenAsModelinAGStudio/Terminal.png)

## Step 4: In another terminal, start autogen-studio

```bash
autogenstudio ui
```

## Step 5: Navigate to AutoGen Studio UI and add hello world agent as openai Model

### Step 5.1: Go to model tab

![The Model Tab](../images/articles/UseAutoGenAsModelinAGStudio/TheModelTab.png)

### Step 5.2: Select "OpenAI model" card

![Open AI model Card](../images/articles/UseAutoGenAsModelinAGStudio/Step5.2OpenAIModel.png)

### Step 5.3: Fill the model name and url

The model name needs to be same with agent name

![Fill the model name and url](../images/articles/UseAutoGenAsModelinAGStudio/Step5.3ModelNameAndURL.png)

## Step 6: Create a hello world agent that uses the hello world model

![Create a hello world agent that uses the hello world model](../images/articles/UseAutoGenAsModelinAGStudio/Step6.png)

![Agent Configuration](../images/articles/UseAutoGenAsModelinAGStudio/Step6b.png)

## Final Step: Use the hello world agent in workflow

![Use the hello world agent in workflow](../images/articles/UseAutoGenAsModelinAGStudio/FinalStepsA.png)

![Use the hello world agent in workflow](../images/articles/UseAutoGenAsModelinAGStudio/FinalStepsA.png)

![Use the hello world agent in workflow](../images/articles/UseAutoGenAsModelinAGStudio/FinalStepsB.png)

![Use the hello world agent in workflow](../images/articles/UseAutoGenAsModelinAGStudio/FinalStepsC.png)
5 changes: 4 additions & 1 deletion dotnet/website/tutorial/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
href: Image-chat-with-agent.md

- name: Create agent with tools
href: Create-agent-with-tools.md
href: Create-agent-with-tools.md

- name: Use AutoGen.Net agent as model in AG Studio
href: Use-AutoGen.Net-agent-as-model-in-AG-Studio.md
Loading