初始提交

This commit is contained in:
2026-08-26 18:06:02 +08:00
commit 5544788917
53 changed files with 4101 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
using MAF1.Agents.FileCity;
namespace MAF1.Workflows;
public static class CityWeatherWorkflow
{
public static Workflow BuildNodeCondition(AIAgent fileCityAgent, AIAgent weatherAgent)
{
(ExecutorBinding fileCity, ExecutorBinding weather) = BindAgents(fileCityAgent, weatherAgent);
CityGateExecutor gate = new();
return new WorkflowBuilder(fileCity)
.AddEdge(fileCity, gate)
.AddEdge(gate, weather)
.WithOutputFrom(gate, weather)
.WithName("CityWeather-Node")
.Build();
}
public static Workflow BuildEdgeCondition(AIAgent fileCityAgent, AIAgent weatherAgent)
{
(ExecutorBinding fileCity, ExecutorBinding weather) = BindAgents(fileCityAgent, weatherAgent);
CityParseExecutor parse = new();
ToWeatherPromptExecutor toWeather = new();
SkipWeatherExecutor skip = new();
return new WorkflowBuilder(fileCity)
.AddEdge(fileCity, parse)
.AddEdge<CityExtraction>(parse, toWeather, extraction => extraction is { HasValidCities: true })
.AddEdge<CityExtraction>(parse, skip, extraction => extraction is not { HasValidCities: true })
.AddEdge(toWeather, weather)
.WithOutputFrom(skip, weather)
.WithName("CityWeather-Edge")
.Build();
}
private static (ExecutorBinding FileCity, ExecutorBinding Weather) BindAgents(AIAgent fileCityAgent, AIAgent weatherAgent)
{
AIAgentHostOptions agentOptions = new()
{
ForwardIncomingMessages = false,
ReassignOtherAgentsAsUsers = true,
EmitAgentUpdateEvents = true,
EmitAgentResponseEvents = true,
};
return (fileCityAgent.BindAsExecutor(agentOptions), weatherAgent.BindAsExecutor(agentOptions));
}
}