2024-01-15 19:15:18 +00:00
|
|
|
using BotSharp.Abstraction.Routing;
|
|
|
|
|
using BotSharp.Abstraction.Routing.Models;
|
2024-02-19 22:55:41 +00:00
|
|
|
using BotSharp.Abstraction.Routing.Planning;
|
2024-01-15 19:15:18 +00:00
|
|
|
using BotSharp.Abstraction.Routing.Settings;
|
|
|
|
|
using BotSharp.Abstraction.Settings;
|
|
|
|
|
using BotSharp.Core.Routing.Hooks;
|
2024-01-29 18:08:49 +00:00
|
|
|
using BotSharp.Core.Routing.Planning;
|
2024-01-15 19:15:18 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Core.Routing;
|
|
|
|
|
|
|
|
|
|
public class RoutingPlugin : IBotSharpPlugin
|
|
|
|
|
{
|
|
|
|
|
public string Id => "87352ece-2c1c-477c-8236-2e047e11dcab";
|
2024-01-16 19:23:45 +00:00
|
|
|
public string Name => "Agent Routing";
|
|
|
|
|
public string Description => "Based on the conversation context, routing user request to the appropriate Agent. It's designed for complicated tasks.";
|
2024-01-15 19:15:18 +00:00
|
|
|
|
|
|
|
|
public SettingsMeta Settings =>
|
|
|
|
|
new SettingsMeta("Router");
|
|
|
|
|
|
|
|
|
|
public object GetNewSettingsInstance() =>
|
|
|
|
|
new RoutingSettings();
|
|
|
|
|
|
|
|
|
|
public void RegisterDI(IServiceCollection services, IConfiguration config)
|
|
|
|
|
{
|
|
|
|
|
services.AddScoped<RoutingContext>();
|
|
|
|
|
|
|
|
|
|
// Register router
|
|
|
|
|
services.AddScoped(provider =>
|
|
|
|
|
{
|
|
|
|
|
var settingService = provider.GetRequiredService<ISettingService>();
|
|
|
|
|
return settingService.Bind<RoutingSettings>("Router");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
services.AddScoped<IRoutingService, RoutingService>();
|
|
|
|
|
services.AddScoped<IAgentHook, RoutingAgentHook>();
|
|
|
|
|
|
2024-02-19 22:55:41 +00:00
|
|
|
services.AddScoped<IPlaner, NaivePlanner>();
|
|
|
|
|
services.AddScoped<IPlaner, HFPlanner>();
|
|
|
|
|
services.AddScoped<IPlaner, SequentialPlanner>();
|
2024-02-27 13:19:05 +00:00
|
|
|
services.AddScoped<IPlaner, TwoStagePlanner>();
|
2024-01-15 19:15:18 +00:00
|
|
|
}
|
|
|
|
|
}
|