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>
42 lines
2.2 KiB
C#
42 lines
2.2 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using Microsoft.Agents.AI.Workflows.Checkpointing;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows;
|
|
|
|
/// <summary>
|
|
/// Represents a request from an external input port.
|
|
/// </summary>
|
|
/// <param name="PortInfo">The port invoked.</param>
|
|
/// <param name="RequestId">The unique identifier of the corresponding request.</param>
|
|
/// <param name="Data">The data contained in the response.</param>
|
|
public record ExternalResponse(RequestPortInfo PortInfo, string RequestId, PortableValue Data)
|
|
{
|
|
/// <summary>
|
|
/// Determines whether the underlying data is of the specified type.
|
|
/// </summary>
|
|
/// <typeparam name="TValue">The type to compare with the underlying data.</typeparam>
|
|
/// <returns>true if the underlying data is of type TValue; otherwise, false.</returns>
|
|
public bool IsDataOfType<TValue>() => this.Data.Is<TValue>();
|
|
|
|
/// <summary>
|
|
/// Determines whether the underlying data can be retrieved as the specified type.
|
|
/// </summary>
|
|
/// <typeparam name="TValue">The type to which the underlying data is to be cast if available.</typeparam>
|
|
/// <param name="value">When this method returns, contains the value of type <typeparamref name="TValue"/> if the data is
|
|
/// available and compatible.</param>
|
|
/// <returns>true if the data is present and can be cast to <typeparamref name="TValue"/>; otherwise, false.</returns>
|
|
public bool TryGetDataAs<TValue>([NotNullWhen(true)] out TValue? value) => this.Data.Is(out value);
|
|
|
|
/// <summary>
|
|
/// Attempts to retrieve the underlying data as the specified type.
|
|
/// </summary>
|
|
/// <param name="targetType">The type to which the data should be cast or converted.</param>
|
|
/// <param name="value">When this method returns <see langword="true"/>, contains the value of type
|
|
/// <paramref name="targetType"/> if the data is available and compatible.</param>
|
|
/// <returns>true if the data is present and can be cast to <paramref name="targetType"/>; otherwise, false.</returns>
|
|
public bool TryGetDataAs(Type targetType, [NotNullWhen(true)] out object? value) => this.Data.IsType(targetType, out value);
|
|
}
|