Chat template selection is now at the correct position and a new chat gets started when a template is chosen. The profile selection gets disabled, if you haven't allowed the usage in the chat template.

This commit is contained in:
Peer Schütt 2025-05-22 13:16:50 +02:00
parent 365f7f36e9
commit e7b32848e5
7 changed files with 34 additions and 20 deletions

View File

@ -81,6 +81,11 @@
</MudTooltip> </MudTooltip>
} }
@if (this.SettingsManager.ConfigurationData.ChatTemplates.Count > 0)
{
<ChatTemplateSelection CurrentChatTemplate="@this.currentChatTemplate" CurrentChatTemplateChanged="@this.ChatTemplateWasChanged"/>
}
@if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY) @if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY)
{ {
<MudTooltip Text="@T("Delete this chat & start a new one.")" Placement="@TOOLBAR_TOOLTIP_PLACEMENT"> <MudTooltip Text="@T("Delete this chat & start a new one.")" Placement="@TOOLBAR_TOOLTIP_PLACEMENT">
@ -107,12 +112,7 @@
</MudTooltip> </MudTooltip>
} }
<ProfileSelection CurrentProfile="@this.currentProfile" CurrentProfileChanged="@this.ProfileWasChanged"/> <ProfileSelection CurrentProfile="@this.currentProfile" CurrentProfileChanged="@this.ProfileWasChanged" Disabled="@(!this.currentChatTemplate.AllowProfileUsage)"/>
@if (this.SettingsManager.ConfigurationData.ChatTemplates.Count > 0)
{
<ChatTemplateSelection CurrentChatTemplate="@this.currentChatTemplate" CurrentChatTemplateChanged="@this.ChatTemplateWasChanged"/>
}
@if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager)) @if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager))
{ {

View File

@ -339,7 +339,9 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
Blocks = this.currentChatTemplate.AdditionalMessages.Select(x => x.DeepClone()).ToList(), Blocks = this.currentChatTemplate.AdditionalMessages.Select(x => x.DeepClone()).ToList(),
}; };
await this.ChatThreadChanged.InvokeAsync(this.ChatThread); // await this.ChatThreadChanged.InvokeAsync(this.ChatThread);
await this.StartNewChat(true, false);
} }
private IReadOnlyList<DataSourceAgentSelected> GetAgentSelectedDataSources() private IReadOnlyList<DataSourceAgentSelected> GetAgentSelectedDataSources()

View File

@ -1,11 +1,20 @@
@using AIStudio.Settings
@inherits MSGComponentBase @inherits MSGComponentBase
<MudTooltip Text="@T("You can switch between your chat templates here")" Placement="Placement.Top">
<MudMenu TransformOrigin="@Origin.BottomLeft" AnchorOrigin="Origin.TopLeft" StartIcon="@Icons.Material.Filled.RateReview" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="@this.CurrentChatTemplate.Name" Variant="Variant.Filled" Color="Color.Default" Class="@this.MarginClass"> <MudTooltip Placement="Placement.Top" Text="@T("Start a new chat with a chat template.")">
<MudMenu AnchorOrigin="Origin.TopLeft" TransformOrigin="@Origin.BottomLeft" Class="@this.MarginClass">
<ActivatorContent>
<MudButton IconSize="Size.Large" StartIcon="@Icons.Material.Filled.RateReview">
@(this.CurrentChatTemplate != ChatTemplate.NO_CHATTEMPLATE ? this.CurrentChatTemplate.Name : "")
</MudButton>
</ActivatorContent>
<ChildContent>
@foreach (var chatTemplate in this.SettingsManager.ConfigurationData.ChatTemplates.GetAllChatTemplates()) @foreach (var chatTemplate in this.SettingsManager.ConfigurationData.ChatTemplates.GetAllChatTemplates())
{ {
<MudMenuItem OnClick="() => this.SelectionChanged(chatTemplate)"> <MudMenuItem OnClick="() => this.SelectionChanged(chatTemplate)">
@chatTemplate.Name @chatTemplate.Name
</MudMenuItem> </MudMenuItem>
} }
</ChildContent>
</MudMenu> </MudMenu>
</MudTooltip> </MudTooltip>

View File

