From ad606e6710d06b4ae095179dc2554021c3f4f6f1 Mon Sep 17 00:00:00 2001 From: hchen Date: Wed, 8 Nov 2023 16:47:23 -0600 Subject: [PATCH] Fix rich content text in InstructExecutor. --- .../Services/ConversationService.SendMessage.cs | 8 ++++++++ .../BotSharp.Core/Planning/InstructExecutor.cs | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs index 2e087cf2..f67307c4 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs @@ -101,6 +101,14 @@ public partial class ConversationService _logger.LogInformation(text); #endif + // Process rich content + if (response.RichContent != null && + response.RichContent is RichContent template && + string.IsNullOrEmpty(template.Message.Text)) + { + template.Message.Text = response.Content; + } + // Only read content from RichContent for UI rendering. When richContent is null, create a basic text message for richContent. var state = _services.GetRequiredService(); response.RichContent = response.RichContent ?? new RichContent diff --git a/src/Infrastructure/BotSharp.Core/Planning/InstructExecutor.cs b/src/Infrastructure/BotSharp.Core/Planning/InstructExecutor.cs index 47d6ccce..0d02cd95 100644 --- a/src/Infrastructure/BotSharp.Core/Planning/InstructExecutor.cs +++ b/src/Infrastructure/BotSharp.Core/Planning/InstructExecutor.cs @@ -1,6 +1,4 @@ using BotSharp.Abstraction.Functions.Models; -using BotSharp.Abstraction.Messaging.Models; -using BotSharp.Abstraction.Messaging.Models.RichContent; using BotSharp.Abstraction.Planning; using BotSharp.Abstraction.Routing; @@ -35,14 +33,6 @@ public class InstructExecutor : IExecutor response.MessageId = message.MessageId; response.Instruction = inst; - // Process rich content - if (response.RichContent != null && - response.RichContent is RichContent template && - string.IsNullOrEmpty(template.Message.Text)) - { - template.Message.Text = response.Content; - } - return response; } }