Merge pull request #363 from hchen2020/master

Delay persisting message to allow message content to be changed in hook.
This commit is contained in:
C. Oceania 2024-03-26 11:11:13 -05:00 committed by GitHub
commit 71eeb01b50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,8 +32,6 @@ public partial class ConversationService
message.SenderId = _user.Id; message.SenderId = _user.Id;
} }
_storage.Append(_conversationId, message);
var conv = _services.GetRequiredService<IConversationService>(); var conv = _services.GetRequiredService<IConversationService>();
var dialogs = conv.GetDialogHistory(); var dialogs = conv.GetDialogHistory();
@ -72,6 +70,12 @@ public partial class ConversationService
} }
} }
// Persist to storage
_storage.Append(_conversationId, message);
// Add to thread
dialogs.Add(message);
if (!stopCompletion) if (!stopCompletion)
{ {
// Routing with reasoning // Routing with reasoning