From a3d38c5db4109d8ed614cb617710b7ad1455a354 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Thu, 5 Nov 2026 12:38:21 +0100 Subject: [PATCH] Fixed dropping a custom prompt guide into the Prompt Optimizer (#1163) --- .../Assistants/I18N/allTexts.lua | 3 ++ .../AssistantPromptOptimizer.razor | 20 ++++----- .../AssistantPromptOptimizer.razor.cs | 42 +++++++++++-------- .../Components/ReadFileContent.razor.cs | 25 +++-------- .../plugin.lua | 3 ++ .../plugin.lua | 3 ++ .../wwwroot/changelog/v26.11.1.md | 2 + 7 files changed, 49 insertions(+), 49 deletions(-) diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index b7d8c46bb..5ed1c74ae 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -2311,6 +2311,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER -- Custom language UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3032662264"] = "Custom language" +-- Load the prompt guide from file +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3415232006"] = "Load the prompt guide from file" + -- Give the model a role UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3420218291"] = "Give the model a role" diff --git a/app/MindWork AI Studio/Assistants/PromptOptimizer/AssistantPromptOptimizer.razor b/app/MindWork AI Studio/Assistants/PromptOptimizer/AssistantPromptOptimizer.razor index 7bcbdd8ce..b7fcdcbf3 100644 --- a/app/MindWork AI Studio/Assistants/PromptOptimizer/AssistantPromptOptimizer.razor +++ b/app/MindWork AI Studio/Assistants/PromptOptimizer/AssistantPromptOptimizer.razor @@ -95,17 +95,6 @@ @T("Use custom prompt guide") - @if (this.useCustomPromptGuide) - { - - } - +@if (this.useCustomPromptGuide) +{ + +} + diff --git a/app/MindWork AI Studio/Assistants/PromptOptimizer/AssistantPromptOptimizer.razor.cs b/app/MindWork AI Studio/Assistants/PromptOptimizer/AssistantPromptOptimizer.razor.cs index 0ce067ef6..eb089ce6c 100644 --- a/app/MindWork AI Studio/Assistants/PromptOptimizer/AssistantPromptOptimizer.razor.cs +++ b/app/MindWork AI Studio/Assistants/PromptOptimizer/AssistantPromptOptimizer.razor.cs @@ -5,6 +5,7 @@ using AIStudio.Dialogs; using AIStudio.Dialogs.Settings; using AIStudio.Tools.AssistantLaunch; using AIStudio.Tools.AssistantSessions; +using AIStudio.Tools.Rust; using AIStudio.Tools.Services; using Microsoft.AspNetCore.Components; @@ -187,6 +188,16 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore + /// The files a custom prompt guide can come from. + /// + /// + /// Documents only: an audio or a video file would be transcribed, and a transcript reports + /// the name of its file rather than the path, which the preview of the guide needs. + /// + private static readonly FileTypeFilter[] CUSTOM_PROMPT_GUIDE_FILE_TYPES = [ FileTypes.DOCUMENT ]; + private static readonly AssistantSessionStateKey INPUT_PROMPT_STATE_KEY = new(nameof(inputPrompt)); private static readonly AssistantSessionStateKey SELECTED_TARGET_LANGUAGE_STATE_KEY = new(nameof(selectedTargetLanguage)); private static readonly AssistantSessionStateKey CUSTOM_TARGET_LANGUAGE_STATE_KEY = new(nameof(customTargetLanguage)); @@ -549,29 +560,24 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore files) + /// + /// Takes the file whose content was just loaded as the custom prompt guide. + /// + /// + /// The content has arrived already, through the binding of ReadFileContent, which reports it + /// before the path. A file without readable content never gets here. + /// + /// The path of the file which was loaded. + private async Task SetCustomPromptGuideFile(string filePath) { - if (files.Count == 0) - { - this.customPromptGuideFiles.Clear(); - this.currentCustomPromptGuidePath = string.Empty; - this.customPromptingGuidelineContent = string.Empty; - return; - } - - var selected = files.FirstOrDefault(file => !string.Equals(file.FilePath, this.currentCustomPromptGuidePath, StringComparison.OrdinalIgnoreCase)) - ?? files.First(); - var replacedPrevious = !string.IsNullOrWhiteSpace(this.currentCustomPromptGuidePath) && - !string.Equals(this.currentCustomPromptGuidePath, selected.FilePath, StringComparison.OrdinalIgnoreCase); + !string.Equals(this.currentCustomPromptGuidePath, filePath, StringComparison.OrdinalIgnoreCase); - this.customPromptGuideFiles = [ selected ]; - this.currentCustomPromptGuidePath = selected.FilePath; + this.customPromptGuideFiles = [ FileAttachment.FromPath(filePath) ]; + this.currentCustomPromptGuidePath = filePath; - if (files.Count > 1 || replacedPrevious) + if (replacedPrevious) await this.MessageBus.SendInfo(new(Icons.Material.Filled.SwapHoriz, T("Replaced the previously selected custom prompt guide file."))); - - await this.LoadCustomPromptGuidelineContentAsync(selected); } private async Task LoadCustomPromptGuidelineContentAsync(FileAttachment fileAttachment) diff --git a/app/MindWork AI Studio/Components/ReadFileContent.razor.cs b/app/MindWork AI Studio/Components/ReadFileContent.razor.cs index b1afc1d2e..0c5b055e8 100644 --- a/app/MindWork AI Studio/Components/ReadFileContent.razor.cs +++ b/app/MindWork AI Studio/Components/ReadFileContent.razor.cs @@ -211,23 +211,6 @@ public partial class ReadFileContent : MSGComponentBase } } - private async Task EnsurePandocAvailability() - { - // Ensure that Pandoc is installed and ready: - var pandocState = await this.PandocAvailabilityService.EnsureAvailabilityAsync( - showSuccessMessage: false, - showDialog: true); - - // Check if Pandoc is available after the check / installation: - if (!pandocState.IsAvailable) - { - this.Logger.LogWarning("The user cancelled the Pandoc installation or Pandoc is not available. Aborting file selection."); - return false; - } - - return true; - } - private async Task LoadFirstValidFile(List paths) { var inaccessiblePaths = paths.Where(path => !File.Exists(path)).ToList(); @@ -264,9 +247,11 @@ public partial class ReadFileContent : MSGComponentBase if (FileTypes.IsAllowedPath(filePath, FileTypes.AUDIO) || FileTypes.IsAllowedPath(filePath, FileTypes.VIDEO)) return await this.LoadMediaTranscriptAsync(filePath); - if (!await this.EnsurePandocAvailability()) - return false; - + // + // No Pandoc check here: UserFile.LoadFileData asks for Pandoc itself, and only for the + // formats we convert with it. PDFs and the other document types are read by the Rust + // runtime, so they must stay loadable without Pandoc. + // if (!await FileExtensionValidation.IsExtensionValidWithNotifyAsync(FileExtensionValidation.UseCase.DIRECTLY_LOADING_CONTENT, filePath)) { this.Logger.LogWarning("User attempted to load unsupported file: {FilePath}", filePath); diff --git a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua index 86ffa86ff..68736e757 100644 --- a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua @@ -2313,6 +2313,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER -- Custom language UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3032662264"] = "Benutzerdefinierte Sprache" +-- Load the prompt guide from file +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3415232006"] = "Prompting-Leitfaden aus Datei laden" + -- Give the model a role UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3420218291"] = "Geben Sie dem Modell eine Rolle" diff --git a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua index fb7fcaa8e..07e5444d2 100644 --- a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua @@ -2313,6 +2313,9 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER -- Custom language UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3032662264"] = "Custom language" +-- Load the prompt guide from file +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3415232006"] = "Load the prompt guide from file" + -- Give the model a role UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::PROMPTOPTIMIZER::ASSISTANTPROMPTOPTIMIZER::T3420218291"] = "Give the model a role" diff --git a/app/MindWork AI Studio/wwwroot/changelog/v26.11.1.md b/app/MindWork AI Studio/wwwroot/changelog/v26.11.1.md index 0ec0295ff..d57a6665a 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v26.11.1.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v26.11.1.md @@ -29,6 +29,8 @@ - Fixed the Assistant Builder telling you in English why it could not use the answer of the AI model, even when you chose another language for AI Studio. - Fixed requests to a provider failing when a configuration plugin gave it additional API parameters that contain the same parameter twice. AI Studio now sends the request without these parameters and names the repeated parameter in its log, as it does for other invalid parameters. - Fixed the information page leaving out three libraries that AI Studio uses: MailKit and MimeKit, which read your mailboxes, and the Open XML SDK, with which the Slide Assistant reads and writes PowerPoint files. +- Fixed AI Studio asking you to install Pandoc when you load a file as the input of an assistant, although PDF, Word, Markdown, and most other files need no Pandoc. +- Fixed dropping a file onto your custom prompt guide in the Prompt Optimizer. Once you switch on "Use custom prompt guide", a marked area appears where you can drop your guide or select it with a button. - Upgraded several libraries to improve security. - Upgraded Tauri to v2.12.5. - Upgraded MudBlazor to v9.12.0.