mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
samples: WorkflowHelper => WorkflowFactory (#1640)
This commit is contained in:
committed by
GitHub
Unverified
parent
e9687d59b4
commit
feb3404a27
@@ -35,7 +35,7 @@ public static class Program
|
||||
var chatClient = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential()).GetChatClient(deploymentName).AsIChatClient();
|
||||
|
||||
// Create the workflow and turn it into an agent
|
||||
var workflow = WorkflowHelper.GetWorkflow(chatClient);
|
||||
var workflow = WorkflowFactory.BuildWorkflow(chatClient);
|
||||
var agent = workflow.AsAgent("workflow-agent", "Workflow Agent");
|
||||
var thread = agent.GetNewThread();
|
||||
|
||||
|
||||
+2
-2
@@ -6,14 +6,14 @@ using Microsoft.Extensions.AI;
|
||||
|
||||
namespace WorkflowAsAnAgentsSample;
|
||||
|
||||
internal static class WorkflowHelper
|
||||
internal static class WorkflowFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a workflow that uses two language agents to process input concurrently.
|
||||
/// </summary>
|
||||
/// <param name="chatClient">The chat client to use for the agents</param>
|
||||
/// <returns>A workflow that processes input using two language agents</returns>
|
||||
internal static Workflow GetWorkflow(IChatClient chatClient)
|
||||
internal static Workflow BuildWorkflow(IChatClient chatClient)
|
||||
{
|
||||
// Create executors
|
||||
var startExecutor = new ConcurrentStartExecutor();
|
||||
+2
-2
@@ -25,7 +25,7 @@ public static class Program
|
||||
private static async Task Main()
|
||||
{
|
||||
// Create the workflow
|
||||
var workflow = WorkflowHelper.GetWorkflow();
|
||||
var workflow = WorkflowFactory.BuildWorkflow();
|
||||
|
||||
// Create checkpoint manager
|
||||
var checkpointManager = CheckpointManager.Default;
|
||||
@@ -67,7 +67,7 @@ public static class Program
|
||||
Console.WriteLine($"Number of checkpoints created: {checkpoints.Count}");
|
||||
|
||||
// Rehydrate a new workflow instance from a saved checkpoint and continue execution
|
||||
var newWorkflow = WorkflowHelper.GetWorkflow();
|
||||
var newWorkflow = WorkflowFactory.BuildWorkflow();
|
||||
const int CheckpointIndex = 5;
|
||||
Console.WriteLine($"\n\nHydrating a new workflow instance from the {CheckpointIndex + 1}th checkpoint.");
|
||||
CheckpointInfo savedCheckpoint = checkpoints[CheckpointIndex];
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ using Microsoft.Agents.AI.Workflows;
|
||||
|
||||
namespace WorkflowCheckpointAndRehydrateSample;
|
||||
|
||||
internal static class WorkflowHelper
|
||||
internal static class WorkflowFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a workflow that plays a number guessing game with checkpointing support.
|
||||
@@ -13,7 +13,7 @@ internal static class WorkflowHelper
|
||||
/// 2. JudgeExecutor: Evaluates the guess and provides feedback.
|
||||
/// The workflow continues until the correct number is guessed.
|
||||
/// </summary>
|
||||
internal static Workflow GetWorkflow()
|
||||
internal static Workflow BuildWorkflow()
|
||||
{
|
||||
// Create the executors
|
||||
GuessNumberExecutor guessNumberExecutor = new(1, 100);
|
||||
@@ -24,7 +24,7 @@ public static class Program
|
||||
private static async Task Main()
|
||||
{
|
||||
// Create the workflow
|
||||
var workflow = WorkflowHelper.GetWorkflow();
|
||||
var workflow = WorkflowFactory.BuildWorkflow();
|
||||
|
||||
// Create checkpoint manager
|
||||
var checkpointManager = CheckpointManager.Default;
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ using Microsoft.Agents.AI.Workflows;
|
||||
|
||||
namespace WorkflowCheckpointAndResumeSample;
|
||||
|
||||
internal static class WorkflowHelper
|
||||
internal static class WorkflowFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a workflow that plays a number guessing game with checkpointing support.
|
||||
@@ -13,7 +13,7 @@ internal static class WorkflowHelper
|
||||
/// 2. JudgeExecutor: Evaluates the guess and provides feedback.
|
||||
/// The workflow continues until the correct number is guessed.
|
||||
/// </summary>
|
||||
internal static Workflow GetWorkflow()
|
||||
internal static Workflow BuildWorkflow()
|
||||
{
|
||||
// Create the executors
|
||||
GuessNumberExecutor guessNumberExecutor = new(1, 100);
|
||||
+1
-1
@@ -27,7 +27,7 @@ public static class Program
|
||||
private static async Task Main()
|
||||
{
|
||||
// Create the workflow
|
||||
var workflow = WorkflowHelper.GetWorkflow();
|
||||
var workflow = WorkflowFactory.BuildWorkflow();
|
||||
|
||||
// Create checkpoint manager
|
||||
var checkpointManager = CheckpointManager.Default;
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@ using Microsoft.Agents.AI.Workflows;
|
||||
|
||||
namespace WorkflowCheckpointWithHumanInTheLoopSample;
|
||||
|
||||
internal static class WorkflowHelper
|
||||
internal static class WorkflowFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a workflow that plays a number guessing game with human-in-the-loop interaction.
|
||||
/// An input port allows the external world to provide inputs to the workflow upon requests.
|
||||
/// </summary>
|
||||
internal static Workflow GetWorkflow()
|
||||
internal static Workflow BuildWorkflow()
|
||||
{
|
||||
// Create the executors
|
||||
RequestPort numberRequest = RequestPort.Create<SignalWithNumber, int>("GuessNumber");
|
||||
+1
-1
@@ -24,7 +24,7 @@ public static class Program
|
||||
private static async Task Main()
|
||||
{
|
||||
// Create the workflow
|
||||
var workflow = WorkflowHelper.GetWorkflow();
|
||||
var workflow = WorkflowFactory.BuildWorkflow();
|
||||
|
||||
// Execute the workflow
|
||||
await using StreamingRun handle = await InProcessExecution.StreamAsync(workflow, NumberSignal.Init);
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@ using Microsoft.Agents.AI.Workflows;
|
||||
|
||||
namespace WorkflowHumanInTheLoopBasicSample;
|
||||
|
||||
internal static class WorkflowHelper
|
||||
internal static class WorkflowFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a workflow that plays a number guessing game with human-in-the-loop interaction.
|
||||
/// An input port allows the external world to provide inputs to the workflow upon requests.
|
||||
/// </summary>
|
||||
internal static Workflow GetWorkflow()
|
||||
internal static Workflow BuildWorkflow()
|
||||
{
|
||||
// Create the executors
|
||||
RequestPort numberRequestPort = RequestPort.Create<NumberSignal, int>("GuessNumber");
|
||||
Reference in New Issue
Block a user