route_to_agent fallback

This commit is contained in:
Haiping Chen 2023-09-21 14:21:59 -05:00
parent f0e9ac50bf
commit 8abc002f14
2 changed files with 17 additions and 2 deletions

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<LangVersion>10.0</LangVersion>
<OutputPath>..\..\..\packages</OutputPath>
<BotSharpVersion>0.14.5</BotSharpVersion>
<BotSharpVersion>0.14.6</BotSharpVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
</Project>

View file

@ -59,8 +59,23 @@ public class RoutingService : IRoutingService
// Compatible with previous Router, can be removed in the future.
else if (inst.Function == "route_to_agent")
{
// If the agent name is empty, fallback to router
if (string.IsNullOrEmpty(inst.Parameters.AgentName))
{
result = new RoleDialogModel(AgentRole.Function, inst.Reason)
{
FunctionName = inst.Function,
FunctionArgs = JsonSerializer.Serialize(new RoutingArgs
{
AgentName = inst.Parameters.AgentName
}),
CurrentAgentId = router.Id
};
break;
}
var function = _services.GetServices<IFunctionCallback>().FirstOrDefault(x => x.Name == inst.Function);
result = new RoleDialogModel(AgentRole.Function, inst.Parameters.Question)
result = new RoleDialogModel(AgentRole.Function, inst.Reason)
{
FunctionName = inst.Function,
FunctionArgs = JsonSerializer.Serialize(new RoutingArgs