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

49 lines
2 KiB
C#
Raw Normal View History

2023-09-22 20:38:58 +00:00
using BotSharp.Abstraction.Routing.Settings;
namespace BotSharp.Core.Routing.Handlers;
public class ResponseToUserRoutingHandler : RoutingHandlerBase, IRoutingHandler
{
public string Name => "response_to_user";
2024-03-30 00:07:09 +00:00
public string Description => "When you can handle the conversation 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
{
2024-04-23 19:02:00 +00:00
new ParameterPropertyDef("reason",
"why response to user directly without go to other agents."),
2024-04-23 19:02:00 +00:00
new ParameterPropertyDef("response",
"response content to user in courteous words with language English. If the user wants to end the conversation, you must set conversation_end to true and response politely."),
new ParameterPropertyDef("conversation_end",
"whether to end this conversation.",
2024-04-23 19:02:00 +00:00
type: "boolean"),
new ParameterPropertyDef("task_completed ",
"whether the user's task request has been completed.",
type: "boolean"),
new ParameterPropertyDef("language",
"User preferred language, considering the whole conversation. Language could be English, Spanish or Chinese.",
2024-04-23 19:02:00 +00:00
required: true),
new ParameterPropertyDef("lastest_message_translated_to_english",
"Translate user lastest message in [CONVERSATION] to English"),
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)
{
}
public async Task<bool> Handle(IRoutingService routing, FunctionCallFromLlm inst, RoleDialogModel message)
2023-09-22 20:38:58 +00:00
{
2023-10-30 16:48:18 +00:00
var response = new RoleDialogModel(AgentRole.Assistant, inst.Response)
{
CurrentAgentId = message.CurrentAgentId,
MessageId = message.MessageId,
StopCompletion = true
};
_dialogs.Add(response);
return true;
2023-09-22 20:38:58 +00:00
}
}