Merge pull request #202 from hchen2020/master

Fix rich content text in InstructExecutor.
This commit is contained in:
Haiping 2023-11-08 16:50:53 -06:00 committed by GitHub
commit cbd76c4e8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View file

@ -101,6 +101,14 @@ public partial class ConversationService
_logger.LogInformation(text);
#endif
// Process rich content
if (response.RichContent != null &&
response.RichContent is RichContent<IMessageTemplate> 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<IConversationStateService>();
response.RichContent = response.RichContent ?? new RichContent<IMessageTemplate>

View file

@ -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<IMessageTemplate> template &&
string.IsNullOrEmpty(template.Message.Text))
{
template.Message.Text = response.Content;
}
return response;
}
}