From 720c530e2838622c066dfa8d78130ebe78909ac3 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Thu, 19 Dec 2024 11:51:38 +0100 Subject: [PATCH] Added an auto-save option --- .../Assistants/ERI/AssistantERI.razor | 14 +++++++- .../Assistants/ERI/AssistantERI.razor.cs | 36 ++++++++++++++++++- .../Settings/DataModel/DataERI.cs | 7 +++- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor b/app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor index a39d973b..9b8fc5b9 100644 --- a/app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor +++ b/app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor @@ -20,7 +20,19 @@
- + + Auto Save + + + + The ERI specification will change over time. You probably want to keep your ERI server up to date. This means you might want to + regenerate the code for your ERI server. To avoid having to make all inputs each time, all your inputs and decisions can be + automatically saved. Would you like this? + + + + + Common ERI server settings diff --git a/app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor.cs b/app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor.cs index 1b0ff5a3..1b1107a2 100644 --- a/app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor.cs +++ b/app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor.cs @@ -63,6 +63,7 @@ public partial class AssistantERI : AssistantBaseCore protected override bool MightPreselectValues() { + this.autoSave = this.SettingsManager.ConfigurationData.ERI.AutoSaveChanges; if (this.SettingsManager.ConfigurationData.ERI.PreselectOptions) { this.serverName = this.SettingsManager.ConfigurationData.ERI.PreselectedServerName; @@ -90,6 +91,36 @@ public partial class AssistantERI : AssistantBaseCore return false; } + protected override async Task OnFormChange() + { + await this.AutoSave(); + } + + private async Task AutoSave() + { + if(!this.autoSave) + return; + + this.SettingsManager.ConfigurationData.ERI.PreselectedServerName = this.serverName; + this.SettingsManager.ConfigurationData.ERI.PreselectedServerDescription = this.serverDescription; + this.SettingsManager.ConfigurationData.ERI.PreselectedERIVersion = this.selectedERIVersion; + this.SettingsManager.ConfigurationData.ERI.PreselectedProgrammingLanguage = this.selectedProgrammingLanguage; + this.SettingsManager.ConfigurationData.ERI.PreselectedOtherProgrammingLanguage = this.otherProgrammingLanguage; + this.SettingsManager.ConfigurationData.ERI.PreselectedDataSource = this.selectedDataSource; + this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourceProductName = this.dataSourceProductName; + this.SettingsManager.ConfigurationData.ERI.PreselectedOtherDataSource = this.otherDataSource; + this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourceHostname = this.dataSourceHostname; + this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourcePort = this.dataSourcePort; + this.SettingsManager.ConfigurationData.ERI.PreselectedAuthMethods = [..this.selectedAuthenticationMethods]; + this.SettingsManager.ConfigurationData.ERI.PreselectedAuthDescription = this.authDescription; + this.SettingsManager.ConfigurationData.ERI.PreselectedOperatingSystem = this.selectedOperatingSystem; + this.SettingsManager.ConfigurationData.ERI.PreselectedAllowedLLMProviders = this.allowedLLMProviders; + this.SettingsManager.ConfigurationData.ERI.PreselectedRetrievalDescription = this.retrievalDescription; + this.SettingsManager.ConfigurationData.ERI.PreselectedAdditionalLibraries = this.additionalLibraries; + await this.SettingsManager.StoreSettings(); + } + + private bool autoSave; private string serverName = string.Empty; private string serverDescription = string.Empty; private ERIVersion selectedERIVersion = ERIVersion.V1; @@ -303,7 +334,9 @@ public partial class AssistantERI : AssistantBaseCore private bool IsAuthDescriptionOptional() { - var authenticationMethods = (this.selectedAuthenticationMethods as HashSet)!; + if (this.selectedAuthenticationMethods is not HashSet authenticationMethods) + return true; + if(authenticationMethods.Count > 1) return false; @@ -359,6 +392,7 @@ public partial class AssistantERI : AssistantBaseCore private async Task GenerateServer() { + await this.AutoSave(); await this.form!.Validate(); if (!this.inputIsValid) return; diff --git a/app/MindWork AI Studio/Settings/DataModel/DataERI.cs b/app/MindWork AI Studio/Settings/DataModel/DataERI.cs index 64e835f5..9e389f4b 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataERI.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataERI.cs @@ -7,10 +7,15 @@ namespace AIStudio.Settings.DataModel; public sealed class DataERI { + /// + /// Should we automatically save any input made in the ERI assistant? + /// + public bool AutoSaveChanges { get; set; } = true; + /// /// Preselect any ERI options? /// - public bool PreselectOptions { get; set; } + public bool PreselectOptions { get; set; } = true; /// /// Preselect the server name?