From 0bf2fe58fc95cd5246f2f5f33e06f6ed6afd2a3e Mon Sep 17 00:00:00 2001 From: hchen Date: Thu, 16 Nov 2023 12:20:43 -0600 Subject: [PATCH] Fix ExecuteOnce fetch dialogs. --- .../BotSharp.Abstraction/Routing/IRoutingService.cs | 7 +++++++ src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs | 4 +++- tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs index 5a280172..da074555 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs @@ -12,5 +12,12 @@ public interface IRoutingService void ResetRecursiveCounter(); Task InvokeAgent(string agentId, List dialogs); Task InstructLoop(RoleDialogModel message); + + /// + /// Talk to a specific Agent directly, bypassing the Router + /// + /// + /// + /// Task ExecuteOnce(Agent agent, RoleDialogModel message); } diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs index 1ce7cfb7..41845eda 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs @@ -36,7 +36,9 @@ public partial class RoutingService : IRoutingService var handlers = _services.GetServices(); var handler = handlers.FirstOrDefault(x => x.Name == "route_to_agent"); - var dialogs = new List { message }; + + var conv = _services.GetRequiredService(); + var dialogs = conv.GetDialogHistory(); handler.SetDialogs(dialogs); var inst = new FunctionCallFromLlm diff --git a/tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs b/tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs index 3ee956d8..e1a1d61a 100644 --- a/tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs +++ b/tests/BotSharp.Plugin.PizzaBot/PizzaBotPlugin.cs @@ -6,6 +6,8 @@ namespace BotSharp.Plugin.PizzaBot; public class PizzaBotPlugin : IBotSharpPlugin { public string Name => "Pizza AI Assistant"; + public string Description => "An example of an enterprise-grade AI Chatbot."; + public void RegisterDI(IServiceCollection services, IConfiguration config) { // Register hooks