BotSharp/src/Plugins/BotSharp.Plugin.KnowledgeBase/KnowledgeBasePlugin.cs

46 lines
1.7 KiB
C#
Raw Normal View History

2024-01-12 08:52:50 +00:00
using BotSharp.Abstraction.Plugins.Models;
using BotSharp.Abstraction.Settings;
2024-09-01 05:15:13 +00:00
using BotSharp.Plugin.KnowledgeBase.Converters;
2024-07-17 21:03:46 +00:00
using BotSharp.Plugin.KnowledgeBase.Hooks;
2024-09-05 15:34:35 +00:00
using BotSharp.Plugin.KnowledgeBase.Services;
2023-06-26 23:08:24 +00:00
using Microsoft.Extensions.Configuration;
namespace BotSharp.Plugin.KnowledgeBase;
2023-06-26 23:08:24 +00:00
public class KnowledgeBasePlugin : IBotSharpPlugin
{
2024-01-12 22:20:22 +00:00
public string Id => "f1625e9f-8de5-467b-b230-556364d8b117";
2023-12-26 03:16:41 +00:00
public string Name => "Knowledge Base";
public string Description => "Embedding private data and feed them into LLM in the conversation.";
2024-01-06 22:24:22 +00:00
public string IconUrl => "https://cdn-icons-png.flaticon.com/512/9592/9592995.png";
2023-06-26 23:08:24 +00:00
public void RegisterDI(IServiceCollection services, IConfiguration config)
{
services.AddScoped(provider =>
{
var settingService = provider.GetRequiredService<ISettingService>();
return settingService.Bind<KnowledgeBaseSettings>("KnowledgeBase");
});
2023-06-26 23:08:24 +00:00
services.AddSingleton<IPdf2TextConverter, PigPdf2TextConverter>();
2024-07-17 21:03:46 +00:00
services.AddScoped<IAgentUtilityHook, KnowledgeBaseUtilityHook>();
services.AddScoped<IAgentHook, KnowledgeBaseAgentHook>();
services.AddScoped<IKnowledgeService, KnowledgeService>();
2023-06-26 23:08:24 +00:00
}
2024-01-12 08:52:50 +00:00
2024-01-15 21:35:01 +00:00
public bool AttachMenu(List<PluginMenuDef> menu)
2024-01-12 08:52:50 +00:00
{
2024-01-15 21:35:01 +00:00
var section = menu.First(x => x.Label == "Apps");
menu.Add(new PluginMenuDef("Knowledge Base", icon: "bx bx-book-open", weight: section.Weight + 1)
{
SubMenu = new List<PluginMenuDef>
{
2024-08-23 18:49:06 +00:00
new PluginMenuDef("Q & A", link: "page/knowledge-base/question-answer"),
2024-08-28 16:08:12 +00:00
new PluginMenuDef("Relationships", link: "page/knowledge-base/relationships")
}
});
2024-01-15 21:35:01 +00:00
return true;
2024-01-12 08:52:50 +00:00
}
2023-06-26 23:08:24 +00:00
}