2024-01-03 19:40:41 +00:00
|
|
|
using BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Plugin.WebDriver.Functions;
|
|
|
|
|
|
|
|
|
|
public class InputUserTextFn : IFunctionCallback
|
|
|
|
|
{
|
|
|
|
|
public string Name => "input_user_text";
|
|
|
|
|
|
|
|
|
|
private readonly IServiceProvider _services;
|
|
|
|
|
private readonly PlaywrightWebDriver _driver;
|
|
|
|
|
|
|
|
|
|
public InputUserTextFn(IServiceProvider services,
|
|
|
|
|
PlaywrightWebDriver driver)
|
|
|
|
|
{
|
|
|
|
|
_services = services;
|
|
|
|
|
_driver = driver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<bool> Execute(RoleDialogModel message)
|
|
|
|
|
{
|
|
|
|
|
var args = JsonSerializer.Deserialize<BrowsingContextIn>(message.FunctionArgs);
|
|
|
|
|
|
|
|
|
|
var agentService = _services.GetRequiredService<IAgentService>();
|
|
|
|
|
var agent = await agentService.LoadAgent(message.CurrentAgentId);
|
|
|
|
|
await _driver.InputUserText(agent, args, message.MessageId);
|
|
|
|
|
|
2024-01-23 23:14:57 +00:00
|
|
|
message.Content = $"Input text \"{args.InputText}\" successfully.";
|
2024-01-26 22:23:10 +00:00
|
|
|
|
2024-01-03 19:40:41 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|