AI-Studio/app/MindWork AI Studio/Chat/ContentBlockComponent.razor
Thorsten Sommer b185463c3e
Switched the solution to fix #28 (and #24)
Instead of using a custom fork of the component, we use the release version. The custom fork causes #24. Now, we did what anyone does: We show the plain Markdown code first and switch to Markdown rendering after streaming is done.

- Removed local custom fork of the library
- Added release version of library
- Show plain Markdown code while streaming
- Switch to Markdown rendering after streaming
2024-05-13 18:42:34 +02:00

69 lines
2.4 KiB
Plaintext

@using MudBlazor
<MudCard Class="my-2 rounded-lg" Outlined="@true">
<MudCardHeader>
<CardHeaderAvatar>
<MudAvatar Color="@this.Role.ToColor()">
<MudIcon Icon="@this.Role.ToIcon()"/>
</MudAvatar>
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.body1">@this.Role.ToName() (@this.Time)</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudIconButton Icon="@Icons.Material.Filled.ContentCopy" Color="Color.Default" OnClick="@this.CopyToClipboard" />
</CardHeaderActions>
</MudCardHeader>
<MudCardContent>
@if (!this.HideContent)
{
if (this.Content.IsStreaming)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="mb-6" />
}
switch (this.Type)
{
case ContentType.TEXT:
if (this.Content is ContentText textContent)
{
if (textContent.InitialRemoteWait)
{
<MudSkeleton Width="30%" Height="42px;"/>
<MudSkeleton Width="80%"/>
<MudSkeleton Width="100%"/>
}
else
{
@if (this.Content.IsStreaming)
{
<MudText Typo="Typo.body1" Style="white-space: pre-wrap;">
@textContent.Text
</MudText>
}
else
{
<MudMarkdown Value="@textContent.Text"/>
}
}
}
break;
case ContentType.IMAGE:
if (this.Content is ContentImage imageContent)
{
<MudImage Src="@imageContent.URL"/>
}
break;
default:
<MudText Typo="Typo.body2">
Cannot render content of type @this.Type yet.
</MudText>
break;
}
}
</MudCardContent>
</MudCard>