初始提交
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using MAF1.Agents.FileCity;
|
||||
using Microsoft.Agents.AI.Workflows;
|
||||
using Microsoft.Extensions.AI;
|
||||
|
||||
namespace MAF1.Workflows;
|
||||
|
||||
/// <summary>
|
||||
/// 边条件模式:这里只解析,不做 if。走哪条边由 AddEdge 的 condition 决定。
|
||||
/// </summary>
|
||||
internal sealed class CityParseExecutor() : ChatProtocolExecutor(
|
||||
"CityParse",
|
||||
new ChatProtocolExecutorOptions { AutoSendTurnToken = false })
|
||||
{
|
||||
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder builder)
|
||||
{
|
||||
return base.ConfigureProtocol(builder).SendsMessage<CityExtraction>();
|
||||
}
|
||||
|
||||
protected override async ValueTask TakeTurnAsync(
|
||||
List<ChatMessage> messages,
|
||||
IWorkflowContext context,
|
||||
bool? emitEvents,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
string text = string.Join(
|
||||
Environment.NewLine,
|
||||
messages
|
||||
.Where(message => !string.IsNullOrWhiteSpace(message.Text))
|
||||
.Select(message => message.Text));
|
||||
|
||||
await context.SendMessageAsync(FileCityAgent.Parse(text), cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user