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
|
|
|
|
|
|
|
|
public bool IsReasoning => false;
|
|
|
|
|
|
2023-10-20 03:47:14 +00:00
|
|
|
public List<NameDesc> Parameters => new List<NameDesc>
|
|
|
|
|
{
|
|
|
|
|
new NameDesc("reason", "why response to user"),
|
|
|
|
|
new NameDesc("response", "response content")
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-22 20:38:58 +00:00
|
|
|
public ResponseToUserRoutingHandler(IServiceProvider services, ILogger<ResponseToUserRoutingHandler> logger, RoutingSettings settings)
|
|
|
|
|
: base(services, logger, settings)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-27 12:51:15 +00:00
|
|
|
public async Task<RoleDialogModel> Handle(IRoutingService routing, FunctionCallFromLlm inst)
|
2023-09-22 20:38:58 +00:00
|
|
|
{
|
2023-10-13 23:36:57 +00:00
|
|
|
var result = new RoleDialogModel(AgentRole.Assistant, inst.Response)
|
2023-09-22 20:38:58 +00:00
|
|
|
{
|
2023-10-27 15:18:48 +00:00
|
|
|
MessageId = inst.MessageId,
|
2023-09-23 21:33:05 +00:00
|
|
|
CurrentAgentId = _settings.RouterId,
|
2023-09-22 20:38:58 +00:00
|
|
|
FunctionName = inst.Function,
|
2023-10-23 00:31:49 +00:00
|
|
|
Data = inst,
|
2023-09-22 20:38:58 +00:00
|
|
|
StopCompletion = true
|
|
|
|
|
};
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|