diff --git a/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor b/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor new file mode 100644 index 00000000..0f266cc7 --- /dev/null +++ b/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor @@ -0,0 +1,65 @@ +@attribute [Route(Routes.ASSISTANT_DOCUMENT_ANALYSIS)] +@inherits AssistantBaseCore + +@using AIStudio.Settings.DataModel + + +
+ + + @T("Document analysis policies") + + + + @T("Here you have the option to save different policies for various document analysis assistants and switch between them.") + + +@if(this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies.Count is 0) +{ + + @T("You have not yet added any document analysis policies.") + +} +else +{ + + @foreach (var policy in this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies) + { + + @policy.PolicyName + + } + +} + + + + @T("Add policy") + + + @T("Delete this policy") + + + +
+ + + + + @T("Common settings") + + + + + + + @T("Input and output rules") + + + + + + + TODO + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor.cs b/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor.cs new file mode 100644 index 00000000..2cc6dbd7 --- /dev/null +++ b/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor.cs @@ -0,0 +1,262 @@ +using System.Text; + +using AIStudio.Chat; +using AIStudio.Dialogs; +using AIStudio.Dialogs.Settings; +using AIStudio.Settings.DataModel; + +using Microsoft.AspNetCore.Components; + +using DialogOptions = AIStudio.Dialogs.DialogOptions; + +namespace AIStudio.Assistants.DocumentAnalysis; + +public partial class DocumentAnalysisAssistant : AssistantBaseCore +{ + [Inject] + private IDialogService DialogService { get; init; } = null!; + + public override Tools.Components Component => Tools.Components.DOCUMENT_ANALYSIS_ASSISTANT; + + protected override string Title => T("Document Analysis Assistant"); + + protected override string Description => T( + """ + The document analysis assistant helps you to analyze and extract information from documents + based on predefined policies. You can create, edit, and manage document analysis policies + that define how documents should be processed and what information should be extracted. + Some policies might be protected by your organization and cannot be modified or deleted. + """); + + protected override string SystemPrompt + { + get + { + var sb = new StringBuilder(); + return sb.ToString(); + } + } + + protected override IReadOnlyList FooterButtons => []; + + protected override bool ShowEntireChatThread => true; + + protected override bool ShowSendTo => true; + + protected override string SubmitText => T("Analyze document"); + + protected override Func SubmitAction => this.Analyze; + + protected override bool SubmitDisabled => this.IsNoPolicySelected; + + protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with + { + SystemPrompt = SystemPrompts.DEFAULT, + }; + + protected override void ResetForm() + { + if (!this.MightPreselectValues()) + { + this.policyName = string.Empty; + this.policyDescription = string.Empty; + this.policyIsProtected = false; + this.policyAnalysisRules = string.Empty; + this.policyOutputRules = string.Empty; + } + } + + protected override bool MightPreselectValues() + { + if (this.selectedPolicy is not null) + { + this.policyName = this.selectedPolicy.PolicyName; + this.policyDescription = this.selectedPolicy.PolicyDescription; + this.policyIsProtected = this.selectedPolicy.IsProtected; + this.policyAnalysisRules = this.selectedPolicy.AnalysisRules; + this.policyOutputRules = this.selectedPolicy.OutputRules; + + return true; + } + + return false; + } + + protected override async Task OnFormChange() + { + await this.AutoSave(); + } + + #region Overrides of AssistantBase + + protected override async Task OnInitializedAsync() + { + this.selectedPolicy = this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies.FirstOrDefault(); + if(this.selectedPolicy is null) + { + await this.AddPolicy(); + this.selectedPolicy = this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies.First(); + } + + await base.OnInitializedAsync(); + } + + #endregion + + private async Task AutoSave(bool force = false) + { + if(this.selectedPolicy is null) + return; + + if(!force && this.selectedPolicy.IsProtected) + return; + + if(!force && this.policyIsProtected) + return; + + this.selectedPolicy.PreselectedProvider = this.providerSettings.Id; + + this.selectedPolicy.PolicyName = this.policyName; + this.selectedPolicy.PolicyDescription = this.policyDescription; + this.selectedPolicy.IsProtected = this.policyIsProtected; + this.selectedPolicy.AnalysisRules = this.policyAnalysisRules; + this.selectedPolicy.OutputRules = this.policyOutputRules; + + await this.SettingsManager.StoreSettings(); + } + + private DataDocumentAnalysisPolicy? selectedPolicy; + private bool policyIsProtected; + private string policyName = string.Empty; + private string policyDescription = string.Empty; + private string policyAnalysisRules = string.Empty; + private string policyOutputRules = string.Empty; + + private bool IsNoPolicySelectedOrProtected => this.selectedPolicy is null || this.selectedPolicy.IsProtected; + + private bool IsNoPolicySelected => this.selectedPolicy is null; + + private void SelectedPolicyChanged(DataDocumentAnalysisPolicy? policy) + { + this.selectedPolicy = policy; + this.ResetForm(); + } + + private async Task AddPolicy() + { + this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies.Add(new () + { + PolicyName = string.Format(T("Policy {0}"), DateTimeOffset.UtcNow), + }); + + await this.SettingsManager.StoreSettings(); + } + + private async Task RemovePolicy() + { + if(this.selectedPolicy is null) + return; + + if(this.selectedPolicy.IsProtected) + return; + + var dialogParameters = new DialogParameters + { + { x => x.Message, string.Format(T("Are you sure you want to delete the document analysis policy '{0}'?"), this.selectedPolicy.PolicyName) }, + }; + + var dialogReference = await this.DialogService.ShowAsync(T("Delete document analysis policy"), dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies.Remove(this.selectedPolicy); + this.selectedPolicy = null; + this.ResetForm(); + + await this.SettingsManager.StoreSettings(); + this.form?.ResetValidation(); + } + + /// + /// Gets called when the policy name was changed by typing. + /// + /// + /// This method is used to update the policy name in the selected policy. + /// Otherwise, the users would be confused when they change the name and the changes are not reflected in the UI. + /// + private void PolicyNameWasChanged() + { + if(this.selectedPolicy is null) + return; + + if(this.selectedPolicy.IsProtected) + return; + + this.selectedPolicy.PolicyName = this.policyName; + } + + private async Task PolicyProtectionWasChanged(bool state) + { + if(this.selectedPolicy is null) + return; + + this.policyIsProtected = state; + this.selectedPolicy.IsProtected = state; + await this.AutoSave(true); + } + + private string? ValidatePolicyName(string name) + { + if(string.IsNullOrWhiteSpace(name)) + return T("Please provide a name for your policy. This name will be used to identify the policy in AI Studio."); + + if(name.Length is > 60 or < 6) + return T("The name of your policy must be between 6 and 60 characters long."); + + if(this.SettingsManager.ConfigurationData.DocumentAnalysis.Policies.Where(n => n != this.selectedPolicy).Any(n => n.PolicyName == name)) + return T("A policy with this name already exists. Please choose a different name."); + + return null; + } + + private string? ValidatePolicyDescription(string description) + { + if(string.IsNullOrWhiteSpace(description)) + return T("Please provide a description for your policy. This description will be used to inform users about the purpose of your document analysis policy."); + + if(description.Length is < 32 or > 512) + return T("The description of your policy must be between 32 and 512 characters long."); + + return null; + } + + private string? ValidateAnalysisRules(string analysisRules) + { + if(string.IsNullOrWhiteSpace(analysisRules)) + return T("Please provide a description of your analysis rules. This rules will be used to instruct the AI on how to analyze the documents."); + + return null; + } + + private string? ValidateOutputRules(string outputRules) + { + if(string.IsNullOrWhiteSpace(outputRules)) + return T("Please provide a description of your output rules. This rules will be used to instruct the AI on how to format the output of the analysis."); + + return null; + } + + private async Task Analyze() + { + if (this.IsNoPolicySelectedOrProtected) + return; + + await this.AutoSave(); + await this.form!.Validate(); + if (!this.inputIsValid) + return; + + #warning TODO + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index d4572354..7728d11d 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -382,6 +382,96 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::CODING::COMMONCODINGLANGUAGEEXTENSIONS::T -- None UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::CODING::COMMONCODINGLANGUAGEEXTENSIONS::T810547195"] = "None" +-- Please provide a brief description of your policy. Describe or explain what your policy does. This description will be shown to users in AI Studio. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1182372158"] = "Please provide a brief description of your policy. Describe or explain what your policy does. This description will be shown to users in AI Studio." + +-- Settings +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1258653480"] = "Settings" + +-- No, the policy can be edited +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1286595725"] = "No, the policy can be edited" + +-- Please provide a description of your analysis rules. This rules will be used to instruct the AI on how to analyze the documents. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1291179736"] = "Please provide a description of your analysis rules. This rules will be used to instruct the AI on how to analyze the documents." + +-- Input and output rules +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1714738288"] = "Input and output rules" + +-- Yes, protect this policy +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1762380857"] = "Yes, protect this policy" + +-- Please give your policy a name that provides information about the intended purpose. The name will be displayed to users in AI Studio. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1786783201"] = "Please give your policy a name that provides information about the intended purpose. The name will be displayed to users in AI Studio." + +-- Please provide a description for your policy. This description will be used to inform users about the purpose of your document analysis policy. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1837166236"] = "Please provide a description for your policy. This description will be used to inform users about the purpose of your document analysis policy." + +-- Common settings +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T1963959073"] = "Common settings" + +-- Analyze document +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T2053296240"] = "Analyze document" + +-- Document analysis policies +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T2064879144"] = "Document analysis policies" + +-- The name of your policy must be between 6 and 60 characters long. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T2435013256"] = "The name of your policy must be between 6 and 60 characters long." + +-- Are you sure you want to delete the document analysis policy '{0}'? +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T2582525917"] = "Are you sure you want to delete the document analysis policy '{0}'?" + +-- Document analysis +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T2708005534"] = "Document analysis" + +-- Policy name +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T2879019438"] = "Policy name" + +-- Analysis rules +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T3108719748"] = "Analysis rules" + +-- Delete this policy +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T3119086260"] = "Delete this policy" + +-- Policy {0} +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T3157740273"] = "Policy {0}" + +-- The description of your policy must be between 32 and 512 characters long. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T3285636934"] = "The description of your policy must be between 32 and 512 characters long." + +-- Add policy +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T3357792182"] = "Add policy" + +-- You have not yet added any document analysis policies. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T3394850216"] = "You have not yet added any document analysis policies." + +-- Document Analysis Assistant +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T348883878"] = "Document Analysis Assistant" + +-- A policy with this name already exists. Please choose a different name. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T3584374593"] = "A policy with this name already exists. Please choose a different name." + +-- Output rules +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T3918193587"] = "Output rules" + +-- Please provide a name for your policy. This name will be used to identify the policy in AI Studio. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T4040507702"] = "Please provide a name for your policy. This name will be used to identify the policy in AI Studio." + +-- Delete document analysis policy +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T4293094335"] = "Delete document analysis policy" + +-- Please provide a description of your output rules. This rules will be used to instruct the AI on how to format the output of the analysis. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T652187065"] = "Please provide a description of your output rules. This rules will be used to instruct the AI on how to format the output of the analysis." + +-- Policy description +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T748735777"] = "Policy description" + +-- Would you like to protect this policy so that you cannot accidentally edit or delete it? +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T80597472"] = "Would you like to protect this policy so that you cannot accidentally edit or delete it?" + +-- Here you have the option to save different policies for various document analysis assistants and switch between them. +UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::DOCUMENTANALYSIS::DOCUMENTANALYSISASSISTANT::T848153710"] = "Here you have the option to save different policies for various document analysis assistants and switch between them." + -- Provide a list of bullet points and some basic information for an e-mail. The assistant will generate an e-mail based on that input. UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::EMAIL::ASSISTANTEMAIL::T1143222914"] = "Provide a list of bullet points and some basic information for an e-mail. The assistant will generate an e-mail based on that input." @@ -3604,6 +3694,33 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDATASOURCES::T774473 -- Local Directory UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDATASOURCES::T926703547"] = "Local Directory" +-- When enabled, you can preselect some ERI server options. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T1280666275"] = "When enabled, you can preselect some ERI server options." + +-- Assistant: Document Analysis +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T1372406750"] = "Assistant: Document Analysis" + +-- Most document analysis options can be customized and saved directly in the assistant. For this, the assistant has an auto-save function. +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T1870328357"] = "Most document analysis options can be customized and saved directly in the assistant. For this, the assistant has an auto-save function." + +-- Would you like to preselect one of your profiles? +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T2221665527"] = "Would you like to preselect one of your profiles?" + +-- Preselect document analysis options? +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T2230062650"] = "Preselect document analysis options?" + +-- No document analysis options are preselected +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T3317802895"] = "No document analysis options are preselected" + +-- Close +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T3448155331"] = "Close" + +-- Document analysis options are preselected +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T3945756386"] = "Document analysis options are preselected" + +-- Preselect one of your profiles? +UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGDOCUMENTANALYSIS::T4004501229"] = "Preselect one of your profiles?" + -- When enabled, you can preselect some ERI server options. UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SETTINGS::SETTINGSDIALOGERISERVER::T1280666275"] = "When enabled, you can preselect some ERI server options." @@ -4477,6 +4594,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::ABOUT::T986578435"] = "Install Pandoc" -- Get coding and debugging support from an LLM. UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T1243850917"] = "Get coding and debugging support from an LLM." +-- Analyze a document regarding defined rules and extract key information. +UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T1271524187"] = "Analyze a document regarding defined rules and extract key information." + -- Business UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T131837803"] = "Business" @@ -4522,6 +4642,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T2547582747"] = "Synonyms" -- Find synonyms for a given word or phrase. UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T2712131461"] = "Find synonyms for a given word or phrase." +-- Document Analysis +UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T2770149758"] = "Document Analysis" + -- AI Studio Development UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T2830810750"] = "AI Studio Development" @@ -5044,6 +5167,9 @@ UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::PREVIEWFEATURESEXTENSIONS::T1587 -- Read PDF: Preview of our PDF reading system where you can read and extract text from PDF files UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::PREVIEWFEATURESEXTENSIONS::T1847148141"] = "Read PDF: Preview of our PDF reading system where you can read and extract text from PDF files" +-- Document Analysis: Preview of our document analysis system where you can analyze and extract information from documents +UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::PREVIEWFEATURESEXTENSIONS::T1848209619"] = "Document Analysis: Preview of our document analysis system where you can analyze and extract information from documents" + -- Plugins: Preview of our plugin system where you can extend the functionality of the app UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::PREVIEWFEATURESEXTENSIONS::T2056842933"] = "Plugins: Preview of our plugin system where you can extend the functionality of the app" diff --git a/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogDocumentAnalysis.razor b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogDocumentAnalysis.razor new file mode 100644 index 00000000..7cdd4455 --- /dev/null +++ b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogDocumentAnalysis.razor @@ -0,0 +1,28 @@ +@using AIStudio.Settings +@inherits SettingsDialogBase + + + + + + + @T("Assistant: Document Analysis") + + + + + + + + + + @T("Most document analysis options can be customized and saved directly in the assistant. For this, the assistant has an auto-save function.") + + + + + + @T("Close") + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogDocumentAnalysis.razor.cs b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogDocumentAnalysis.razor.cs new file mode 100644 index 00000000..caafcb44 --- /dev/null +++ b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogDocumentAnalysis.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Dialogs.Settings; + +public partial class SettingsDialogDocumentAnalysis : SettingsDialogBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Pages/Assistants.razor b/app/MindWork AI Studio/Pages/Assistants.razor index d7fe0bed..1cd72a5f 100644 --- a/app/MindWork AI Studio/Pages/Assistants.razor +++ b/app/MindWork AI Studio/Pages/Assistants.razor @@ -26,6 +26,12 @@ + + @if (PreviewFeatures.PRE_DOCUMENT_ANALYSIS_2025.IsEnabled(this.SettingsManager)) + { + + } + diff --git a/app/MindWork AI Studio/Routes.razor.cs b/app/MindWork AI Studio/Routes.razor.cs index d59bffac..836cab0e 100644 --- a/app/MindWork AI Studio/Routes.razor.cs +++ b/app/MindWork AI Studio/Routes.razor.cs @@ -27,5 +27,6 @@ public sealed partial class Routes public const string ASSISTANT_BIAS = "/assistant/bias-of-the-day"; public const string ASSISTANT_ERI = "/assistant/eri"; public const string ASSISTANT_AI_STUDIO_I18N = "/assistant/ai-studio/i18n"; + public const string ASSISTANT_DOCUMENT_ANALYSIS = "/assistant/document-analysis"; // ReSharper restore InconsistentNaming } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/Data.cs b/app/MindWork AI Studio/Settings/DataModel/Data.cs index 0e825aa0..8c8a1ef8 100644 --- a/app/MindWork AI Studio/Settings/DataModel/Data.cs +++ b/app/MindWork AI Studio/Settings/DataModel/Data.cs @@ -84,6 +84,8 @@ public sealed class Data public DataCoding Coding { get; init; } = new(); public DataERI ERI { get; init; } = new(); + + public DataDocumentAnalysis DocumentAnalysis { get; init; } = new(x => x.DocumentAnalysis); public DataTextSummarizer TextSummarizer { get; init; } = new(); diff --git a/app/MindWork AI Studio/Settings/DataModel/DataDocumentAnalysis.cs b/app/MindWork AI Studio/Settings/DataModel/DataDocumentAnalysis.cs new file mode 100644 index 00000000..c0f58d6f --- /dev/null +++ b/app/MindWork AI Studio/Settings/DataModel/DataDocumentAnalysis.cs @@ -0,0 +1,18 @@ +using System.Linq.Expressions; + +namespace AIStudio.Settings.DataModel; + +public sealed class DataDocumentAnalysis(Expression>? configSelection = null) +{ + /// + /// The default constructor for the JSON deserializer. + /// + public DataDocumentAnalysis() : this(null) + { + } + + /// + /// Configured document analysis policies. + /// + public List Policies { get; set; } = []; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/DataDocumentAnalysisPolicy.cs b/app/MindWork AI Studio/Settings/DataModel/DataDocumentAnalysisPolicy.cs new file mode 100644 index 00000000..a71a1478 --- /dev/null +++ b/app/MindWork AI Studio/Settings/DataModel/DataDocumentAnalysisPolicy.cs @@ -0,0 +1,47 @@ +using AIStudio.Provider; + +namespace AIStudio.Settings.DataModel; + +public sealed class DataDocumentAnalysisPolicy +{ + /// + /// Preselect the policy name? + /// + public string PolicyName { get; set; } = string.Empty; + + /// + /// Preselect the policy description? + /// + public string PolicyDescription { get; set; } = string.Empty; + + /// + /// Is this policy protected? If so, it cannot be deleted or modified by the user. + /// This is useful for policies that are distributed by the organization. + /// + public bool IsProtected { get; set; } + + /// + /// The rules for the document analysis policy. + /// + public string AnalysisRules { get; set; } = string.Empty; + + /// + /// The rules for the output of the document analysis, e.g., the desired format, structure, etc. + /// + public string OutputRules { get; set; } = string.Empty; + + /// + /// The minimum confidence level required for a provider to be considered. + /// + public ConfidenceLevel MinimumProviderConfidence { get; set; } = ConfidenceLevel.NONE; + + /// + /// Which LLM provider should be preselected? + /// + public string PreselectedProvider { get; set; } = string.Empty; + + /// + /// Preselect a profile? + /// + public string PreselectedProfile { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/PreviewFeatures.cs b/app/MindWork AI Studio/Settings/DataModel/PreviewFeatures.cs index 85acedec..49aad8d0 100644 --- a/app/MindWork AI Studio/Settings/DataModel/PreviewFeatures.cs +++ b/app/MindWork AI Studio/Settings/DataModel/PreviewFeatures.cs @@ -11,4 +11,5 @@ public enum PreviewFeatures PRE_PLUGINS_2025, PRE_READ_PDF_2025, + PRE_DOCUMENT_ANALYSIS_2025, } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/PreviewFeaturesExtensions.cs b/app/MindWork AI Studio/Settings/DataModel/PreviewFeaturesExtensions.cs index 3736dd80..e80495b2 100644 --- a/app/MindWork AI Studio/Settings/DataModel/PreviewFeaturesExtensions.cs +++ b/app/MindWork AI Studio/Settings/DataModel/PreviewFeaturesExtensions.cs @@ -13,6 +13,7 @@ public static class PreviewFeaturesExtensions PreviewFeatures.PRE_PLUGINS_2025 => TB("Plugins: Preview of our plugin system where you can extend the functionality of the app"), PreviewFeatures.PRE_READ_PDF_2025 => TB("Read PDF: Preview of our PDF reading system where you can read and extract text from PDF files"), + PreviewFeatures.PRE_DOCUMENT_ANALYSIS_2025 => TB("Document Analysis: Preview of our document analysis system where you can analyze and extract information from documents"), _ => TB("Unknown preview feature") }; diff --git a/app/MindWork AI Studio/Settings/DataModel/PreviewVisibilityExtensions.cs b/app/MindWork AI Studio/Settings/DataModel/PreviewVisibilityExtensions.cs index f80939f6..bd648b24 100644 --- a/app/MindWork AI Studio/Settings/DataModel/PreviewVisibilityExtensions.cs +++ b/app/MindWork AI Studio/Settings/DataModel/PreviewVisibilityExtensions.cs @@ -20,6 +20,7 @@ public static class PreviewVisibilityExtensions if (visibility >= PreviewVisibility.PROTOTYPE) { features.Add(PreviewFeatures.PRE_RAG_2024); + features.Add(PreviewFeatures.PRE_DOCUMENT_ANALYSIS_2025); } if (visibility >= PreviewVisibility.EXPERIMENTAL) diff --git a/app/MindWork AI Studio/Tools/Components.cs b/app/MindWork AI Studio/Tools/Components.cs index 94148d5e..1004188c 100644 --- a/app/MindWork AI Studio/Tools/Components.cs +++ b/app/MindWork AI Studio/Tools/Components.cs @@ -18,6 +18,7 @@ public enum Components JOB_POSTING_ASSISTANT, BIAS_DAY_ASSISTANT, ERI_ASSISTANT, + DOCUMENT_ANALYSIS_ASSISTANT, // ReSharper disable InconsistentNaming I18N_ASSISTANT,