Skip to content

Commit 61248ca

Browse files
Add a new orchestration sample that uses different agent types
1 parent ba000c3 commit 61248ca

20 files changed

+451
-45
lines changed

dotnet/samples/GettingStartedWithAgents/Orchestration/Step01_Concurrent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public async Task ConcurrentTaskAsync(bool streamedResponse)
2121
{
2222
// Define the agents
2323
ChatCompletionAgent physicist =
24-
this.CreateAgent(
24+
this.CreateChatCompletionAgent(
2525
instructions: "You are an expert in physics. You answer questions from a physics perspective.",
2626
name: "Physicist",
2727
description: "An expert in physics");
2828
ChatCompletionAgent chemist =
29-
this.CreateAgent(
29+
this.CreateChatCompletionAgent(
3030
instructions: "You are an expert in chemistry. You answer questions from a chemistry perspective.",
3131
name: "Chemist",
3232
description: "An expert in chemistry");

dotnet/samples/GettingStartedWithAgents/Orchestration/Step01a_ConcurrentWithStructuredOutput.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public async Task ConcurrentStructuredOutputAsync()
2525
{
2626
// Define the agents
2727
ChatCompletionAgent agent1 =
28-
this.CreateAgent(
28+
this.CreateChatCompletionAgent(
2929
instructions: "You are an expert in identifying themes in articles. Given an article, identify the main themes.",
3030
description: "An expert in identifying themes in articles");
3131
ChatCompletionAgent agent2 =
32-
this.CreateAgent(
32+
this.CreateChatCompletionAgent(
3333
instructions: "You are an expert in sentiment analysis. Given an article, identify the sentiment.",
3434
description: "An expert in sentiment analysis");
3535
ChatCompletionAgent agent3 =
36-
this.CreateAgent(
36+
this.CreateChatCompletionAgent(
3737
instructions: "You are an expert in entity recognition. Given an article, extract the entities.",
3838
description: "An expert in entity recognition");
3939

dotnet/samples/GettingStartedWithAgents/Orchestration/Step02_Sequential.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public async Task SequentialTaskAsync(bool streamedResponse)
2222
{
2323
// Define the agents
2424
ChatCompletionAgent analystAgent =
25-
this.CreateAgent(
25+
this.CreateChatCompletionAgent(
2626
name: "Analyst",
2727
instructions:
2828
"""
@@ -33,7 +33,7 @@ public async Task SequentialTaskAsync(bool streamedResponse)
3333
""",
3434
description: "A agent that extracts key concepts from a product description.");
3535
ChatCompletionAgent writerAgent =
36-
this.CreateAgent(
36+
this.CreateChatCompletionAgent(
3737
name: "copywriter",
3838
instructions:
3939
"""
@@ -43,7 +43,7 @@ Output should be short (around 150 words), output just the copy as a single text
4343
""",
4444
description: "An agent that writes a marketing copy based on the extracted concepts.");
4545
ChatCompletionAgent editorAgent =
46-
this.CreateAgent(
46+
this.CreateChatCompletionAgent(
4747
name: "editor",
4848
instructions:
4949
"""

dotnet/samples/GettingStartedWithAgents/Orchestration/Step02a_SequentialCancellation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public async Task SequentialCancelledAsync()
1717
{
1818
// Define the agents
1919
ChatCompletionAgent agent =
20-
this.CreateAgent(
20+
this.CreateChatCompletionAgent(
2121
"""
2222
If the input message is a number, return the number incremented by one.
2323
""",

dotnet/samples/GettingStartedWithAgents/Orchestration/Step03_GroupChat.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public async Task GroupChatAsync(bool streamedResponse)
2727
{
2828
// Define the agents
2929
ChatCompletionAgent writer =
30-
this.CreateAgent(
30+
this.CreateChatCompletionAgent(
3131
name: "CopyWriter",
3232
description: "A copy writer",
3333
instructions:
@@ -40,7 +40,7 @@ Only provide a single proposal per response.
4040
Consider suggestions when refining an idea.
4141
""");
4242
ChatCompletionAgent editor =
43-
this.CreateAgent(
43+
this.CreateChatCompletionAgent(
4444
name: "Reviewer",
4545
description: "An editor.",
4646
instructions:
@@ -73,7 +73,7 @@ Consider suggestions when refining an idea.
7373
InProcessRuntime runtime = new();
7474
await runtime.StartAsync();
7575

76-
string input = "Create a slogon for a new eletric SUV that is affordable and fun to drive.";
76+
string input = "Create a slogan for a new electric SUV that is affordable and fun to drive.";
7777
Console.WriteLine($"\n# INPUT: {input}\n");
7878
OrchestrationResult<string> result = await orchestration.InvokeAsync(input, runtime);
7979
string text = await result.GetValueAsync(TimeSpan.FromSeconds(ResultTimeoutInSeconds * 3));

dotnet/samples/GettingStartedWithAgents/Orchestration/Step03a_GroupChatWithHumanInTheLoop.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public async Task GroupChatWithHumanAsync()
1919
{
2020
// Define the agents
2121
ChatCompletionAgent writer =
22-
this.CreateAgent(
22+
this.CreateChatCompletionAgent(
2323
name: "CopyWriter",
2424
description: "A copy writer",
2525
instructions:
@@ -32,7 +32,7 @@ Only provide a single proposal per response.
3232
Consider suggestions when refining an idea.
3333
""");
3434
ChatCompletionAgent editor =
35-
this.CreateAgent(
35+
this.CreateChatCompletionAgent(
3636
name: "Reviewer",
3737
description: "An editor.",
3838
instructions:
@@ -73,7 +73,7 @@ Consider suggestions when refining an idea.
7373
await runtime.StartAsync();
7474

7575
// Run the orchestration
76-
string input = "Create a slogon for a new eletric SUV that is affordable and fun to drive.";
76+
string input = "Create a slogan for a new electric SUV that is affordable and fun to drive.";
7777
Console.WriteLine($"\n# INPUT: {input}\n");
7878
OrchestrationResult<string> result = await orchestration.InvokeAsync(input, runtime);
7979
string text = await result.GetValueAsync(TimeSpan.FromSeconds(ResultTimeoutInSeconds * 3));

dotnet/samples/GettingStartedWithAgents/Orchestration/Step03b_GroupChatWithAIManager.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public async Task GroupChatWithAIManagerAsync()
2323
{
2424
// Define the agents
2525
ChatCompletionAgent farmer =
26-
this.CreateAgent(
26+
this.CreateChatCompletionAgent(
2727
name: "Farmer",
2828
description: "A rural farmer from Southeast Asia.",
2929
instructions:
@@ -34,7 +34,7 @@ You value tradition and sustainability.
3434
You are in a debate. Feel free to challenge the other participants with respect.
3535
""");
3636
ChatCompletionAgent developer =
37-
this.CreateAgent(
37+
this.CreateChatCompletionAgent(
3838
name: "Developer",
3939
description: "An urban software developer from the United States.",
4040
instructions:
@@ -45,7 +45,7 @@ Your life is fast-paced and technology-driven.
4545
You are in a debate. Feel free to challenge the other participants with respect.
4646
""");
4747
ChatCompletionAgent teacher =
48-
this.CreateAgent(
48+
this.CreateChatCompletionAgent(
4949
name: "Teacher",
5050
description: "A retired history teacher from Eastern Europe",
5151
instructions:
@@ -56,7 +56,7 @@ You bring historical and philosophical perspectives to discussions.
5656
You are in a debate. Feel free to challenge the other participants with respect.
5757
""");
5858
ChatCompletionAgent activist =
59-
this.CreateAgent(
59+
this.CreateChatCompletionAgent(
6060
name: "Activist",
6161
description: "A young activist from South America.",
6262
instructions:
@@ -66,7 +66,7 @@ You are in a debate. Feel free to challenge the other participants with respect.
6666
You are in a debate. Feel free to challenge the other participants with respect.
6767
""");
6868
ChatCompletionAgent spiritual =
69-
this.CreateAgent(
69+
this.CreateChatCompletionAgent(
7070
name: "SpiritualLeader",
7171
description: "A spiritual leader from the Middle East.",
7272
instructions:
@@ -76,7 +76,7 @@ You are in a debate. Feel free to challenge the other participants with respect.
7676
You are in a debate. Feel free to challenge the other participants with respect.
7777
""");
7878
ChatCompletionAgent artist =
79-
this.CreateAgent(
79+
this.CreateChatCompletionAgent(
8080
name: "Artist",
8181
description: "An artist from Africa.",
8282
instructions:
@@ -86,7 +86,7 @@ You are in a debate. Feel free to challenge the other participants with respect.
8686
You are in a debate. Feel free to challenge the other participants with respect.
8787
""");
8888
ChatCompletionAgent immigrant =
89-
this.CreateAgent(
89+
this.CreateChatCompletionAgent(
9090
name: "Immigrant",
9191
description: "An immigrant entrepreneur from Asia living in Canada.",
9292
instructions:
@@ -97,7 +97,7 @@ You balance trandition with adaption.
9797
You are in a debate. Feel free to challenge the other participants with respect.
9898
""");
9999
ChatCompletionAgent doctor =
100-
this.CreateAgent(
100+
this.CreateChatCompletionAgent(
101101
name: "Doctor",
102102
description: "A doctor from Scandinavia.",
103103
instructions:

dotnet/samples/GettingStartedWithAgents/Orchestration/Step04_Handoff.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ public async Task OrderSupportAsync(bool streamedResponse)
2323
{
2424
// Define the agents & tools
2525
ChatCompletionAgent triageAgent =
26-
this.CreateAgent(
26+
this.CreateChatCompletionAgent(
2727
instructions: "A customer support agent that triages issues.",
2828
name: "TriageAgent",
2929
description: "Handle customer requests.");
3030
ChatCompletionAgent statusAgent =
31-
this.CreateAgent(
31+
this.CreateChatCompletionAgent(
3232
name: "OrderStatusAgent",
3333
instructions: "Handle order status requests.",
3434
description: "A customer support agent that checks order status.");
3535
statusAgent.Kernel.Plugins.Add(KernelPluginFactory.CreateFromObject(new OrderStatusPlugin()));
3636
ChatCompletionAgent returnAgent =
37-
this.CreateAgent(
37+
this.CreateChatCompletionAgent(
3838
name: "OrderReturnAgent",
3939
instructions: "Handle order return requests.",
4040
description: "A customer support agent that handles order returns.");
4141
returnAgent.Kernel.Plugins.Add(KernelPluginFactory.CreateFromObject(new OrderReturnPlugin()));
4242
ChatCompletionAgent refundAgent =
43-
this.CreateAgent(
43+
this.CreateChatCompletionAgent(
4444
name: "OrderRefundAgent",
4545
instructions: "Handle order refund requests.",
4646
description: "A customer support agent that handles order refund.");

dotnet/samples/GettingStartedWithAgents/Orchestration/Step04a_HandoffWithStructuredInput.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ public async Task HandoffStructuredInputAsync()
2323

2424
// Define the agents
2525
ChatCompletionAgent triageAgent =
26-
this.CreateAgent(
26+
this.CreateChatCompletionAgent(
2727
instructions: "Given a GitHub issue, triage it.",
2828
name: "TriageAgent",
2929
description: "An agent that triages GitHub issues");
3030
ChatCompletionAgent pythonAgent =
31-
this.CreateAgent(
31+
this.CreateChatCompletionAgent(
3232
instructions: "You are an agent that handles Python related GitHub issues.",
3333
name: "PythonAgent",
3434
description: "An agent that handles Python related issues");
3535
pythonAgent.Kernel.Plugins.Add(plugin);
3636
ChatCompletionAgent dotnetAgent =
37-
this.CreateAgent(
37+
this.CreateChatCompletionAgent(
3838
instructions: "You are an agent that handles .NET related GitHub issues.",
3939
name: "DotNetAgent",
4040
description: "An agent that handles .NET related issues");

dotnet/samples/GettingStartedWithAgents/Orchestration/Step05_Magentic.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task MagenticTaskAsync(bool streamedResponse)
3636
// Define the agents
3737
Kernel researchKernel = CreateKernelWithOpenAIChatCompletion(ResearcherModel);
3838
ChatCompletionAgent researchAgent =
39-
this.CreateAgent(
39+
this.CreateChatCompletionAgent(
4040
name: "ResearchAgent",
4141
description: "A helpful assistant with access to web search. Ask it to perform web searches.",
4242
instructions: "You are a Researcher. You find information without additional computation or quantitative analysis.",
@@ -86,7 +86,7 @@ I am preparing a report on the energy efficiency of different machine learning m
8686
""";
8787
Console.WriteLine($"\n# INPUT:\n{input}\n");
8888
OrchestrationResult<string> result = await orchestration.InvokeAsync(input, runtime);
89-
string text = await result.GetValueAsync(TimeSpan.FromSeconds(ResultTimeoutInSeconds * 10));
89+
string text = await result.GetValueAsync(TimeSpan.FromSeconds(ResultTimeoutInSeconds * 20));
9090
Console.WriteLine($"\n# RESULT: {text}");
9191

9292
await runtime.RunUntilIdleAsync();

0 commit comments

Comments
 (0)