add show_current_url = true

This commit is contained in:
Wenbo Cao 2025-04-01 12:29:39 -05:00
parent 0164cc5bb6
commit 2a322f694c
3 changed files with 23 additions and 7 deletions

View file

@ -35,6 +35,12 @@ public class ElementActionArgs
/// </summary>
public int WaitTime { get; set; }
/// <summary>
/// Add current url to the content
/// </summary>
[JsonPropertyName("show_current_url")]
public bool ShowCurrentUrl { get; set; } = false;
/// <summary>
/// Required for deserialization
/// </summary>

View file

@ -31,7 +31,7 @@ public class UtilWebActionOnElementFn : IFunctionCallback
}
actionArgs.WaitTime = 2;
var conv = _services.GetRequiredService<IConversationService>();
var services = _services.CreateScope().ServiceProvider;
@ -45,7 +45,13 @@ public class UtilWebActionOnElementFn : IFunctionCallback
};
var result = await browser.ActionOnElement(msg, locatorArgs, actionArgs);
message.Content = $"{actionArgs.Action} executed {(result.IsSuccess ? "success" : "failed")}. Current page url: '{result.UrlAfterAction}'.";
message.Content = $"{actionArgs.Action} executed {(result.IsSuccess ? "success" : "failed")}.";
// Add Current Url info to the message
if (actionArgs.ShowCurrentUrl)
{
message.Content += $" Current page url: '{result.UrlAfterAction}'.";
}
var path = webDriverService.GetScreenshotFilePath(message.MessageId);

View file

@ -16,16 +16,20 @@
"content": {
"type": "string",
"description": "content to input in element"
},
"file_urls": {
},
"file_urls": {
"type": "array",
"description": "The output format must be string array of file urls.",
"items": {
"type": "string",
"description": "file url"
"type": "string",
"description": "file url"
}
},
"show_current_url": {
"type": "boolean",
"description": "check if need to extract the current url"
},
"press_key": {
"press_key": {
"type": "string",
"enum": [ "Enter" ],
"description": "press key after input text"