Skip to content

Commit 5472d6e

Browse files
authored
Overhaul orchestration library with new approach (#199)
1 parent 27f7af2 commit 5472d6e

104 files changed

Lines changed: 1211 additions & 5083 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dotnet/samples/GettingStarted/Orchestration/ConcurrentOrchestration_Intro.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ public async Task RunOrchestrationAsync(bool streamedResponse)
4343
// Run the orchestration
4444
string input = "What is temperature?";
4545
Console.WriteLine($"\n# INPUT: {input}\n");
46-
OrchestrationResult<string[]> result = await orchestration.InvokeAsync(input);
46+
AgentRunResponse result = await orchestration.RunAsync(input);
4747

48-
string[] output = await result;
49-
Console.WriteLine($"\n# RESULT:\n{string.Join("\n\n", output.Select(text => $"{text}"))}");
48+
Console.WriteLine($"\n# RESULT:\n{string.Join("\n\n", result.Messages.Select(r => $"{r.Text}"))}");
5049

5150
this.DisplayHistory(monitor.History);
5251
}

dotnet/samples/GettingStarted/Orchestration/ConcurrentOrchestration_With_StructuredOutput.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,14 @@ public async Task RunOrchestrationAsync()
3232
description: "An expert in entity recognition");
3333

3434
// Define the orchestration with transform
35-
StructuredOutputTransform<Analysis> outputTransform = new(this.CreateChatClient());
36-
ConcurrentOrchestration<string, Analysis> orchestration =
37-
new(agent1, agent2, agent3)
38-
{
39-
LoggerFactory = this.LoggerFactory,
40-
ResultTransform = outputTransform.TransformAsync,
41-
};
35+
ConcurrentOrchestration orchestration = new(agent1, agent2, agent3) { LoggerFactory = this.LoggerFactory };
4236

4337
// Run the orchestration
4438
const string resourceId = "Hamlet_full_play_summary.txt";
4539
string input = Resources.Read(resourceId);
4640
Console.WriteLine($"\n# INPUT: @{resourceId}\n");
47-
OrchestrationResult<Analysis> result = await orchestration.InvokeAsync(input);
4841

49-
Analysis output = await result;
42+
var output = await orchestration.RunAsync<Analysis>(this.CreateChatClient(), input);
5043
Console.WriteLine($"\n# RESULT:\n{JsonSerializer.Serialize(output, s_options)}");
5144
}
5245

dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_Intro.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ Consider suggestions when refining an idea.
6868

6969
string input = "Create a slogon for a new eletric SUV that is affordable and fun to drive.";
7070
Console.WriteLine($"\n# INPUT: {input}\n");
71-
OrchestrationResult<string> result = await orchestration.InvokeAsync(input);
72-
Console.WriteLine($"\n# RESULT: {await result}");
71+
AgentRunResponse result = await orchestration.RunAsync(input);
72+
Console.WriteLine($"\n# RESULT: {result}");
7373

7474
this.DisplayHistory(monitor.History);
7575
}

dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_With_AIManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ You are in a debate. Feel free to challenge the other participants with respect.
132132

133133
// Run the orchestration
134134
Console.WriteLine($"\n# INPUT: {topic}\n");
135-
OrchestrationResult<string> result = await orchestration.InvokeAsync(topic);
136-
Console.WriteLine($"\n# RESULT: {await result}");
135+
AgentRunResponse result = await orchestration.RunAsync(topic);
136+
Console.WriteLine($"\n# RESULT: {result}");
137137

138138
this.DisplayHistory(monitor.History);
139139
}

dotnet/samples/GettingStarted/Orchestration/GroupChatOrchestration_With_HumanInTheLoop.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ Consider suggestions when refining an idea.
6969
// Run the orchestration
7070
string input = "Create a slogon for a new eletric SUV that is affordable and fun to drive.";
7171
Console.WriteLine($"\n# INPUT: {input}\n");
72-
OrchestrationResult<string> result = await orchestration.InvokeAsync(input);
73-
Console.WriteLine($"\n# RESULT: {await result}");
72+
AgentRunResponse result = await orchestration.RunAsync(input);
73+
Console.WriteLine($"\n# RESULT: {result}");
7474

