Skip to content

Commit cbd76c4

Browse files
authored
Merge pull request #202 from hchen2020/master
Fix rich content text in InstructExecutor.
2 parents c20cdd1 + 5add9ee commit cbd76c4

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ private async Task HandleAssistantMessage(RoleDialogModel response, Func<RoleDia
101101
_logger.LogInformation(text);
102102
#endif
103103

104+
// Process rich content
105+
if (response.RichContent != null &&
106+
response.RichContent is RichContent<IMessageTemplate> template &&
107+
string.IsNullOrEmpty(template.Message.Text))
108+
{
109+
template.Message.Text = response.Content;
110+
}
111+
104112
// Only read content from RichContent for UI rendering. When richContent is null, create a basic text message for richContent.
105113
var state = _services.GetRequiredService<IConversationStateService>();
106114
response.RichContent = response.RichContent ?? new RichContent<IMessageTemplate>

src/Infrastructure/BotSharp.Core/Planning/InstructExecutor.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using BotSharp.Abstraction.Functions.Models;
2-
using BotSharp.Abstraction.Messaging.Models;
3-
using BotSharp.Abstraction.Messaging.Models.RichContent;
42
using BotSharp.Abstraction.Planning;
53
using BotSharp.Abstraction.Routing;
64

@@ -35,14 +33,6 @@ public async Task<RoleDialogModel> Execute(IRoutingService routing,
3533
response.MessageId = message.MessageId;
3634
response.Instruction = inst;
3735

38-
// Process rich content
39-
if (response.RichContent != null &&
40-
response.RichContent is RichContent<IMessageTemplate> template &&
41-
string.IsNullOrEmpty(template.Message.Text))
42-
{
43-
template.Message.Text = response.Content;
44-
}
45-
4636
return response;
4737
}
4838
}

0 commit comments

Comments
 (0)