2023-09-22 20:38:58 +00:00
|
|
|
using BotSharp.Abstraction.Functions.Models;
|
2023-09-24 16:20:02 +00:00
|
|
|
using BotSharp.Abstraction.Models;
|
2023-09-22 20:38:58 +00:00
|
|
|
using BotSharp.Abstraction.Routing;
|
|
|
|
|
using BotSharp.Abstraction.Routing.Settings;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Core.Routing.Handlers;
|
|
|
|
|
|
|
|
|
|
public class ResponseToUserRoutingHandler : RoutingHandlerBase, IRoutingHandler
|
|
|
|
|
{
|
|
|
|
|
public string Name => "response_to_user";
|
|
|
|
|
|
2023-10-20 03:47:14 +00:00
|
|
|
public string Description => "Response according to the context without asking specific agent.";
|
2023-09-22 20:38:58 +00:00
|
|
|
|
2023-10-28 20:59:26 +00:00
|
|
|
public List<ParameterPropertyDef> Parameters => new List<ParameterPropertyDef>
|
2023-10-20 03:47:14 +00:00
|
|
|
{
|
2023-10-28 20:59:26 +00:00
|
|
|
new ParameterPropertyDef("reason", "why response to user"),
|
|
|
|
|
new ParameterPropertyDef("response", "response content")
|
2023-10-20 03:47:14 +00:00
|
|
|
};
|
|
|
|
|
|
2023-09-22 20:38:58 +00:00
|
|
|
public ResponseToUserRoutingHandler(IServiceProvider services, ILogger<ResponseToUserRoutingHandler> logger, RoutingSettings settings)
|
|
|
|
|
: base(services, logger, settings)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-27 20:36:26 +00:00
|
|
|
public async Task<bool> Handle(IRoutingService routing, FunctionCallFromLlm inst, RoleDialogModel message)
|
2023-09-22 20:38:58 +00:00
|
|
|
{
|
2023-10-27 20:36:26 +00:00
|
|
|
message.Content = inst.Response;
|
|
|
|
|
message.StopCompletion = true;
|
|
|
|
|
message.Role = AgentRole.Assistant;
|
|
|
|
|
return true;
|
2023-09-22 20:38:58 +00:00
|
|
|
}
|
|
|
|
|
}
|