7575
this.DisplayHistory(monitor.History);
7676
}

dotnet/samples/GettingStarted/Orchestration/HandoffOrchestration_Intro.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public async Task RunOrchestrationAsync(bool streamedResponse)
8080

8181
// Run the orchestration
8282
Console.WriteLine($"\n# INPUT:\n{task}\n");
83-
OrchestrationResult<string> result = await orchestration.InvokeAsync(task);
83+
AgentRunResponse result = await orchestration.RunAsync(task);
8484

85-
Console.WriteLine($"\n# RESULT: {await result}");
85+
Console.WriteLine($"\n# RESULT: {result}");
8686

8787
this.DisplayHistory(monitor.History);
8888
}

dotnet/samples/GettingStarted/Orchestration/HandoffOrchestration_With_StructuredInput.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

3+
using System.Text.Json;
34
using System.Text.Json.Serialization;
45
using Microsoft.Agents.Orchestration;
56
using Microsoft.Extensions.AI;
@@ -44,7 +45,7 @@ public async Task RunOrchestrationAsync()
4445
OrchestrationMonitor monitor = new();
4546

4647
// Define the orchestration
47-
HandoffOrchestration<GithubIssue, string> orchestration =
48+
HandoffOrchestration orchestration =
4849
new(OrchestrationHandoffs
4950
.StartWith(triageAgent)
5051
.Add(triageAgent, dotnetAgent, pythonAgent))
@@ -80,8 +81,8 @@ Normal DBContext logging shows only normal context queries. Queries run by Vecto
8081

8182
// Run the orchestration
8283
Console.WriteLine($"\n# INPUT:\n{input.Id}: {input.Title}\n");
83-
OrchestrationResult<string> result = await orchestration.InvokeAsync(input);
84-
Console.WriteLine($"\n# RESULT: {await result}");
84+
AgentRunResponse result = await orchestration.RunAsync(JsonSerializer.Serialize(input));
85+
Console.WriteLine($"\n# RESULT: {result}");
8586
Console.WriteLine($"\n# LABELS: {string.Join(",", githubPlugin.Labels["12345"])}\n");
8687
}
8788

dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_Intro.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ give format and make it polished. Output the final improved copy as a single tex
6565
// Run the orchestration
6666
string input = "An eco-friendly stainless steel water bottle that keeps drinks cold for 24 hours";
6767
Console.WriteLine($"\n# INPUT: {input}\n");
68-
OrchestrationResult<string> result = await orchestration.InvokeAsync(input);
69-
Console.WriteLine($"\n# RESULT: {await result}");
68+
AgentRunResponse result = await orchestration.RunAsync(input);
69+
Console.WriteLine($"\n# RESULT: {result}");
7070

7171
this.DisplayHistory(monitor.History);
7272
}

dotnet/samples/GettingStarted/Orchestration/SequentialOrchestration_With_Cancellation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

33
using Microsoft.Agents.Orchestration;
4+
using Microsoft.Extensions.AI;
45
using Microsoft.Extensions.AI.Agents;
56

67
namespace Orchestration;
@@ -28,7 +29,7 @@ public async Task RunOrchestrationAsync()
2829
string input = "42";
2930
Console.WriteLine($"\n# INPUT: {input}\n");
3031

31-
OrchestrationResult<string> result = await orchestration.InvokeAsync(input);
32+
OrchestratingAgentResponse result = await orchestration.RunAsync([new ChatMessage(ChatRole.User, input)]);
3233

3334
result.Cancel();
3435
await Task.Delay(TimeSpan.FromSeconds(3));

dotnet/samples/HelloHttpApi/HelloHttpApi.ApiService/AgentsJsonContext.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)