There was a bug when updating a chat template. The AllowProfiles bool was not given, so the default true was always used.

This commit is contained in:
Peer Schütt 2025-05-23 16:46:27 +02:00
parent a5b11f2305
commit a06051ac6d
4 changed files with 9 additions and 7 deletions

View File

@ -91,7 +91,6 @@ public sealed record ChatThread
/// <returns>The prepared system prompt.</returns> /// <returns>The prepared system prompt.</returns>
public string PrepareSystemPrompt(SettingsManager settingsManager, ChatThread chatThread, ILogger logger) public string PrepareSystemPrompt(SettingsManager settingsManager, ChatThread chatThread, ILogger logger)
{ {
// //
// Use the information from the chat template, if provided. Otherwise, use the default system prompt // Use the information from the chat template, if provided. Otherwise, use the default system prompt
// //

View File

@ -38,6 +38,7 @@ public partial class SettingsPanelChatTemplates : SettingsPanelBase
{ x => x.DataSystemPrompt, chatTemplate.SystemPrompt }, { x => x.DataSystemPrompt, chatTemplate.SystemPrompt },
{ x => x.IsEditing, true }, { x => x.IsEditing, true },
{x => x.ExampleConversation, chatTemplate.ExampleConversation}, {x => x.ExampleConversation, chatTemplate.ExampleConversation},
{x => x.AllowProfileUsage, chatTemplate.AllowProfileUsage},
}; };
var dialogReference = await this.DialogService.ShowAsync<ChatTemplateDialog>(T("Edit Chat Template"), dialogParameters, DialogOptions.FULLSCREEN); var dialogReference = await this.DialogService.ShowAsync<ChatTemplateDialog>(T("Edit Chat Template"), dialogParameters, DialogOptions.FULLSCREEN);

View File

@ -55,7 +55,7 @@
</MudTooltip> </MudTooltip>
<MudTooltip Text="@T("Using some chat templates in tandem with profiles might cause issues. Therefore, you can preliminarily block the usage of profiles here.")"> <MudTooltip Text="@T("Using some chat templates in tandem with profiles might cause issues. Therefore, you can preliminarily block the usage of profiles here.")">
<MudSwitch @bind-Value="allowProfileUsage" Class="mb-3" Color="Color.Primary" Label="@T("Allow the use of profiles together with this chat template?")" ThumbIcon="@Icons.Material.Filled.Person4" ThumbIconColor="Color.Default" /> <MudSwitch @bind-Value="@this.AllowProfileUsage" Class="mb-3" Color="Color.Primary" Label="@T("Allow the use of profiles together with this chat template?")" ThumbIcon="@Icons.Material.Filled.Person4" ThumbIconColor="Color.Default" />
</MudTooltip> </MudTooltip>
<MudText Typo="Typo.h6" Class="mb-3"> <MudText Typo="Typo.h6" Class="mb-3">

View File

@ -44,6 +44,9 @@ public partial class ChatTemplateDialog : MSGComponentBase
[Parameter] [Parameter]
public List<ContentBlock> ExampleConversation { get; set; } = []; public List<ContentBlock> ExampleConversation { get; set; } = [];
[Parameter]
public bool AllowProfileUsage { get; set; } = true;
[Inject] [Inject]
private ILogger<ProviderDialog> Logger { get; init; } = null!; private ILogger<ProviderDialog> Logger { get; init; } = null!;
@ -59,10 +62,7 @@ public partial class ChatTemplateDialog : MSGComponentBase
private string dataEditingPreviousName = string.Empty; private string dataEditingPreviousName = string.Empty;
private ContentBlock messageEntryBeforeEdit; private ContentBlock messageEntryBeforeEdit;
// private readonly List<ContentBlock> additionalMessagesEntries = [];
// private readonly List<string> availableRoles = ["User", "Assistant"];
private readonly IEnumerable<ChatRole> availableRoles = ChatRoles.ChatTemplateRoles().ToArray(); private readonly IEnumerable<ChatRole> availableRoles = ChatRoles.ChatTemplateRoles().ToArray();
private bool allowProfileUsage = true;
// We get the form reference from Blazor code to validate it manually: // We get the form reference from Blazor code to validate it manually:
private MudForm form = null!; private MudForm form = null!;
@ -75,7 +75,7 @@ public partial class ChatTemplateDialog : MSGComponentBase
Name = this.DataName, Name = this.DataName,
SystemPrompt = this.DataSystemPrompt, SystemPrompt = this.DataSystemPrompt,
ExampleConversation = this.ExampleConversation, ExampleConversation = this.ExampleConversation,
AllowProfileUsage = allowProfileUsage, AllowProfileUsage = this.AllowProfileUsage,
}; };
private void RemoveMessage(ContentBlock item) private void RemoveMessage(ContentBlock item)
@ -85,6 +85,8 @@ public partial class ChatTemplateDialog : MSGComponentBase
private void AddNewMessageToEnd() private void AddNewMessageToEnd()
{ {
this.ExampleConversation ??= new List<ContentBlock>();
var newEntry = new ContentBlock var newEntry = new ContentBlock
{ {
Role = ChatRole.USER, // Default to User Role = ChatRole.USER, // Default to User