2024-05-27 01:09:18 +00:00
|
|
|
using BotSharp.Abstraction.Google.Settings;
|
2024-01-15 19:15:18 +00:00
|
|
|
using BotSharp.Abstraction.Instructs;
|
|
|
|
|
using BotSharp.Abstraction.Messaging;
|
2024-01-15 21:35:01 +00:00
|
|
|
using BotSharp.Abstraction.Plugins.Models;
|
2024-01-29 18:08:49 +00:00
|
|
|
using BotSharp.Abstraction.Routing.Planning;
|
2024-01-15 19:15:18 +00:00
|
|
|
using BotSharp.Abstraction.Settings;
|
|
|
|
|
using BotSharp.Abstraction.Templating;
|
|
|
|
|
using BotSharp.Core.Instructs;
|
|
|
|
|
using BotSharp.Core.Messaging;
|
2024-01-29 18:08:49 +00:00
|
|
|
using BotSharp.Core.Routing.Planning;
|
2024-01-15 19:15:18 +00:00
|
|
|
using BotSharp.Core.Templating;
|
2024-04-22 19:29:21 +00:00
|
|
|
using BotSharp.Core.Translation;
|
2024-01-15 19:15:18 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Core.Conversations;
|
|
|
|
|
|
|
|
|
|
public class ConversationPlugin : IBotSharpPlugin
|
|
|
|
|
{
|
|
|
|
|
public string Id => "99e9b971-a9f1-4273-84da-876d2873d192";
|
|
|
|
|
public string Name => "Conversation";
|
2024-01-16 19:23:45 +00:00
|
|
|
public string Description => "Provides conversations/ states management, saves dialogue logs, undo dialogs and channel access.";
|
2024-01-15 19:15:18 +00:00
|
|
|
|
|
|
|
|
public SettingsMeta Settings =>
|
|
|
|
|
new SettingsMeta("Conversation");
|
|
|
|
|
public object GetNewSettingsInstance() =>
|
|
|
|
|
new ConversationSetting();
|
|
|
|
|
|
|
|
|
|
public void RegisterDI(IServiceCollection services, IConfiguration config)
|
|
|
|
|
{
|
|
|
|
|
services.AddScoped(provider =>
|
|
|
|
|
{
|
|
|
|
|
var settingService = provider.GetRequiredService<ISettingService>();
|
|
|
|
|
return settingService.Bind<ConversationSetting>("Conversation");
|
|
|
|
|
});
|
|
|
|
|
|
2024-05-27 01:09:18 +00:00
|
|
|
services.AddScoped(provider =>
|
|
|
|
|
{
|
|
|
|
|
var settingService = provider.GetRequiredService<ISettingService>();
|
|
|
|
|
return settingService.Bind<GoogleApiSettings>("GoogleApi");
|
|
|
|
|
});
|
|
|
|
|
|
2024-01-15 19:15:18 +00:00
|
|
|
services.AddScoped<IConversationStorage, ConversationStorage>();
|
|
|
|
|
services.AddScoped<IConversationService, ConversationService>();
|
|
|
|
|
services.AddScoped<IConversationStateService, ConversationStateService>();
|
2024-04-22 19:29:21 +00:00
|
|
|
services.AddScoped<ITranslationService, TranslationService>();
|
2024-01-15 19:15:18 +00:00
|
|
|
|
|
|
|
|
// Rich content messaging
|
|
|
|
|
services.AddScoped<IRichContentService, RichContentService>();
|
|
|
|
|
|
|
|
|
|
// Register template render
|
|
|
|
|
services.AddSingleton<ITemplateRender, TemplateRender>();
|
|
|
|
|
services.AddScoped<IResponseTemplateService, ResponseTemplateService>();
|
|
|
|
|
|
|
|
|
|
services.AddScoped<IExecutor, InstructExecutor>();
|
|
|
|
|
services.AddScoped<IInstructService, InstructService>();
|
|
|
|
|
services.AddScoped<ITokenStatistics, TokenStatistics>();
|
|
|
|
|
}
|
2024-01-15 21:35:01 +00:00
|
|
|
|
|
|
|
|
public bool AttachMenu(List<PluginMenuDef> menu)
|
|
|
|
|
{
|
|
|
|
|
var section = menu.First(x => x.Label == "Apps");
|
2024-01-30 22:20:23 +00:00
|
|
|
menu.Add(new PluginMenuDef("Conversation", link: "page/conversation", icon: "bx bx-conversation", weight: section.Weight + 5));
|
2024-01-15 21:35:01 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2024-01-15 19:15:18 +00:00
|
|
|
}
|