Update ChatTemplateDialog to handle text and image content types

This commit is contained in:
Thorsten Sommer 2025-05-24 18:21:05 +02:00
parent b36679d90a
commit 9c5647176d
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -81,7 +81,24 @@
<MudTh>@T("Actions")</MudTh> <MudTh>@T("Actions")</MudTh>
</HeaderContent> </HeaderContent>
<RowTemplate> <RowTemplate>
@(context.Content is ContentText textContent ? textContent.Text : context.Content?.ToString()) <MudTd>
@context.Role.ToChatTemplateName()
</MudTd>
<MudTd>
@switch(context.Content)
{
case ContentText textContent:
<MudTextField AutoGrow="true" Value="@textContent.Text" Placeholder="@T("Enter a message")" ReadOnly="true" Variant="Variant.Text" Validation="@this.ValidateExampleTextMessage"/>
break;
case ContentImage { SourceType: ContentImageSource.URL or ContentImageSource.LOCAL_PATH } imageContent:
<MudImage Src="@imageContent.Source" Alt="@T("Image content")" Fluid="true" />
break;
default:
@T("Unsupported content type")
break;
}
</MudTd> </MudTd>
<MudTd style="text-align: center"> <MudTd style="text-align: center">
<MudIconButton Color="Color.Primary" Icon="@Icons.Material.Filled.Add" OnClick="@(() => AddNewMessageBelow(context))" /> <MudIconButton Color="Color.Primary" Icon="@Icons.Material.Filled.Add" OnClick="@(() => AddNewMessageBelow(context))" />