diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs
index a5369af9..b20da8de 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs
@@ -40,4 +40,6 @@ public interface IRoutingService
///
///
Task InstructDirect(Agent agent, RoleDialogModel message);
+
+ Task GetConversationContent(List dialogs, int maxDialogCount = 50);
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/Models/DecomposedStep.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/Models/DecomposedStep.cs
index d49f6f7d..ab65a23e 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Routing/Models/DecomposedStep.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Routing/Models/DecomposedStep.cs
@@ -6,4 +6,7 @@ public class DecomposedStep
[JsonPropertyName("total_remaining_steps")]
public int TotalRemainingSteps { get; set; }
+
+ [JsonPropertyName("stop_reason")]
+ public string? StopReason { get; set; }
}
diff --git a/src/Infrastructure/BotSharp.Core/Routing/Planning/SequentialPlanner.cs b/src/Infrastructure/BotSharp.Core/Routing/Planning/SequentialPlanner.cs
index 45480ede..7d4291ee 100644
--- a/src/Infrastructure/BotSharp.Core/Routing/Planning/SequentialPlanner.cs
+++ b/src/Infrastructure/BotSharp.Core/Routing/Planning/SequentialPlanner.cs
@@ -33,6 +33,18 @@ public class SequentialPlanner : IPlaner
_lastInst.Reason = $"{decomposation.TotalRemainingSteps} left.";
return _lastInst;
}
+ else if (decomposation.TotalRemainingSteps == 0)
+ {
+ // Tell router all steps are done
+ dialogs.Add(new RoleDialogModel(AgentRole.Assistant, decomposation.StopReason)
+ {
+ CurrentAgentId = router.Id,
+ FunctionName = nameof(SequentialPlanner),
+ MessageId = messageId
+ });
+ router.TemplateDict["conversation"] = router.TemplateDict["conversation"].ToString().TrimEnd() +
+ $"\r\n{router.Name}: {decomposation.StopReason}";
+ }
var next = GetNextStepPrompt(router);
diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.sequential.get_remaining_task.liquid b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.sequential.get_remaining_task.liquid
index 1e3b4fe6..fbeaa09f 100644
--- a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.sequential.get_remaining_task.liquid
+++ b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.sequential.get_remaining_task.liquid
@@ -3,4 +3,4 @@ If a specific step has been exectued, you will get something indicates the resul
If there is no any result provided, it means all the steps have not been executed yet.
You need to figure out which steps have not been completed.
Tell me what is the first remaining step from user steps that have not been completed based on the context.
-Output in JSON { "description": "step detail with arguments", "total_remaining_steps": 0}
\ No newline at end of file
+Output in JSON { "description": "step detail with arguments", "total_remaining_steps": 0, "stop_reason": "the reason why it should total remaining steps is zero"}
\ No newline at end of file
diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.sequential.liquid b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.sequential.liquid
index 1411ca45..d0d3a4ad 100644
--- a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.sequential.liquid
+++ b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/templates/planner_prompt.sequential.liquid
@@ -1,4 +1,2 @@
In order to sequentially execute user tasks,
-What is the next step based on the CONVERSATION?
-Put the next step detail in reason.
-Don't response to user if there is any step that has not been completed.
\ No newline at end of file
+What is the next step based on the CONVERSATION?
\ No newline at end of file
diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/IWebBrowser.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/IWebBrowser.cs
index 2ca10aa3..26b8bde5 100644
--- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/IWebBrowser.cs
+++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/IWebBrowser.cs
@@ -2,7 +2,9 @@ namespace BotSharp.Plugin.WebDriver.Drivers;
public interface IWebBrowser
{
- Agent Agent { get; }
- void SetAgent(Agent agent);
Task LaunchBrowser(string? url);
+ Task InputUserText(Agent agent, BrowsingContextIn context, string messageId);
+ Task InputUserPassword(Agent agent, BrowsingContextIn context, string messageId);
+ Task ClickElement(Agent agent, BrowsingContextIn context, string messageId);
+ Task GoToPage(Agent agent, BrowsingContextIn context, string messageId);
}
diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightInstance.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightInstance.cs
index 0e4ba826..4fc2688b 100644
--- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightInstance.cs
+++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightInstance.cs
@@ -24,8 +24,13 @@ public class PlaywrightInstance : IDisposable
{
Headless = false,
Channel = "chrome",
- Args = new string[]
+ IgnoreDefaultArgs = new[]
{
+ "enable-automation"
+ },
+ Args = new[]
+ {
+ "--disable-infobars"
// "--start-maximized"
}
});
diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.InputUserText.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.InputUserText.cs
index 78b2f317..5de55fa2 100644
--- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.InputUserText.cs
+++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.InputUserText.cs
@@ -12,12 +12,14 @@ public partial class PlaywrightWebDriver
// Find by text exactly match
var elements = _instance.Page.GetByRole(AriaRole.Textbox, new PageGetByRoleOptions
{
- Name = context.ElementName
+ Name = context.ElementText
});
var count = await elements.CountAsync();
-
- elements = _instance.Page.GetByPlaceholder(context.ElementName);
- count = await elements.CountAsync();
+ if (count == 0)
+ {
+ elements = _instance.Page.GetByPlaceholder(context.ElementText);
+ count = await elements.CountAsync();
+ }
if (count == 0)
{
@@ -25,7 +27,7 @@ public partial class PlaywrightWebDriver
var html = await FilteredInputHtml();
var htmlElementContextOut = await driverService.InferElement(agent,
html,
- context.ElementName,
+ context.ElementText,
messageId);
elements = Locator(htmlElementContextOut);
}
diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Functions/InputUserTextFn.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Functions/InputUserTextFn.cs
index 6db61c71..7a87a633 100644
--- a/src/Plugins/BotSharp.Plugin.WebDriver/Functions/InputUserTextFn.cs
+++ b/src/Plugins/BotSharp.Plugin.WebDriver/Functions/InputUserTextFn.cs
@@ -24,7 +24,12 @@ public class InputUserTextFn : IFunctionCallback
var agent = await agentService.LoadAgent(message.CurrentAgentId);
await _driver.InputUserText(agent, args, message.MessageId);
- message.Content = $"Input text \"{args.InputText}\" successfully.";
+ message.Content = $"Input text \"{args.InputText}\"";
+ if (args.PressEnter.HasValue && args.PressEnter.Value)
+ {
+ message.Content += " and pressed Enter";
+ }
+ message.Content += " successfully.\"";
return true;
}
diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b/functions.json b/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b/functions.json
index f40e9daa..d847c3b6 100644
--- a/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b/functions.json
+++ b/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b/functions.json
@@ -71,9 +71,9 @@
"parameters": {
"type": "object",
"properties": {
- "element_name": {
+ "element_text": {
"type": "string",
- "description": "the html input box element name."
+ "description": "text or placeholder shown in the element."
},
"input_text": {
"type": "string",
@@ -84,7 +84,7 @@
"description": "whether to press Enter key"
}
},
- "required": [ "element_name", "input_text" ]
+ "required": [ "element_text", "input_text" ]
}
},
{
@@ -131,7 +131,7 @@
},
"element_text": {
"type": "string",
- "description": "text shown in the element."
+ "description": "text or placeholder shown in the element."
},
"match_rule": {
"type": "string",