From 553fe3e4c77b76427d0941454a9c54def666cfa0 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Fri, 17 Nov 2023 17:36:15 -0600 Subject: [PATCH] Add function result to history. --- .../Conversations/Services/ConversationStorage.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStorage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStorage.cs index 2912979d..5ebe95ba 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStorage.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStorage.cs @@ -26,7 +26,7 @@ public class ConversationStorage : IConversationStorage { // var args = dialog.FunctionArgs.RemoveNewLine(); - sb.AppendLine($"{dialog.CreatedAt}|{dialog.Role}|{agentId}|{dialog.MessageId}|{agentId}"); + sb.AppendLine($"{dialog.CreatedAt}|{dialog.Role}|{agentId}|{dialog.MessageId}|{dialog.FunctionName}"); var content = dialog.Content; content = content.RemoveNewLine(); @@ -67,7 +67,8 @@ public class ConversationStorage : IConversationStorage var role = blocks[1]; var currentAgentId = blocks[2]; var messageId = blocks[3]; - var senderId = blocks[4]; + var senderId = role == AgentRole.Function ? currentAgentId : blocks[4]; + var function = role == AgentRole.Function ? blocks[4] : null; var text = dialog.Substring(4); results.Add(new RoleDialogModel(role, text) @@ -77,6 +78,7 @@ public class ConversationStorage : IConversationStorage Content = text, CreatedAt = createdAt, SenderId = senderId, + FunctionName = function }); } return results;