From d7ef99d034c055f16f1a6fa84cc2c0768b3895e8 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Wed, 25 Oct 2023 19:30:23 -0500 Subject: [PATCH] Render assistant role as specific agent name. --- .../Routing/RoutingService.GetNextInstruction.cs | 11 ++++++++++- .../instruction.liquid | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetNextInstruction.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetNextInstruction.cs index c08230ad..9cf2726a 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetNextInstruction.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetNextInstruction.cs @@ -56,15 +56,24 @@ public partial class RoutingService model: _settings.Model); int retryCount = 0; + var agentService = _services.GetRequiredService(); while (retryCount < 3) { try { var conversation = ""; + foreach (var dialog in _dialogs.TakeLast(20)) { - conversation += $"{dialog.Role}: {dialog.Content}\r\n"; + var role = dialog.Role; + if (role != AgentRole.User) + { + var agent = await agentService.GetAgent(dialog.CurrentAgentId); + role = agent.Name; + } + + conversation += $"{role}: {dialog.Content}\r\n"; } content = $"{conversation}\r\n###\r\n{content}"; diff --git a/src/WebStarter/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instruction.liquid b/src/WebStarter/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instruction.liquid index 1543518d..a6d15308 100644 --- a/src/WebStarter/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instruction.liquid +++ b/src/WebStarter/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/instruction.liquid @@ -3,7 +3,7 @@ You're {{router.name}} ({{router.description}}). Follow these steps to handle us 2. Select a appropriate function from [FUNCTIONS]. 3. Determine which agent is suitable to handle this conversation. 4. Re-think about the selected function or agent is the best choice. -5. For agent required arguments, leave it blank if user doesn't provide it. +5. For agent required arguments, leave it as blank object if user doesn't provide it. [FUNCTIONS] {% for handler in routing_handlers %}