2024-01-12 08:52:50 +00:00
|
|
|
using BotSharp.Abstraction.Plugins.Models;
|
2023-06-26 23:08:24 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
2023-09-06 12:58:02 +00:00
|
|
|
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";
|
|
|
|
|
public bool WithAgent => true;
|
|
|
|
|
|
2023-06-26 23:08:24 +00:00
|
|
|
public void RegisterDI(IServiceCollection services, IConfiguration config)
|
|
|
|
|
{
|
|
|
|
|
var settings = new KnowledgeBaseSettings();
|
|
|
|
|
config.Bind("KnowledgeBase", settings);
|
|
|
|
|
services.AddSingleton(x => settings);
|
|
|
|
|
|
2024-01-06 03:24:13 +00:00
|
|
|
var a = config["KnowledgeBase"];
|
|
|
|
|
|
2023-06-26 23:08:24 +00:00
|
|
|
services.AddScoped<ITextChopper, TextChopperService>();
|
|
|
|
|
services.AddScoped<IKnowledgeService, KnowledgeService>();
|
2023-09-06 12:58:02 +00:00
|
|
|
services.AddSingleton<IPdf2TextConverter, PigPdf2TextConverter>();
|
2023-06-26 23:08:24 +00:00
|
|
|
}
|
2024-01-12 08:52:50 +00:00
|
|
|
|
|
|
|
|
public PluginMenuDef[] GetMenus()
|
|
|
|
|
{
|
|
|
|
|
return new PluginMenuDef[]
|
|
|
|
|
{
|
|
|
|
|
new PluginMenuDef("RAG", isHeader: true, weight: 20),
|
|
|
|
|
new PluginMenuDef("Knowledge Base", link: "/page/knowledge-base", icon: "bx bx-book-open", weight: 21),
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-06-26 23:08:24 +00:00
|
|
|
}
|