From 273c4274f2b6b07876e0bcf2c96d204c5b41f5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peer=20Sch=C3=BCtt?= Date: Fri, 5 Dec 2025 20:48:54 +0100 Subject: [PATCH] Added document review to the document analysis assistant (#581) Co-authored-by: Thorsten Sommer --- .../Assistants/I18N/allTexts.lua | 65 ++++++++++------- .../Components/AttachDocuments.razor | 41 ++++++----- .../Components/AttachDocuments.razor.cs | 19 +++-- .../Components/ReadFileContent.razor.cs | 25 +------ .../Dialogs/DocumentCheckDialog.razor | 70 +++++++++++++++++++ .../Dialogs/DocumentCheckDialog.razor.cs | 48 +++++++++++++ .../Dialogs/PandocDocumentCheckDialog.razor | 34 --------- .../PandocDocumentCheckDialog.razor.cs | 20 ------ .../plugin.lua | 65 ++++++++++------- .../plugin.lua | 65 ++++++++++------- app/MindWork AI Studio/Tools/UserFile.cs | 51 ++++++++++++++ .../wwwroot/changelog/v0.9.55.md | 3 +- 12 files changed, 324 insertions(+), 182 deletions(-) create mode 100644 app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor create mode 100644 app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor.cs delete mode 100644 app/MindWork AI Studio/Dialogs/PandocDocumentCheckDialog.razor delete mode 100644 app/MindWork AI Studio/Dialogs/PandocDocumentCheckDialog.razor.cs create mode 100644 app/MindWork AI Studio/Tools/UserFile.cs diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index c2b1cc0b..74cbc726 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -1483,11 +1483,11 @@ UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T861873672"] = "Export C -- Open Settings UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T1172211894"] = "Open Settings" --- Drag and drop files here or click to attach documents. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T1647829151"] = "Drag and drop files here or click to attach documents." +-- Drag and drop files into the marked area or click here to attach documents: +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T230755331"] = "Drag and drop files into the marked area or click here to attach documents:" --- Pandoc Load Document Preview -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T2686523471"] = "Pandoc Load Document Preview" +-- Document Preview +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T285154968"] = "Document Preview" -- Videos are not supported yet UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T2928927510"] = "Videos are not supported yet" @@ -1498,6 +1498,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T298062956"] = "Images a -- Clear file list UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T3759696136"] = "Clear file list" +-- Add file +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T4014053962"] = "Add file" + -- Executables are not allowed UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T4167762413"] = "Executables are not allowed" @@ -1801,12 +1804,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "You can -- Provider UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Provider" --- Pandoc Installation -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T185447014"] = "Pandoc Installation" - --- Pandoc may be required for importing files. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T2596465560"] = "Pandoc may be required for importing files." - -- Videos are not supported yet UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T2928927510"] = "Videos are not supported yet" @@ -2908,6 +2905,30 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DATASOURCELOCALFILEINFODIALOG::T3688254408"] -- Your security policy UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DATASOURCELOCALFILEINFODIALOG::T4081226330"] = "Your security policy" +-- Markdown View +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T1373123357"] = "Markdown View" + +-- Load file +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T2129302565"] = "Load file" + +-- See how we load your file. Review the content before we process it further. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3271853346"] = "See how we load your file. Review the content before we process it further." + +-- Close +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3448155331"] = "Close" + +-- Loaded Content +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3529911749"] = "Loaded Content" + +-- Simple View +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T428485200"] = "Simple View" + +-- This is the content we loaded from your file — including headings, lists, and formatting. Use this to verify your file loads as expected. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T652739927"] = "This is the content we loaded from your file — including headings, lists, and formatting. Use this to verify your file loads as expected." + +-- File Path +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T729508546"] = "File Path" + -- Embedding Name UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGMETHODDIALOG::T1427271797"] = "Embedding Name" @@ -3118,21 +3139,6 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDIALOG::T504404155"] = "Accept the ter -- Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept GPL and archive," you agree to the terms of the GPL license. Software under GPL is free of charge and free to use. UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDIALOG::T523908375"] = "Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking \"Accept GPL and archive,\" you agree to the terms of the GPL license. Software under GPL is free of charge and free to use." --- Test how Pandoc loads your document. See the raw content it produces before further processing. -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T1481857352"] = "Test how Pandoc loads your document. See the raw content it produces before further processing." - --- Content Loaded by Pandoc -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2147198279"] = "Content Loaded by Pandoc" - --- This is the content Pandoc loaded from your document — including headings, lists, and formatting. Use this to verify your document loads as expected. -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2156541074"] = "This is the content Pandoc loaded from your document — including headings, lists, and formatting. Use this to verify your document loads as expected." - --- Load document -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2394358670"] = "Load document" - --- Cancel -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T900713019"] = "Cancel" - -- Tell the AI what you want it to do for you. What are your goals or are you trying to achieve? Like having the AI address you informally. UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROFILEDIALOG::T1458195391"] = "Tell the AI what you want it to do for you. What are your goals or are you trying to achieve? Like having the AI address you informally." @@ -5875,6 +5881,15 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEEXTENSIONS::T4174900468"] = "Sources pro -- Sources provided by the AI UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEEXTENSIONS::T4261248356"] = "Sources provided by the AI" +-- Pandoc Installation +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T185447014"] = "Pandoc Installation" + +-- Pandoc may be required for importing files. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T2596465560"] = "Pandoc may be required for importing files." + +-- The file path is null or empty and the file therefore can not be loaded. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T932243993"] = "The file path is null or empty and the file therefore can not be loaded." + -- The hostname is not a valid HTTP(S) URL. UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::DATASOURCEVALIDATION::T1013354736"] = "The hostname is not a valid HTTP(S) URL." diff --git a/app/MindWork AI Studio/Components/AttachDocuments.razor b/app/MindWork AI Studio/Components/AttachDocuments.razor index aa89ebe3..cc1899d3 100644 --- a/app/MindWork AI Studio/Components/AttachDocuments.razor +++ b/app/MindWork AI Studio/Components/AttachDocuments.razor @@ -1,20 +1,27 @@ @inherits MSGComponentBase -
- - - - @T("Drag and drop files here or click to attach documents.") - - @foreach (var fileInfo in this.DocumentPaths.Select(file => new FileInfo(file))) - { - - - - } - - - - @T("Clear file list") + + + @T("Drag and drop files into the marked area or click here to attach documents: ") + + @T("Add file") -
\ No newline at end of file + +
+ + @foreach (var fileInfo in this.DocumentPaths.Select(file => new FileInfo(file))) + { + + } + +
+ + @T("Clear file list") + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/AttachDocuments.razor.cs b/app/MindWork AI Studio/Components/AttachDocuments.razor.cs index 7b885842..0e1dc919 100644 --- a/app/MindWork AI Studio/Components/AttachDocuments.razor.cs +++ b/app/MindWork AI Studio/Components/AttachDocuments.razor.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Components; namespace AIStudio.Components; -using DialogOptions = AIStudio.Dialogs.DialogOptions; +using DialogOptions = Dialogs.DialogOptions; public partial class AttachDocuments : MSGComponentBase { @@ -167,19 +167,16 @@ public partial class AttachDocuments : MSGComponentBase } /// - /// The user might want to check what the Pandoc integration actually extracts from his file and therefore gives the LLM as input. + /// The user might want to check what we actually extract from his file and therefore give the LLM as an input. /// /// The file to check. private async Task InvestigateFile(FileInfo file) { - # warning Implement Investigation of file - - var dialogParameters = new DialogParameters{}; - - var dialogReference = await this.DialogService.ShowAsync(T("Pandoc Load Document Preview"), dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - return; + var dialogParameters = new DialogParameters + { + { x => x.FilePath, file.FullName }, + }; + + await this.DialogService.ShowAsync(T("Document Preview"), dialogParameters, DialogOptions.FULLSCREEN); } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ReadFileContent.razor.cs b/app/MindWork AI Studio/Components/ReadFileContent.razor.cs index c4019fa2..4c636567 100644 --- a/app/MindWork AI Studio/Components/ReadFileContent.razor.cs +++ b/app/MindWork AI Studio/Components/ReadFileContent.razor.cs @@ -1,11 +1,8 @@ -using AIStudio.Dialogs; using AIStudio.Tools.Rust; using AIStudio.Tools.Services; using Microsoft.AspNetCore.Components; -using DialogOptions = AIStudio.Dialogs.DialogOptions; - namespace AIStudio.Components; public partial class ReadFileContent : MSGComponentBase @@ -56,27 +53,7 @@ public partial class ReadFileContent : MSGComponentBase return; } - // Ensure that Pandoc is installed and ready: - var pandocState = await Pandoc.CheckAvailabilityAsync(this.RustService, showSuccessMessage: false); - if (!pandocState.IsAvailable) - { - var dialogParameters = new DialogParameters - { - { x => x.ShowInitialResultInSnackbar, false }, - }; - - var dialogReference = await this.DialogService.ShowAsync(T("Pandoc Installation"), dialogParameters, DialogOptions.FULLSCREEN); - await dialogReference.Result; - - pandocState = await Pandoc.CheckAvailabilityAsync(this.RustService, showSuccessMessage: true); - if (!pandocState.IsAvailable) - { - this.Logger.LogError("Pandoc is not available after installation attempt."); - await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Cancel, T("Pandoc may be required for importing files."))); - } - } - - var fileContent = await this.RustService.ReadArbitraryFileData(selectedFile.SelectedFilePath, int.MaxValue); + var fileContent = await UserFile.LoadFileData(selectedFile.SelectedFilePath, this.RustService, this.DialogService); await this.FileContentChanged.InvokeAsync(fileContent); } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor b/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor new file mode 100644 index 00000000..88e5353f --- /dev/null +++ b/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor @@ -0,0 +1,70 @@ +@inherits MSGComponentBase + + + + + @T("See how we load your file. Review the content before we process it further.") + + + @if (string.IsNullOrWhiteSpace(this.FilePath)) + { + + } + else + { + + } + + + + +
+ +
+
+
+ + + +
+ +
+ + + @T("Close") + + +
\ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor.cs b/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor.cs new file mode 100644 index 00000000..93a8bf19 --- /dev/null +++ b/app/MindWork AI Studio/Dialogs/DocumentCheckDialog.razor.cs @@ -0,0 +1,48 @@ +using AIStudio.Components; +using AIStudio.Tools.Services; +using Microsoft.AspNetCore.Components; + +namespace AIStudio.Dialogs; + +/// +/// Check how your file will be loaded. +/// +public partial class DocumentCheckDialog : MSGComponentBase +{ + [CascadingParameter] + private IMudDialogInstance MudDialog { get; set; } = null!; + + [Parameter] + public string FilePath { get; set; } = string.Empty; + + private void Close() => this.MudDialog.Cancel(); + + [Parameter] + public string FileContent { get; set; } = string.Empty; + + [Inject] + private RustService RustService { get; init; } = null!; + + [Inject] + private IDialogService DialogService { get; init; } = null!; + + [Inject] + private ILogger Logger { get; init; } = null!; + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender && !string.IsNullOrWhiteSpace(this.FilePath)) + { + var fileContent = await UserFile.LoadFileData(this.FilePath, this.RustService, this.DialogService); + this.FileContent = fileContent; + this.StateHasChanged(); + } + } + + private CodeBlockTheme CodeColorPalette => this.SettingsManager.IsDarkMode ? CodeBlockTheme.Dark : CodeBlockTheme.Default; + + private MudMarkdownStyling MarkdownStyling => new() + { + CodeBlock = { Theme = this.CodeColorPalette }, + }; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/PandocDocumentCheckDialog.razor b/app/MindWork AI Studio/Dialogs/PandocDocumentCheckDialog.razor deleted file mode 100644 index 50e81235..00000000 --- a/app/MindWork AI Studio/Dialogs/PandocDocumentCheckDialog.razor +++ /dev/null @@ -1,34 +0,0 @@ -@inherits MSGComponentBase - - - - - - - - @T("Test how Pandoc loads your document. See the raw content it produces before further processing.") - - - - - - - - - @T("Cancel") - - - \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/PandocDocumentCheckDialog.razor.cs b/app/MindWork AI Studio/Dialogs/PandocDocumentCheckDialog.razor.cs deleted file mode 100644 index 361342d4..00000000 --- a/app/MindWork AI Studio/Dialogs/PandocDocumentCheckDialog.razor.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Formats.Asn1; -using AIStudio.Components; - -using Microsoft.AspNetCore.Components; - -namespace AIStudio.Dialogs; - -/// -/// Check how your file will be loaded by Pandoc. -/// -public partial class PandocDocumentCheckDialog : MSGComponentBase -{ - [CascadingParameter] - private IMudDialogInstance MudDialog { get; set; } = null!; - - - private string documentContent = string.Empty; - - private void Cancel() => this.MudDialog.Cancel(); -} \ No newline at end of file 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 15b818e4..fb335e5c 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 @@ -1485,11 +1485,11 @@ UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T861873672"] = "Chat in -- Open Settings UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T1172211894"] = "Einstellungen öffnen" --- Drag and drop files here or click to attach documents. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T1647829151"] = "Dateien hierher ziehen und ablegen oder klicken, um Dokumente anzuhängen." +-- Drag and drop files into the marked area or click here to attach documents: +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T230755331"] = "Ziehen Sie Dateien in den markierten Bereich oder klicken Sie hier, um Dokumente anzuhängen:" --- Pandoc Load Document Preview -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T2686523471"] = "Pandoc-Dokumentvorschau" +-- Document Preview +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T285154968"] = "Dokumentenvorschau" -- Videos are not supported yet UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T2928927510"] = "Videos werden noch nicht unterstützt." @@ -1500,6 +1500,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T298062956"] = "Bilder w -- Clear file list UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T3759696136"] = "Dateiliste löschen" +-- Add file +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T4014053962"] = "Datei hinzufügen" + -- Executables are not allowed UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T4167762413"] = "Ausführbare Dateien sind nicht erlaubt" @@ -1803,12 +1806,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "Hier k -- Provider UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Anbieter" --- Pandoc Installation -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T185447014"] = "Pandoc-Installation" - --- Pandoc may be required for importing files. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T2596465560"] = "Pandoc wird möglicherweise zum Importieren von Dateien benötigt." - -- Videos are not supported yet UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T2928927510"] = "Videos werden noch nicht unterstützt." @@ -2910,6 +2907,30 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DATASOURCELOCALFILEINFODIALOG::T3688254408"] -- Your security policy UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DATASOURCELOCALFILEINFODIALOG::T4081226330"] = "Ihre Sicherheitsrichtlinie" +-- Markdown View +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T1373123357"] = "Markdown-Ansicht" + +-- Load file +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T2129302565"] = "Datei laden" + +-- See how we load your file. Review the content before we process it further. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3271853346"] = "So wird Ihre Datei geladen. Überprüfen Sie den Inhalt, bevor wir ihn weiterverarbeiten." + +-- Close +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3448155331"] = "Schließen" + +-- Loaded Content +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3529911749"] = "Geladener Inhalt" + +-- Simple View +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T428485200"] = "Einfache Ansicht" + +-- This is the content we loaded from your file — including headings, lists, and formatting. Use this to verify your file loads as expected. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T652739927"] = "Dies ist der Inhalt, den wir aus Ihrer Datei geladen haben – einschließlich Überschriften, Listen und Formatierung. Verwenden Sie dies, um zu überprüfen, ob Ihre Datei wie erwartet geladen wird." + +-- File Path +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T729508546"] = "Dateipfad" + -- Embedding Name UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGMETHODDIALOG::T1427271797"] = "Name der Einbettung" @@ -3120,21 +3141,6 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDIALOG::T504404155"] = "Akzeptieren Si -- Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept the GPL and download the archive," you agree to the terms of the GPL license. Software under GPL is free of charge and free to use. UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDIALOG::T523908375"] = "Pandoc wird unter der GNU General Public License v2 (GPL) vertrieben. Wenn Sie auf „GPL akzeptieren und Archiv herunterladen“ klicken, stimmen Sie den Bedingungen der GPL-Lizenz zu. Software unter der GPL ist kostenlos und frei nutzbar." --- Test how Pandoc loads your document. See the raw content it produces before further processing. -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T1481857352"] = "Testen Sie, wie Pandoc Ihr Dokument lädt, und überprüfen Sie ob der Inhalt korrekt geladen wird." - --- Content Loaded by Pandoc -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2147198279"] = "Von Pandoc geladener Inhalt" - --- This is the content Pandoc loaded from your document — including headings, lists, and formatting. Use this to verify your document loads as expected. -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2156541074"] = "Das ist der Inhalt, den Pandoc aus Ihrem Dokument geladen hat – einschließlich Überschriften, Listen und Formatierung. Überprüfen Sie damit, ob Ihr Dokument wie erwartet geladen wird." - --- Load document -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2394358670"] = "Dokument laden" - --- Cancel -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T900713019"] = "Abbrechen" - -- Tell the AI what you want it to do for you. What are your goals or are you trying to achieve? Like having the AI address you informally. UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROFILEDIALOG::T1458195391"] = "Teilen Sie der KI mit, was sie machen soll. Was sind ihre Ziele oder was möchten Sie erreichen? Zum Beispiel, dass die KI Sie duzt." @@ -5877,6 +5883,15 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEEXTENSIONS::T4174900468"] = "Von den Dat -- Sources provided by the AI UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEEXTENSIONS::T4261248356"] = "Von der KI bereitgestellte Quellen" +-- Pandoc Installation +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T185447014"] = "Pandoc-Installation" + +-- Pandoc may be required for importing files. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T2596465560"] = "Für das Importieren von Dateien ist möglicherweise Pandoc erforderlich." + +-- The file path is null or empty and the file therefore can not be loaded. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T932243993"] = "Der Dateipfad ist leer, daher kann die Datei nicht geladen werden." + -- The hostname is not a valid HTTP(S) URL. UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::DATASOURCEVALIDATION::T1013354736"] = "Der Hostname ist keine gültige HTTP(S)-URL." 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 f962cf75..f7ffcec2 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 @@ -1485,11 +1485,11 @@ UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T861873672"] = "Export C -- Open Settings UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ASSISTANTBLOCK::T1172211894"] = "Open Settings" --- Drag and drop files here or click to attach documents. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T1647829151"] = "Drag and drop files here or click to attach documents." +-- Drag and drop files into the marked area or click here to attach documents: +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T230755331"] = "Drag and drop files into the marked area or click here to attach documents:" --- Pandoc Load Document Preview -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T2686523471"] = "Pandoc Load Document Preview" +-- Document Preview +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T285154968"] = "Document Preview" -- Videos are not supported yet UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T2928927510"] = "Videos are not supported yet" @@ -1500,6 +1500,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T298062956"] = "Images a -- Clear file list UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T3759696136"] = "Clear file list" +-- Add file +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T4014053962"] = "Add file" + -- Executables are not allowed UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::ATTACHDOCUMENTS::T4167762413"] = "Executables are not allowed" @@ -1803,12 +1806,6 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROFILESELECTION::T918741365"] = "You can -- Provider UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::PROVIDERSELECTION::T900237532"] = "Provider" --- Pandoc Installation -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T185447014"] = "Pandoc Installation" - --- Pandoc may be required for importing files. -UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T2596465560"] = "Pandoc may be required for importing files." - -- Videos are not supported yet UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READFILECONTENT::T2928927510"] = "Videos are not supported yet" @@ -2910,6 +2907,30 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DATASOURCELOCALFILEINFODIALOG::T3688254408"] -- Your security policy UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DATASOURCELOCALFILEINFODIALOG::T4081226330"] = "Your security policy" +-- Markdown View +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T1373123357"] = "Markdown View" + +-- Load file +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T2129302565"] = "Load file" + +-- See how we load your file. Review the content before we process it further. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3271853346"] = "See how we load your file. Review the content before we process it further." + +-- Close +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3448155331"] = "Close" + +-- Loaded Content +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3529911749"] = "Loaded Content" + +-- Simple View +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T428485200"] = "Simple View" + +-- This is the content we loaded from your file — including headings, lists, and formatting. Use this to verify your file loads as expected. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T652739927"] = "This is the content we loaded from your file — including headings, lists, and formatting. Use this to verify your file loads as expected." + +-- File Path +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T729508546"] = "File Path" + -- Embedding Name UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGMETHODDIALOG::T1427271797"] = "Embedding Name" @@ -3120,21 +3141,6 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDIALOG::T504404155"] = "Accept the ter -- Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept the GPL and download the archive," you agree to the terms of the GPL license. Software under GPL is free of charge and free to use. UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDIALOG::T523908375"] = "Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking \"Accept the GPL and download the archive,\" you agree to the terms of the GPL license. Software under GPL is free of charge and free to use." --- Test how Pandoc loads your document. See the raw content it produces before further processing. -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T1481857352"] = "Test how Pandoc loads your document. See the raw content it produces before further processing." - --- Content Loaded by Pandoc -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2147198279"] = "Content Loaded by Pandoc" - --- This is the content Pandoc loaded from your document — including headings, lists, and formatting. Use this to verify your document loads as expected. -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2156541074"] = "This is the content Pandoc loaded from your document — including headings, lists, and formatting. Use this to verify your document loads as expected." - --- Load document -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T2394358670"] = "Load document" - --- Cancel -UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PANDOCDOCUMENTCHECKDIALOG::T900713019"] = "Cancel" - -- Tell the AI what you want it to do for you. What are your goals or are you trying to achieve? Like having the AI address you informally. UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROFILEDIALOG::T1458195391"] = "Tell the AI what you want it to do for you. What are your goals or are you trying to achieve? Like having the AI address you informally." @@ -5877,6 +5883,15 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEEXTENSIONS::T4174900468"] = "Sources pro -- Sources provided by the AI UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEEXTENSIONS::T4261248356"] = "Sources provided by the AI" +-- Pandoc Installation +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T185447014"] = "Pandoc Installation" + +-- Pandoc may be required for importing files. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T2596465560"] = "Pandoc may be required for importing files." + +-- The file path is null or empty and the file therefore can not be loaded. +UI_TEXT_CONTENT["AISTUDIO::TOOLS::USERFILE::T932243993"] = "The file path is null or empty and the file therefore can not be loaded." + -- The hostname is not a valid HTTP(S) URL. UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::DATASOURCEVALIDATION::T1013354736"] = "The hostname is not a valid HTTP(S) URL." diff --git a/app/MindWork AI Studio/Tools/UserFile.cs b/app/MindWork AI Studio/Tools/UserFile.cs new file mode 100644 index 00000000..e3299b39 --- /dev/null +++ b/app/MindWork AI Studio/Tools/UserFile.cs @@ -0,0 +1,51 @@ +using AIStudio.Dialogs; +using AIStudio.Tools.PluginSystem; +using AIStudio.Tools.Services; +using DialogOptions = AIStudio.Dialogs.DialogOptions; + +namespace AIStudio.Tools; + +public static class UserFile +{ + private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(UserFile).Namespace, nameof(UserFile)); + + private static readonly ILogger LOGGER = Program.LOGGER_FACTORY.CreateLogger(nameof(UserFile)); + + /// + /// Attempts to load the content of a file at the specified path, ensuring Pandoc is installed and available before proceeding. + /// + /// The full path to the file to be read. Must not be null or empty. + /// Rustservice used to read file content. + /// Dialogservice used to display the Pandoc installation dialog if needed. + public static async Task LoadFileData(string filePath, RustService rustService, IDialogService dialogService) + { + if (string.IsNullOrEmpty(filePath)) + { + LOGGER.LogError("Can't load from an empty or null file path."); + await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Cancel, TB("The file path is null or empty and the file therefore can not be loaded."))); + } + + // Ensure that Pandoc is installed and ready: + var pandocState = await Pandoc.CheckAvailabilityAsync(rustService, showSuccessMessage: false); + if (!pandocState.IsAvailable) + { + var dialogParameters = new DialogParameters + { + { x => x.ShowInitialResultInSnackbar, false }, + }; + + var dialogReference = await dialogService.ShowAsync(TB("Pandoc Installation"), dialogParameters, DialogOptions.FULLSCREEN); + await dialogReference.Result; + + pandocState = await Pandoc.CheckAvailabilityAsync(rustService, showSuccessMessage: true); + if (!pandocState.IsAvailable) + { + LOGGER.LogError("Pandoc is not available after installation attempt."); + await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Cancel, TB("Pandoc may be required for importing files."))); + } + } + + var fileContent = await rustService.ReadArbitraryFileData(filePath, int.MaxValue); + return fileContent; + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md index 321f7bbb..64a62ed0 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md @@ -1,3 +1,4 @@ # v0.9.55, build 230 (2025-12-xx xx:xx UTC) - Added support for newer Mistral models (Mistral 3, Voxtral, and Magistral). -- Improved the ID handling for configuration plugins. \ No newline at end of file +- Improved the document preview dialog for the document analysis assistant (in preview), providing Markdown and plain text views for attached files. +- Improved the ID handling for configuration plugins.