From e7b32848e5575a0566161e2e30fc6dd2bea117c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peer=20Sch=C3=BCtt?= <20603780+peerschuett@users.noreply.github.com> Date: Thu, 22 May 2025 13:16:50 +0200 Subject: [PATCH] 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. --- .../Components/ChatComponent.razor | 12 ++++----- .../Components/ChatComponent.razor.cs | 4 ++- .../Components/ChatTemplateSelection.razor | 25 +++++++++++++------ .../Components/ChatTemplateSelection.razor.cs | 2 +- .../Components/ProfileSelection.razor | 2 +- .../Components/ProfileSelection.razor.cs | 3 +++ .../Dialogs/ChatTemplateDialog.razor | 6 ++--- 7 files changed, 34 insertions(+), 20 deletions(-) diff --git a/app/MindWork AI Studio/Components/ChatComponent.razor b/app/MindWork AI Studio/Components/ChatComponent.razor index 4886c8f1..7df154f1 100644 --- a/app/MindWork AI Studio/Components/ChatComponent.razor +++ b/app/MindWork AI Studio/Components/ChatComponent.razor @@ -80,6 +80,11 @@ } + + @if (this.SettingsManager.ConfigurationData.ChatTemplates.Count > 0) + { + + } @if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY) { @@ -107,12 +112,7 @@ } - - - @if (this.SettingsManager.ConfigurationData.ChatTemplates.Count > 0) - { - - } + @if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager)) { diff --git a/app/MindWork AI Studio/Components/ChatComponent.razor.cs b/app/MindWork AI Studio/Components/ChatComponent.razor.cs index 4a0007a3..a6a156d3 100644 --- a/app/MindWork AI Studio/Components/ChatComponent.razor.cs +++ b/app/MindWork AI Studio/Components/ChatComponent.razor.cs @@ -339,7 +339,9 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable 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 GetAgentSelectedDataSources() diff --git a/app/MindWork AI Studio/Components/ChatTemplateSelection.razor b/app/MindWork AI Studio/Components/ChatTemplateSelection.razor index 901f6f08..3fe83a3f 100644 --- a/app/MindWork AI Studio/Components/ChatTemplateSelection.razor +++ b/app/MindWork AI Studio/Components/ChatTemplateSelection.razor @@ -1,11 +1,20 @@ +@using AIStudio.Settings @inherits MSGComponentBase - - - @foreach (var chatTemplate in this.SettingsManager.ConfigurationData.ChatTemplates.GetAllChatTemplates()) - { - - @chatTemplate.Name - - } + + + + + + @(this.CurrentChatTemplate != ChatTemplate.NO_CHATTEMPLATE ? this.CurrentChatTemplate.Name : "") + + + + @foreach (var chatTemplate in this.SettingsManager.ConfigurationData.ChatTemplates.GetAllChatTemplates()) + { + + @chatTemplate.Name + + } + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ChatTemplateSelection.razor.cs b/app/MindWork AI Studio/Components/ChatTemplateSelection.razor.cs index 28d4f75b..141fed74 100644 --- a/app/MindWork AI Studio/Components/ChatTemplateSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ChatTemplateSelection.razor.cs @@ -13,7 +13,7 @@ public partial class ChatTemplateSelection : MSGComponentBase public EventCallback CurrentChatTemplateChanged { get; set; } [Parameter] - public string MarginLeft { get; set; } = "ml-3"; + public string MarginLeft { get; set; } = "ml-1"; [Parameter] public string MarginRight { get; set; } = string.Empty; diff --git a/app/MindWork AI Studio/Components/ProfileSelection.razor b/app/MindWork AI Studio/Components/ProfileSelection.razor index 9c9a0520..2c355ff7 100644 --- a/app/MindWork AI Studio/Components/ProfileSelection.razor +++ b/app/MindWork AI Studio/Components/ProfileSelection.razor @@ -1,6 +1,6 @@ @inherits MSGComponentBase - + @foreach (var profile in this.SettingsManager.ConfigurationData.Profiles.GetAllProfiles()) { diff --git a/app/MindWork AI Studio/Components/ProfileSelection.razor.cs b/app/MindWork AI Studio/Components/ProfileSelection.razor.cs index efd15cb5..d72873dd 100644 --- a/app/MindWork AI Studio/Components/ProfileSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ProfileSelection.razor.cs @@ -18,6 +18,9 @@ public partial class ProfileSelection : MSGComponentBase [Parameter] public string MarginRight { get; set; } = string.Empty; + [Parameter] + public bool Disabled { get; set; } + private string MarginClass => $"{this.MarginLeft} {this.MarginRight}"; private async Task SelectionChanged(Profile profile) diff --git a/app/MindWork AI Studio/Dialogs/ChatTemplateDialog.razor b/app/MindWork AI Studio/Dialogs/ChatTemplateDialog.razor index c49ab2e5..30ee2955 100644 --- a/app/MindWork AI Studio/Dialogs/ChatTemplateDialog.razor +++ b/app/MindWork AI Studio/Dialogs/ChatTemplateDialog.razor @@ -6,11 +6,11 @@ - + @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("The name of the chat template is mandatory. Each chat template must have a unique name.") @@ -51,7 +51,7 @@ /> - @T("Use the default system prompt") + @T("Use the default system prompt")