diff --git a/Directory.Packages.props b/Directory.Packages.props
index 4683fc9d..aa76cf61 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -54,7 +54,7 @@
-
+
diff --git a/src/Infrastructure/BotSharp.Abstraction/Browsing/Settings/WebBrowsingSettings.cs b/src/Infrastructure/BotSharp.Abstraction/Browsing/Settings/WebBrowsingSettings.cs
index e1ae9a79..9565e217 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Browsing/Settings/WebBrowsingSettings.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Browsing/Settings/WebBrowsingSettings.cs
@@ -4,4 +4,6 @@ public class WebBrowsingSettings
{
public string Driver { get; set; } = "Playwright";
public bool Headless { get; set; }
+ // Default timeout in milliseconds
+ public float DefaultTimeout { get; set; } = 30000;
}
diff --git a/src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs b/src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs
index 68636bd1..e8548c4d 100644
--- a/src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs
+++ b/src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs
@@ -233,7 +233,8 @@ public class RealtimeHub : IRealtimeHub
}
await _completer.InsertConversationItem(message);
- await _completer.TriggerModelInference("Reply based on the user input");
+ var instruction = await _completer.UpdateSession(_conn);
+ await _completer.TriggerModelInference($"{instruction}\r\n\r\nReply based on the user input: {message.Content}");
}
private async Task HandleUserDisconnected()
diff --git a/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAIChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAIChatCompletionProvider.cs
index 37d3877c..6ee77772 100644
--- a/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAIChatCompletionProvider.cs
+++ b/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAIChatCompletionProvider.cs
@@ -27,7 +27,6 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
private readonly IChatClient _client;
private readonly ILogger _logger;
private readonly IServiceProvider _services;
- private List renderedInstructions = [];
private string? _model;
///
@@ -46,7 +45,7 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
///
public string Provider => "microsoft.extensions.ai";
- public string Model => _model;
+ public string Model => _model ?? "";
///
public void SetModelName(string model) => _model = model;
@@ -56,7 +55,7 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
{
// Before chat completion hook
var hooks = _services.GetServices().ToArray();
- renderedInstructions = [];
+ List renderedInstructions = [];
await Task.WhenAll(hooks.Select(hook => hook.BeforeGenerating(agent, conversations)));
// Configure options
@@ -145,13 +144,13 @@ public sealed class MicrosoftExtensionsAIChatCompletionProvider : IChatCompletio
var completion = await _client.GetResponseAsync(messages);
- RoleDialogModel result = new(AgentRole.Assistant, string.Concat(completion.Message.Contents.OfType()))
+ RoleDialogModel result = new(AgentRole.Assistant, completion.Text)
{
CurrentAgentId = agent.Id,
- RenderedInstruction = string.Join("\r\n", renderedInstructions)
+ //RenderedInstruction = renderedInstructions,
};
- if (completion.Message.Contents.OfType().FirstOrDefault() is { } fcc)
+ if (completion.Messages.SelectMany(m => m.Contents).OfType().FirstOrDefault() is { } fcc)
{
result.Role = AgentRole.Function;
result.MessageId = conversations.LastOrDefault()?.MessageId ?? string.Empty;
diff --git a/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAITextCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAITextCompletionProvider.cs
index ed0e94d9..ef3b35c7 100644
--- a/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAITextCompletionProvider.cs
+++ b/src/Plugins/BotSharp.Plugin.MicrosoftExtensionsAI/MicrosoftExtensionsAITextCompletionProvider.cs
@@ -51,7 +51,7 @@ public sealed class MicrosoftExtensionsAITextCompletionProvider : ITextCompletio
_tokenStatistics.StartTimer();
var completion = await _chatClient.GetResponseAsync(text);
- var result = string.Concat(completion.Message.Contents.OfType());
+ var result = completion.Text;
_tokenStatistics.StopTimer();
// After chat completion hook
diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Functions/GoToPageFn.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Functions/GoToPageFn.cs
index e1041ae6..fe69f9d1 100644
--- a/src/Plugins/BotSharp.Plugin.WebDriver/Functions/GoToPageFn.cs
+++ b/src/Plugins/BotSharp.Plugin.WebDriver/Functions/GoToPageFn.cs
@@ -1,3 +1,5 @@
+using BotSharp.Abstraction.Browsing.Settings;
+
namespace BotSharp.Plugin.WebDriver.Functions;
public class GoToPageFn : IFunctionCallback
@@ -25,7 +27,7 @@ public class GoToPageFn : IFunctionCallback
var url = webDriverService.ReplaceToken(args.Url);
url = url.Replace("https://https://", "https://");
-
+ var _webDriver = _services.GetRequiredService();
var result = await _browser.GoToPage(new MessageInfo
{
AgentId = message.CurrentAgentId,
@@ -33,7 +35,8 @@ public class GoToPageFn : IFunctionCallback
MessageId = message.MessageId
}, new PageActionArgs
{
- Url = url
+ Url = url,
+ Timeout = _webDriver.DefaultTimeout
});
message.Content = result.IsSuccess ? $"Page {url} is open." : $"Page {url} open failed. {result.Message}";
diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Functions/OpenBrowserFn.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Functions/OpenBrowserFn.cs
index 92935233..0beb80fc 100644
--- a/src/Plugins/BotSharp.Plugin.WebDriver/Functions/OpenBrowserFn.cs
+++ b/src/Plugins/BotSharp.Plugin.WebDriver/Functions/OpenBrowserFn.cs
@@ -26,7 +26,7 @@ public class OpenBrowserFn : IFunctionCallback
var webDriverService = _services.GetRequiredService();
var url = webDriverService.ReplaceToken(args.Url);
-
+ var _webDriver = _services.GetRequiredService();
url = url.Replace("https://https://", "https://");
var msgInfo = new MessageInfo
{
@@ -40,7 +40,8 @@ public class OpenBrowserFn : IFunctionCallback
});
result = await _browser.GoToPage(msgInfo, new PageActionArgs
{
- Url = url
+ Url = url,
+ Timeout = _webDriver.DefaultTimeout
});
if (result.IsSuccess)
diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebGoToPageFn.cs b/src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebGoToPageFn.cs
index 675e1ec8..a29af212 100644
--- a/src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebGoToPageFn.cs
+++ b/src/Plugins/BotSharp.Plugin.WebDriver/UtilFunctions/UtilWebGoToPageFn.cs
@@ -1,3 +1,5 @@
+using BotSharp.Abstraction.Browsing.Settings;
+
namespace BotSharp.Plugin.WebDriver.UtilFunctions;
public class UtilWebGoToPageFn : IFunctionCallback
@@ -21,6 +23,8 @@ public class UtilWebGoToPageFn : IFunctionCallback
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});
+ var _webDriver = _services.GetRequiredService();
+ args.Timeout = _webDriver.DefaultTimeout;
args.WaitForNetworkIdle = false;
args.WaitTime = 5;
args.OpenNewTab = true;