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>
public string PrepareSystemPrompt(SettingsManager settingsManager, ChatThread chatThread, ILogger logger)
{
//
// 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.IsEditing, true },
{x => x.ExampleConversation, chatTemplate.ExampleConversation},
{x => x.AllowProfileUsage, chatTemplate.AllowProfileUsage},
};
var dialogReference = await this.DialogService.ShowAsync<ChatTemplateDialog>(T("Edit Chat Template"), dialogParameters, DialogOptions.FULLSCREEN);

View File

@ -55,7 +55,7 @@
</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.")">
<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>
<MudText Typo="Typo.h6" Class="mb-3">

View File

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