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; return chatId;
} }
protected DateTimeOffset AddUserRequest(string request) protected DateTimeOffset AddUserRequest(string request, bool hideContentFromUser = false)
{ {
var time = DateTimeOffset.Now; var time = DateTimeOffset.Now;
this.chatThread!.Blocks.Add(new ContentBlock this.chatThread!.Blocks.Add(new ContentBlock
{ {
Time = time, Time = time,
ContentType = ContentType.TEXT, ContentType = ContentType.TEXT,
HideFromUser = hideContentFromUser,
Role = ChatRole.USER, Role = ChatRole.USER,
Content = new ContentText Content = new ContentText
{ {

View File

@ -18,10 +18,15 @@ public class ContentBlock
/// <summary> /// <summary>
/// The content of the block. /// The content of the block.
/// </summary> /// </summary>
public IContent? Content { get; init; } = null; public IContent? Content { get; init; }
/// <summary> /// <summary>
/// The role of the content block in the chat thread, e.g., user, AI, etc. /// The role of the content block in the chat thread, e.g., user, AI, etc.
/// </summary> /// </summary>
public ChatRole Role { get; init; } = ChatRole.NONE; 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

@ -21,10 +21,13 @@
@if (this.chatThread is not null) @if (this.chatThread is not null)
{ {
foreach (var block in this.chatThread.Blocks.OrderBy(n => n.Time)) foreach (var block in this.chatThread.Blocks.OrderBy(n => n.Time))
{
@if (!block.HideFromUser)
{ {
<ContentBlockComponent Role="@block.Role" Type="@block.ContentType" Time="@block.Time" Content="@block.Content"/> <ContentBlockComponent Role="@block.Role" Type="@block.ContentType" Time="@block.Time" Content="@block.Content"/>
} }
} }
}
</ChildContent> </ChildContent>
<FooterContent> <FooterContent>
<MudElement Style="flex: 0 0 auto;"> <MudElement Style="flex: 0 0 auto;">