mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 23:19:47 +00:00
Added an auto-save option
This commit is contained in:
parent
bbc906f4ca
commit
720c530e28
@ -20,7 +20,19 @@
|
||||
<PreviewPrototype/>
|
||||
<div class="mb-6"></div>
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mb-1">
|
||||
<MudText Typo="Typo.h4" Class="mb-3">
|
||||
Auto Save
|
||||
</MudText>
|
||||
|
||||
<MudText Typo="Typo.body1" Class="mb-3">
|
||||
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?
|
||||
</MudText>
|
||||
|
||||
<MudTextSwitch Label="Should we automatically save any input made?" @bind-Value="@this.autoSave" LabelOn="Yes, please save my inputs" LabelOff="No, I will enter everything again or configure it manually in the settings" />
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mt-6 mb-1">
|
||||
Common ERI server settings
|
||||
</MudText>
|
||||
<MudTextField T="string" @bind-Text="@this.serverName" Validation="@this.ValidateServerName" Immediate="@true" Label="ERI server name" HelperText="Please give your ERI server a name that provides information about the data source and/or its intended purpose. The name will be displayed to users in AI Studio." Counter="60" MaxLength="60" Variant="Variant.Outlined" Margin="Margin.Normal" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
|
||||
|
@ -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<Auth>)!;
|
||||
if (this.selectedAuthenticationMethods is not HashSet<Auth> 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;
|
||||
|
@ -7,10 +7,15 @@ namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed class DataERI
|
||||
{
|
||||
/// <summary>
|
||||
/// Should we automatically save any input made in the ERI assistant?
|
||||
/// </summary>
|
||||
public bool AutoSaveChanges { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Preselect any ERI options?
|
||||
/// </summary>
|
||||
public bool PreselectOptions { get; set; }
|
||||
public bool PreselectOptions { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Preselect the server name?
|
||||
|
Loading…
Reference in New Issue
Block a user