BotSharp/src/Infrastructure/BotSharp.Core/Routing/Handlers/InterruptTaskExecutionRoutingHandler.cs

38 lines
1.2 KiB
C#
Raw Normal View History

2023-09-22 20:38:58 +00:00
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Routing;
using BotSharp.Abstraction.Routing.Settings;
2023-10-29 01:54:10 +00:00
using BotSharp.Core.Planning;
2023-09-22 20:38:58 +00:00
namespace BotSharp.Core.Routing.Handlers;
2023-10-30 16:48:18 +00:00
public class InterruptTaskExecutionRoutingHandler : RoutingHandlerBase//, IRoutingHandler
2023-09-22 20:38:58 +00:00
{
public string Name => "interrupt_task_execution";
public string Description => "Can't continue user's request becauase the requirements are not met.";
2023-10-28 20:59:26 +00:00
public List<ParameterPropertyDef> Parameters => new List<ParameterPropertyDef>
2023-09-22 20:38:58 +00:00
{
2023-10-28 20:59:26 +00:00
new ParameterPropertyDef("reason", "the reason why the request is interrupted"),
new ParameterPropertyDef("answer", "the content response to user")
2023-09-22 20:38:58 +00:00
};
2023-10-28 20:59:26 +00:00
public List<string> Planers => new List<string>
{
2023-10-30 16:48:18 +00:00
nameof(HFPlanner)
2023-10-28 20:59:26 +00:00
};
2023-09-22 20:38:58 +00:00
public InterruptTaskExecutionRoutingHandler(IServiceProvider services, ILogger<InterruptTaskExecutionRoutingHandler> logger, RoutingSettings settings)
: base(services, logger, settings)
{
}
public async Task<bool> Handle(IRoutingService routing, FunctionCallFromLlm inst, RoleDialogModel message)
2023-09-22 20:38:58 +00:00
{
message.FunctionName = inst.Function;
message.StopCompletion = true;
return true;
2023-09-22 20:38:58 +00:00
}
}