Fix router history dialogs.

This commit is contained in:
Haiping Chen 2024-09-04 10:01:40 -05:00
parent 329aa37e5d
commit 4f6fed56d8
3 changed files with 12 additions and 3 deletions

View file

@ -30,7 +30,7 @@ public class RoleDialogModel : ITrackableMessage
public string? SecondaryContent { get; set; }
/// <summary>
/// Postback content
/// Postback of previous round payload
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("payload")]
@ -131,6 +131,7 @@ public class RoleDialogModel : ITrackableMessage
ToolCallId = source.ToolCallId,
PostbackFunctionName = source.PostbackFunctionName,
RichContent = source.RichContent,
Payload = source.Payload,
StopCompletion = source.StopCompletion,
Instruction = source.Instruction,
Data = source.Data,

View file

@ -41,7 +41,7 @@ public partial class ConversationService
routing.Context.SetMessageId(_conversationId, message.MessageId);
routing.Context.Push(agent.Id, reason: "request started");
// Save payload
// Save payload in order to assign the payload before hook is invoked
if (replyMessage != null && !string.IsNullOrEmpty(replyMessage.Payload))
{
message.Payload = replyMessage.Payload;

View file

@ -16,7 +16,15 @@ public partial class RoutingService
role = agent.Name;
}
conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n";
if (role == AgentRole.User)
{
conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n";
}
else
{
// Assistant reply deosn't need help with payload
conversation += $"{role}: {dialog.Content}\r\n";
}
}
return conversation;