Merge pull request #441 from hchen2020/master

Only show playload to AI.
This commit is contained in:
C. Oceania 2024-05-07 17:17:07 -05:00 committed by GitHub
commit d8c2e1dced
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 10 additions and 4 deletions

View file

@ -28,6 +28,9 @@ public class RoleDialogModel : ITrackableMessage
public string? SecondaryContent { get; set; }
/// <summary>
/// Postback content
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("payload")]
public string? Payload { get; set; }

View file

@ -51,6 +51,9 @@ public partial class ConversationService
fileService.SaveMessageFiles(_conversationId, message.MessageId, message.Files);
message.Files?.Clear();
// Save payload
message.Payload = string.IsNullOrEmpty(replyMessage.Payload) ? message.Content : replyMessage.Payload;
// Before chat completion hook
foreach (var hook in hooks)
{

View file

@ -104,7 +104,7 @@ public class ConversationStorage : IConversationStorage
var meta = dialog.MetaData;
var content = dialog.Content;
var secondaryContent = dialog.SecondaryContent;
var payload = dialog.Payload;
var payload = string.IsNullOrEmpty(dialog.Payload) ? null : dialog.Payload;
var role = meta.Role;
var currentAgentId = meta.AgentId;
var messageId = meta.MessageId;

View file

@ -16,7 +16,7 @@ public partial class RoutingService
role = agent.Name;
}
conversation += $"{role}: {dialog.SecondaryContent ?? dialog.Content}\r\n";
conversation += $"{role}: {dialog.Payload ?? dialog.SecondaryContent ?? dialog.Content}\r\n";
}
return conversation;

View file

@ -123,7 +123,7 @@ public class ChatCompletionProvider : IChatCompletion
{
if (conv.Role == AgentRole.User)
{
messages.Add(new Message(RoleType.User, conv.Content));
messages.Add(new Message(RoleType.User, conv.Payload ?? conv.Content));
}
else if (conv.Role == AgentRole.Assistant)
{

View file

@ -278,7 +278,7 @@ public class ChatCompletionProvider : IChatCompletion
}
else if (message.Role == ChatRole.User)
{
var userMessage = new ChatRequestUserMessage(message.Content)
var userMessage = new ChatRequestUserMessage(message.Payload ?? message.Content)
{
// To display Planner name in log
Name = message.FunctionName,