Allow us to hide some messages from the user

This commit is contained in:
Thorsten Sommer 2024-10-27 21:00:18 +01:00
parent 64d8a0fd5f
commit 0c19146f05
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 12 additions and 3 deletions

View File

@ -201,13 +201,14 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
return chatId;
}
protected DateTimeOffset AddUserRequest(string request)
protected DateTimeOffset AddUserRequest(string request, bool hideContentFromUser = false)
{
var time = DateTimeOffset.Now;
this.chatThread!.Blocks.Add(new ContentBlock
{
Time = time,
ContentType = ContentType.TEXT,
HideFromUser = hideContentFromUser,
Role = ChatRole.USER,
Content = new ContentText
{

View File

@ -18,10 +18,15 @@ public class ContentBlock
/// <summary>
/// The content of the block.
/// </summary>
public IContent? Content { get; init; } = null;
public IContent? Content { get; init; }
/// <summary>
/// The role of the content block in the chat thread, e.g., user, AI, etc.
/// </summary>
public ChatRole Role { get; init; } = ChatRole.NONE;
/// <summary>
/// Should the content block be hidden from the user?
/// </summary>
public bool HideFromUser { get; set; }
}

View File

@ -22,7 +22,10 @@
{
foreach (var block in this.chatThread.Blocks.OrderBy(n => n.Time))
{
<ContentBlockComponent Role="@block.Role" Type="@block.ContentType" Time="@block.Time" Content="@block.Content"/>
@if (!block.HideFromUser)
{
<ContentBlockComponent Role="@block.Role" Type="@block.ContentType" Time="@block.Time" Content="@block.Content"/>
}
}
}
</ChildContent>