Predefined User Input works now

This commit is contained in:
Peer Schütt 2025-07-09 10:24:56 +02:00
parent 9c52812c09
commit 30777337dd
5 changed files with 41 additions and 1 deletions

View File

@ -673,6 +673,8 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
Seed = this.RNG.Next(),
Blocks = this.currentChatTemplate == default ? [] : this.currentChatTemplate.ExampleConversation.Select(x => x.DeepClone()).ToList(),
};
this.userInput = this.currentChatTemplate.PredefinedUserPrompt;
}
// Now, we have to reset the data source options as well:

View File

@ -56,6 +56,34 @@
@T("Use the default system prompt")
</MudButton>
<MudText Typo="Typo.h6" Class="mb-3 mt-6">
@T("Predefined User Input")
</MudText>
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
@T("You might want to predefine a first message that will be copied into the user prompt, when you use this chat template. This message could for example be a blueprint for a structured message that this chat template is defined to work with.")
</MudJustifiedText>
<MudTextField
T="string"
@bind-Text="@this.PredefinedUserPrompt"
AdornmentIcon="@Icons.Material.Filled.ListAlt"
Adornment="Adornment.Start"
Immediate="@true"
Label="@T("What predefined user input do you want to use?")"
Variant="Variant.Outlined"
Lines="4"
MaxLines="12"
AutoGrow="@true"
Class="mb-3"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
HelperText="@T("Tell the AI your predefined user input.")"
/>
<MudText Typo="Typo.h6" Class="mb-3 mt-6">
@T("Profile Usage")
</MudText>
<MudJustifiedText Class="mt-6" Typo="Typo.body1">
@T("Using some chat templates in tandem with profiles might cause issues. Therefore, you might prohibit the usage of profiles here.")
</MudJustifiedText>
@ -69,6 +97,7 @@
@T("Add messages of an example conversation (user prompt followed by assistant prompt) to demonstrate the desired interaction pattern. These examples help the AI understand your expectations by showing it the correct format, style, and content of responses before it receives actual user inputs.")
</MudJustifiedText>
<MudTable Items="@this.dataExampleConversation" FixedHeader="true" Hover="true" Class="mt-3 mb-3" CanCancelEdit="true" CancelEditTooltip="@T("Cancel")" CommitEditTooltip="@T("Commit Changes")" Outlined="true" RowEditCancel="@this.ResetItem" RowEditPreview="@this.BackupItem" EditTrigger="TableEditTrigger.RowClick" IsEditRowSwitchingBlocked="false" RowEditCommit="@this.CommitInlineEdit">
<ColGroup>
<col style="width: 10em;" />

View File

@ -35,6 +35,12 @@ public partial class ChatTemplateDialog : MSGComponentBase
[Parameter]
public string DataSystemPrompt { get; set; } = string.Empty;
/// <summary>
/// What is the predefined user prompt?
/// </summary>
[Parameter]
public string PredefinedUserPrompt { get; set; } = string.Empty;
/// <summary>
/// Should the dialog be in editing mode?
/// </summary>
@ -107,6 +113,7 @@ public partial class ChatTemplateDialog : MSGComponentBase
Name = this.DataName,
SystemPrompt = this.DataSystemPrompt,
PredefinedUserPrompt = this.PredefinedUserPrompt,
ExampleConversation = this.dataExampleConversation,
AllowProfileUsage = this.AllowProfileUsage,
};

View File

@ -33,6 +33,7 @@ public partial class SettingsDialogChatTemplate : SettingsDialogBase
{ x => x.DataId, chatTemplate.Id },
{ x => x.DataName, chatTemplate.Name },
{ x => x.DataSystemPrompt, chatTemplate.SystemPrompt },
{ x => x.PredefinedUserPrompt, chatTemplate.PredefinedUserPrompt },
{ x => x.IsEditing, true },
{ x => x.ExampleConversation, chatTemplate.ExampleConversation },
{ x => x.AllowProfileUsage, chatTemplate.AllowProfileUsage },

View File

@ -3,7 +3,7 @@ using AIStudio.Tools.PluginSystem;
namespace AIStudio.Settings;
public readonly record struct ChatTemplate(uint Num, string Id, string Name, string SystemPrompt, List<ContentBlock> ExampleConversation, bool AllowProfileUsage)
public readonly record struct ChatTemplate(uint Num, string Id, string Name, string SystemPrompt, string PredefinedUserPrompt, List<ContentBlock> ExampleConversation, bool AllowProfileUsage)
{
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(ChatTemplate).Namespace, nameof(ChatTemplate));
@ -11,6 +11,7 @@ public readonly record struct ChatTemplate(uint Num, string Id, string Name, str
{
Name = TB("Use no chat template"),
SystemPrompt = string.Empty,
PredefinedUserPrompt = string.Empty,
Id = Guid.Empty.ToString(),
Num = uint.MaxValue,
ExampleConversation = [],