@ -13,7 +13,7 @@ public partial class ChatTemplateSelection : MSGComponentBase
public EventCallback<ChatTemplate> CurrentChatTemplateChanged { get; set; } public EventCallback<ChatTemplate> CurrentChatTemplateChanged { get; set; }
[Parameter] [Parameter]
public string MarginLeft { get; set; } = "ml-3"; public string MarginLeft { get; set; } = "ml-1";
[Parameter] [Parameter]
public string MarginRight { get; set; } = string.Empty; public string MarginRight { get; set; } = string.Empty;

View File

@ -1,6 +1,6 @@
@inherits MSGComponentBase @inherits MSGComponentBase
<MudTooltip Text="@T("You can switch between your profiles here")" Placement="Placement.Top"> <MudTooltip Text="@T("You can switch between your profiles here")" Placement="Placement.Top">
<MudMenu TransformOrigin="@Origin.BottomLeft" AnchorOrigin="Origin.TopLeft" StartIcon="@Icons.Material.Filled.Person4" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="@this.CurrentProfile.Name" Variant="Variant.Filled" Color="Color.Default" Class="@this.MarginClass"> <MudMenu TransformOrigin="@Origin.BottomLeft" AnchorOrigin="Origin.TopLeft" StartIcon="@Icons.Material.Filled.Person4" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="@this.CurrentProfile.Name" Variant="Variant.Filled" Color="Color.Default" Class="@this.MarginClass" disabled="@this.Disabled">
@foreach (var profile in this.SettingsManager.ConfigurationData.Profiles.GetAllProfiles()) @foreach (var profile in this.SettingsManager.ConfigurationData.Profiles.GetAllProfiles())
{ {
<MudMenuItem OnClick="() => this.SelectionChanged(profile)"> <MudMenuItem OnClick="() => this.SelectionChanged(profile)">

View File

@ -18,6 +18,9 @@ public partial class ProfileSelection : MSGComponentBase
[Parameter] [Parameter]
public string MarginRight { get; set; } = string.Empty; public string MarginRight { get; set; } = string.Empty;
[Parameter]
public bool Disabled { get; set; }
private string MarginClass => $"{this.MarginLeft} {this.MarginRight}"; private string MarginClass => $"{this.MarginLeft} {this.MarginRight}";
private async Task SelectionChanged(Profile profile) private async Task SelectionChanged(Profile profile)

View File

@ -6,11 +6,11 @@
<MudDialog> <MudDialog>
<DialogContent> <DialogContent>
<MudJustifiedText Typo="Typo.body1" Class="mb-3"> <MudJustifiedText Class="mb-3" Typo="Typo.body1">
@T("Create your custom chat template to tailor the LLM's behavior for specific tasks or domains. Define a custom system prompt and provide an example conversation to design an AI experience perfectly suited to your requirements.") @T("Create your custom chat template to tailor the LLM's behavior for specific tasks or domains. Define a custom system prompt and provide an example conversation to design an AI experience perfectly suited to your requirements.")
</MudJustifiedText> </MudJustifiedText>
<MudJustifiedText Typo="Typo.body1" Class="mb-3"> <MudJustifiedText Class="mb-3" Typo="Typo.body1">
@T("The name of the chat template is mandatory. Each chat template must have a unique name.") @T("The name of the chat template is mandatory. Each chat template must have a unique name.")
</MudJustifiedText> </MudJustifiedText>
@ -51,7 +51,7 @@
/> />
<MudTooltip Text="@T("Are you unsure which system prompt to use? You can simply start with the default system prompt that AI Studio uses for all chats.")"> <MudTooltip Text="@T("Are you unsure which system prompt to use? You can simply start with the default system prompt that AI Studio uses for all chats.")">
<MudButton Class="mb-3" Color="Color.Primary" OnClick="@this.UseDefaultSystemPrompt" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add" Variant="Variant.Filled">@T("Use the default system prompt")</MudButton> <MudButton Class="mb-3" Color="Color.Primary" OnClick="@this.UseDefaultSystemPrompt" Size="Size.Small" StartIcon="@Icons.Material.Filled.ListAlt" Variant="Variant.Filled">@T("Use the default system prompt")</MudButton>
</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.")">