forked from SciSharp/BotSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebDriverPlugin.cs
More file actions
39 lines (32 loc) · 1.56 KB
/
WebDriverPlugin.cs
File metadata and controls
39 lines (32 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using BotSharp.Abstraction.Browsing.Settings;
using BotSharp.Abstraction.Settings;
using BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
using BotSharp.Plugin.WebDriver.Hooks;
namespace BotSharp.Plugin.Playwrights;
public class WebDriverPlugin : IBotSharpPlugin
{
public string Id => "f0e26bc3-cfde-4b63-845c-c9c542abea44";
public string Name => "Web Driver";
public string Description => "Empower agent to manipulate web browser in automation tools.";
public string IconUrl => "https://cdn-icons-png.flaticon.com/512/8576/8576378.png";
public string[] AgentIds => ["f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b"];
public void RegisterDI(IServiceCollection services, IConfiguration config)
{
var settings = new WebBrowsingSettings();
config.Bind("WebBrowsing", settings);
services.AddSingleton(x => settings);
services.AddScoped<PlaywrightWebDriver>();
services.AddSingleton<PlaywrightInstance>();
// services.AddScoped<SeleniumWebDriver>();
// services.AddSingleton<SeleniumInstance>();
services.AddScoped<IWebBrowser>(provider => settings.Driver switch
{
"Playwright" => provider.GetRequiredService<PlaywrightWebDriver>(),
// "Selenium" => provider.GetRequiredService<SeleniumWebDriver>(),
_ => provider.GetRequiredService<PlaywrightWebDriver>(),
});
services.AddScoped<WebDriverService>();
services.AddScoped<IConversationHook, WebDriverConversationHook>();
services.AddScoped<IAgentUtilityHook, WebUtilityHook>();
}
}