29 lines
962 B
C#
29 lines
962 B
C#
using MAF1.Agents.FileCity;
|
|||
|
|
using Microsoft.Agents.AI.Workflows;
|
||
|
|
|
||
|
|
namespace MAF1.Workflows;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 只有「没有城市」那条边会进到这里,所以这里不再判断。
|
||
|
|
/// </summary>
|
||
|
|
internal sealed class SkipWeatherExecutor() : Executor<CityExtraction>("SkipWeather")
|
||
|
|
{
|
||
|
|
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder builder)
|
||
|
|
{
|
||
|
|
return base.ConfigureProtocol(builder).YieldsOutput<string>();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override async ValueTask HandleAsync(
|
||
|
|
CityExtraction extraction,
|
||
|
|
IWorkflowContext context,
|
||
|
|
CancellationToken cancellationToken = default)
|
||
|
|
{
|
||
|
|
string reason = string.IsNullOrWhiteSpace(extraction.Reason)
|
||
|
|
? "文件里没有可查询的城市。"
|
||
|
|
: extraction.Reason;
|
||
|
|
await context.YieldOutputAsync(
|
||
|
|
$"没有有效城市,工作流结束,不执行 WeatherAgent。{reason}",
|
||
|
|
cancellationToken);
|
||
|
|
}
|
||
|
|
}
|