BotSharp/src/Infrastructure/BotSharp.Core/Agents/AgentPlugin.cs

56 lines
1.9 KiB
C#
Raw Normal View History

using BotSharp.Abstraction.MLTasks;
2024-01-15 21:35:01 +00:00
using BotSharp.Abstraction.Plugins.Models;
using BotSharp.Abstraction.Settings;
2024-05-16 17:58:37 +00:00
using BotSharp.Abstraction.Users.Enums;
using Microsoft.Extensions.Configuration;
namespace BotSharp.Core.Agents;
public class AgentPlugin : IBotSharpPlugin
{
public string Id => "f4b367f8-4945-476a-90a7-c3bb8e6d6e49";
public string Name => "Agent";
2024-01-16 19:23:45 +00:00
public string Description => "A container of agent profile includes instruction, functions, examples and templates/ response templates.";
public SettingsMeta Settings =>
new SettingsMeta("Agent");
2024-04-22 20:46:47 +00:00
public string[] AgentIds => new string[]
{
2024-06-24 17:37:12 +00:00
BuiltInAgentId.AIAssistant,
BuiltInAgentId.Chatbot,
BuiltInAgentId.HumanSupport
2024-04-22 20:46:47 +00:00
};
public object GetNewSettingsInstance() =>
new AgentSettings();
public void RegisterDI(IServiceCollection services, IConfiguration config)
{
services.AddScoped<ILlmProviderService, LlmProviderService>();
services.AddScoped<IAgentService, AgentService>();
services.AddScoped(provider =>
{
var settingService = provider.GetRequiredService<ISettingService>();
return settingService.Bind<AgentSettings>("Agent");
});
}
2024-01-15 21:35:01 +00:00
public bool AttachMenu(List<PluginMenuDef> menu)
{
var section = menu.First(x => x.Label == "Apps");
menu.Add(new PluginMenuDef("Agent", icon: "bx bx-bot", weight: section.Weight + 1)
{
SubMenu = new List<PluginMenuDef>
{
2024-06-12 19:32:15 +00:00
new PluginMenuDef("Routing", link: "page/agent/router"), // icon: "bx bx-map-pin"
2024-10-31 19:36:26 +00:00
new PluginMenuDef("Evaluating", link: "page/agent/evaluator") { Roles = new List<string> { UserRole.Root, UserRole.Admin } }, // icon: "bx bx-task"
2024-01-30 22:20:23 +00:00
new PluginMenuDef("Agents", link: "page/agent"), // icon: "bx bx-bot"
2024-01-15 21:35:01 +00:00
}
});
return true;
}
}