mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* refactor: Normalize Run/RunStreaming with AIAgent * refactor: Clarify Session vs. Run -level concepts * Rename RunId to SessionId to better match Run/Session terminology in AIAgent * [BREAKING]: Will break existing checkpointed sessions in CosmosDb due to field rename * refactor: Rename and simplify interface around getting typed data out of ExternalRequest/Response * Also adds hints around using value types in PortableValue * refactor: Rename AddFanInEdge to AddFanInBarrierEdge This will prevent a breaking change later when we introduce a programmable FanIn edge, analogous to the FanOut edge's EdgeSelector. The goal, in the long run is to support a number of different FanIn scenarios, with naive FanIn (no barrier) by default, similar to FanOut. * refactor: AsAgent(this Workflow, ...) => AsAIAgent(...) * misc - part1: SwitchBuilder internal --------- Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com>
50 lines
2.3 KiB
C#
50 lines
2.3 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.AI;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows;
|
|
|
|
/// <summary>
|
|
/// Provides extension methods for treating workflows as <see cref="AIAgent"/>
|
|
/// </summary>
|
|
public static class WorkflowHostingExtensions
|
|
{
|
|
/// <summary>
|
|
/// Convert a workflow with the appropriate primary input type to an <see cref="AIAgent"/>.
|
|
/// </summary>
|
|
/// <param name="workflow">The workflow to be hosted by the resulting <see cref="AIAgent"/></param>
|
|
/// <param name="id">A unique id for the hosting <see cref="AIAgent"/>.</param>
|
|
/// <param name="name">A name for the hosting <see cref="AIAgent"/>.</param>
|
|
/// <param name="description">A description for the hosting <see cref="AIAgent"/>.</param>
|
|
/// <param name="executionEnvironment">Specify the execution environment to use when running the workflows. See
|
|
/// <see cref="InProcessExecution.OffThread"/>, <see cref="InProcessExecution.Concurrent"/> and
|
|
/// <see cref="InProcessExecution.Lockstep"/> for the in-process environments.</param>
|
|
/// <param name="includeExceptionDetails">If <see langword="true"/>, will include <see cref="System.Exception.Message"/>
|
|
/// in the <see cref="ErrorContent"/> representing the workflow error.</param>
|
|
/// <param name="includeWorkflowOutputsInResponse">If <see langword="true"/>, will transform outgoing workflow outputs
|
|
/// into into content in <see cref="AgentResponseUpdate"/>s or the <see cref="AgentResponse"/> as appropriate.</param>
|
|
/// <returns></returns>
|
|
public static AIAgent AsAIAgent(
|
|
this Workflow workflow,
|
|
string? id = null,
|
|
string? name = null,
|
|
string? description = null,
|
|
IWorkflowExecutionEnvironment? executionEnvironment = null,
|
|
bool includeExceptionDetails = false,
|
|
bool includeWorkflowOutputsInResponse = false)
|
|
{
|
|
return new WorkflowHostAgent(workflow, id, name, description, executionEnvironment, includeExceptionDetails, includeWorkflowOutputsInResponse);
|
|
}
|
|
|
|
internal static FunctionCallContent ToFunctionCall(this ExternalRequest request)
|
|
{
|
|
Dictionary<string, object?> parameters = new()
|
|
{
|
|
{ "data", request.Data}
|
|
};
|
|
|
|
return new FunctionCallContent(request.RequestId, request.PortInfo.PortId, parameters);
|
|
}
|
|
}
|