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-09-26 16:18:42 +00:00
|
|
|
public string Description => "You know how to response according to the context without asking specific agent. For example user greeting.";
|
2023-09-22 20:38:58 +00:00
|
|
|
|
2023-09-24 16:20:02 +00:00
|
|
|
public List<NameDesc> Parameters => new List<NameDesc>
|
2023-09-22 20:38:58 +00:00
|
|
|
{
|
2023-09-24 16:20:02 +00:00
|
|
|
new NameDesc("answer", "the content of response"),
|
|
|
|
|
new NameDesc("reason", "why response to user")
|
2023-09-22 20:38:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public bool IsReasoning => false;
|
|
|
|
|
|
|
|
|
|
public ResponseToUserRoutingHandler(IServiceProvider services, ILogger<ResponseToUserRoutingHandler> logger, RoutingSettings settings)
|
|
|
|
|
: base(services, logger, settings)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<RoleDialogModel> Handle(FunctionCallFromLlm inst)
|
|
|
|
|
{
|
2023-09-23 21:33:05 +00:00
|
|
|
var result = new RoleDialogModel(AgentRole.Assistant, inst.Answer)
|
2023-09-22 20:38:58 +00:00
|
|
|
{
|
2023-09-23 21:33:05 +00:00
|
|
|
CurrentAgentId = _settings.RouterId,
|
2023-09-22 20:38:58 +00:00
|
|
|
FunctionName = inst.Function,
|
|
|
|
|
StopCompletion = true
|
|
|
|
|
};
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|