2023-09-22 20:38:58 +00:00
|
|
|
using BotSharp.Abstraction.Functions.Models;
|
|
|
|
|
using BotSharp.Abstraction.Routing;
|
|
|
|
|
using BotSharp.Abstraction.Routing.Settings;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Core.Routing.Handlers;
|
|
|
|
|
|
|
|
|
|
public class ConversationEndRoutingHandler : RoutingHandlerBase, IRoutingHandler
|
|
|
|
|
{
|
|
|
|
|
public string Name => "conversation_end";
|
|
|
|
|
|
2023-10-13 20:08:59 +00:00
|
|
|
public string Description => "User wants to end the conversation.";
|
2023-09-22 20:38:58 +00:00
|
|
|
|
|
|
|
|
public bool IsReasoning => false;
|
|
|
|
|
|
|
|
|
|
public ConversationEndRoutingHandler(IServiceProvider services, ILogger<ConversationEndRoutingHandler> logger, RoutingSettings settings)
|
|
|
|
|
: base(services, logger, settings)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-13 20:08:59 +00:00
|
|
|
public async Task<RoleDialogModel> Handle(IRoutingService routing, FunctionCallFromLlm inst)
|
2023-09-22 20:38:58 +00:00
|
|
|
{
|
2023-10-13 20:08:59 +00:00
|
|
|
var result = new RoleDialogModel(AgentRole.Assistant, inst.Answer)
|
|
|
|
|
{
|
|
|
|
|
CurrentAgentId = _settings.RouterId,
|
|
|
|
|
FunctionName = inst.Function,
|
|
|
|
|
StopCompletion = true
|
|
|
|
|
};
|
|
|
|
|
return result;
|
2023-09-22 20:38:58 +00:00
|
|
|
}
|
|
|
|
|
}
|