diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs index 6a134cef..cb04e55e 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs @@ -16,7 +16,8 @@ public class Agent /// Default LLM settings /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public AgentLlmConfig? LlmConfig { get; set; } + public AgentLlmConfig LlmConfig { get; set; } + = new AgentLlmConfig(); /// /// Instruction diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs index e902efc5..8025c2b8 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentLlmConfig.cs @@ -21,4 +21,7 @@ public class AgentLlmConfig [JsonPropertyName("model")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? Model { get; set; } + + [JsonPropertyName("max_recursion_depth")] + public int MaxRecursionDepth { get; set; } = 3; } diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs index 78b339fa..ccdee8d5 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs @@ -1,5 +1,3 @@ -using BotSharp.Abstraction.Agents.Models; -using BotSharp.Abstraction.MLTasks.Settings; using BotSharp.Abstraction.Routing.Models; using BotSharp.Abstraction.Templating; @@ -7,20 +5,19 @@ namespace BotSharp.Core.Routing; public partial class RoutingService { - const int MAXIMUM_RECURSION_DEPTH = 3; private int _currentRecursionDepth = 0; public async Task InvokeAgent(string agentId, List dialogs) { - _currentRecursionDepth++; - if (_currentRecursionDepth > MAXIMUM_RECURSION_DEPTH) - { - _logger.LogWarning($"Current recursive call depth greater than {MAXIMUM_RECURSION_DEPTH}, which will cause unexpected result."); - return false; - } - var agentService = _services.GetRequiredService(); var agent = await agentService.LoadAgent(agentId); + _currentRecursionDepth++; + if (_currentRecursionDepth > agent.LlmConfig.MaxRecursionDepth) + { + _logger.LogWarning($"Current recursive call depth greater than {agent.LlmConfig.MaxRecursionDepth}, which will cause unexpected result."); + return false; + } + var chatCompletion = CompletionProvider.GetChatCompletion(_services, agentConfig: agent.LlmConfig); diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ChangeListValue.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ChangeListValue.cs index f3a453ad..d3cb5c7d 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ChangeListValue.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.ChangeListValue.cs @@ -96,9 +96,20 @@ public partial class PlaywrightWebDriver { Label = context.UpdateValue }); - + // Click on the blank area to activate posting - await body.ClickAsync(); + // await body.ClickAsync(); + if (!isVisible) + { + // Select the element you want to make visible (replace with your own selector) + var control = await _instance.Page.QuerySelectorAsync($"#{htmlElementContextOut.ElementId}"); + + // Show the element by modifying its CSS styles + await _instance.Page.EvaluateAsync(@"(element) => { + element.style.display = 'none'; + element.style.visibility = 'hidden'; + }", control); + } } catch (Exception ex) { diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b/agent.json b/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b/agent.json index 5a12078d..34890f9d 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b/agent.json +++ b/src/Plugins/BotSharp.Plugin.WebDriver/data/agents/f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b/agent.json @@ -5,5 +5,8 @@ "updatedDateTime": "2024-01-02T00:00:00Z", "id": "f3ae2a0f-e6ba-4ee1-a0b9-75d7431ff32b", "allowRouting": true, - "isPublic": true + "isPublic": true, + "llmConfig": { + "max_recursion_depth": 10 + } } \ No newline at end of file