Only show playload to AI.

This commit is contained in:
Haiping Chen 2024-05-07 17:16:07 -05:00
parent da371df9d9
commit 6554c43dbc
6 changed files with 10 additions and 4 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -123,7 +123,7 @@ public class ChatCompletionProvider : IChatCompletion
{ {
if (conv.Role == AgentRole.User) 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) else if (conv.Role == AgentRole.Assistant)
{ {

View file

@ -278,7 +278,7 @@ public class ChatCompletionProvider : IChatCompletion
} }
else if (message.Role == ChatRole.User) 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 // To display Planner name in log
Name = message.FunctionName, Name = message.FunctionName,