Allow to manage multiple ERI server configurations

This commit is contained in:
Thorsten Sommer 2024-12-28 14:35:11 +01:00
parent ff8eb071b9
commit ece0788842
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
4 changed files with 344 additions and 201 deletions

View File

@ -1,4 +1,5 @@
@attribute [Route(Routes.ASSISTANT_ERI)]
@using AIStudio.Settings.DataModel
@using MudExtensions
@inherits AssistantBaseCore
@ -21,7 +22,50 @@
<div class="mb-6"></div>
<MudText Typo="Typo.h4" Class="mb-3">
Auto Save
ERI server presets
</MudText>
<MudText Typo="Typo.body1" Class="mb-3">
Here you have the option to save different configurations for various ERI servers and switch between them. This is useful if
you are responsible for multiple ERI servers.
</MudText>
@if(this.SettingsManager.ConfigurationData.ERI.ERIServers.Count is 0)
{
<MudText Typo="Typo.body1" Class="mb-3">
You have not yet added any ERI server presets.
</MudText>
}
else
{
<MudList Disabled="@this.AreServerPresetsBlocked" T="DataERIServer" Class="mb-1" SelectedValue="@this.selectedERIServer" SelectedValueChanged="@this.SelectedERIServerChanged">
@foreach (var server in this.SettingsManager.ConfigurationData.ERI.ERIServers)
{
<MudListItem T="DataERIServer" Icon="@Icons.Material.Filled.Settings" Value="@server">
@server.ServerName
</MudListItem>
}
</MudList>
}
<MudStack Row="@true" Class="mt-1">
<MudButton Disabled="@this.AreServerPresetsBlocked" OnClick="@this.AddERIServer" Variant="Variant.Filled" Color="Color.Primary">
Add ERI server preset
</MudButton>
<MudButton OnClick="@this.RemoveERIServer" Disabled="@(this.AreServerPresetsBlocked || this.IsNoneERIServerSelected)" Variant="Variant.Filled" Color="Color.Primary">
Delete this server preset
</MudButton>
</MudStack>
@if(this.AreServerPresetsBlocked)
{
<MudText Typo="Typo.body1" Class="mb-3 mt-3">
Hint: to allow this assistant to manage multiple presets, you must enable the preselection of values in the settings.
</MudText>
}
<MudText Typo="Typo.h4" Class="mb-3 mt-6">
Auto save
</MudText>
<MudText Typo="Typo.body1" Class="mb-3">
@ -30,23 +74,25 @@
automatically saved. Would you like this?
</MudText>
@if(!this.SettingsManager.ConfigurationData.ERI.PreselectOptions)
@if(this.AreServerPresetsBlocked)
{
<MudText Typo="Typo.body1" Class="mb-3">
Hint: to allow this assistant to automatically save your changes, you must enable the preselection of values in the settings.
</MudText>
}
<MudTextSwitch Label="Should we automatically save any input made?" Disabled="@(!this.SettingsManager.ConfigurationData.ERI.PreselectOptions)" @bind-Value="@this.autoSave" LabelOn="Yes, please save my inputs" LabelOff="No, I will enter everything again or configure it manually in the settings" />
<MudTextSwitch Label="Should we automatically save any input made?" Disabled="@this.AreServerPresetsBlocked" @bind-Value="@this.autoSave" LabelOn="Yes, please save my inputs" LabelOff="No, I will enter everything again or configure it manually in the settings" />
<hr style="width: 100%; border-width: 0.25ch;" class="mt-6"/>
<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"/>
<MudTextField T="string" @bind-Text="@this.serverDescription" Validation="@this.ValidateServerDescription" Immediate="@true" Label="ERI server description" HelperText="Please provide a brief description of your ERI server. Describe or explain what your ERI server does and what data it uses for this purpose. This description will be shown to users in AI Studio." Counter="512" MaxLength="512" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
<MudTextField T="string" Disabled="@this.IsNoneERIServerSelected" @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" OnKeyUp="() => this.ServerNameWasChanged()"/>
<MudTextField T="string" Disabled="@this.IsNoneERIServerSelected" @bind-Text="@this.serverDescription" Validation="@this.ValidateServerDescription" Immediate="@true" Label="ERI server description" HelperText="Please provide a brief description of your ERI server. Describe or explain what your ERI server does and what data it uses for this purpose. This description will be shown to users in AI Studio." Counter="512" MaxLength="512" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
<MudStack Row="@true" Class="mb-3">
<MudSelect T="ProgrammingLanguages" @bind-Value="@this.selectedProgrammingLanguage" AdornmentIcon="@Icons.Material.Filled.Code" Adornment="Adornment.Start" Label="Programming language" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateProgrammingLanguage">
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="ProgrammingLanguages" @bind-Value="@this.selectedProgrammingLanguage" AdornmentIcon="@Icons.Material.Filled.Code" Adornment="Adornment.Start" Label="Programming language" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateProgrammingLanguage">
@foreach (var language in Enum.GetValues<ProgrammingLanguages>())
{
<MudSelectItem Value="@language">@language.Name()</MudSelectItem>
@ -54,18 +100,18 @@
</MudSelect>
@if (this.selectedProgrammingLanguage is ProgrammingLanguages.OTHER)
{
<MudTextField T="string" @bind-Text="@this.otherProgrammingLanguage" Validation="@this.ValidateOtherLanguage" Label="Other language" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.otherProgrammingLanguage" Validation="@this.ValidateOtherLanguage" Label="Other language" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
}
</MudStack>
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3">
<MudSelect T="ERIVersion" @bind-Value="@this.selectedERIVersion" Label="ERI specification version" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateERIVersion">
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="ERIVersion" @bind-Value="@this.selectedERIVersion" Label="ERI specification version" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateERIVersion">
@foreach (var version in Enum.GetValues<ERIVersion>())
{
<MudSelectItem Value="@version">@version</MudSelectItem>
}
</MudSelect>
<MudButton Variant="Variant.Outlined" Size="Size.Small" Disabled="@(!this.selectedERIVersion.WasSpecificationSelected())" Href="@this.selectedERIVersion.SpecificationURL()" Target="_blank">
<MudButton Variant="Variant.Outlined" Size="Size.Small" Disabled="@(!this.selectedERIVersion.WasSpecificationSelected() || this.IsNoneERIServerSelected)" Href="@this.selectedERIVersion.SpecificationURL()" Target="_blank">
<MudIcon Icon="@Icons.Material.Filled.Link" Class="mr-2"/> Download specification
</MudButton>
</MudStack>
@ -75,7 +121,7 @@
</MudText>
<MudStack Row="@false" Spacing="1" Class="mb-3">
<MudSelect T="DataSources" @bind-Value="@this.selectedDataSource" AdornmentIcon="@Icons.Material.Filled.Dataset" Adornment="Adornment.Start" Label="Data source" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateDataSource" SelectedValuesChanged="@this.DataSourceWasChanged">
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="DataSources" @bind-Value="@this.selectedDataSource" AdornmentIcon="@Icons.Material.Filled.Dataset" Adornment="Adornment.Start" Label="Data source" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateDataSource" SelectedValuesChanged="@this.DataSourceWasChanged">
@foreach (var dataSource in Enum.GetValues<DataSources>())
{
<MudSelectItem Value="@dataSource">@dataSource.Name()</MudSelectItem>
@ -83,21 +129,21 @@
</MudSelect>
@if (this.selectedDataSource is DataSources.CUSTOM)
{
<MudTextField T="string" @bind-Text="@this.otherDataSource" Validation="@this.ValidateOtherDataSource" Label="Describe your data source" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.otherDataSource" Validation="@this.ValidateOtherDataSource" Label="Describe your data source" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
}
</MudStack>
@if(this.selectedDataSource > DataSources.FILE_SYSTEM)
{
<MudTextField T="string" @bind-Text="@this.dataSourceProductName" Label="Data source: product name" Validation="@this.ValidateDataSourceProductName" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.dataSourceProductName" Label="Data source: product name" Validation="@this.ValidateDataSourceProductName" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
}
@if (this.NeedHostnamePort())
{
<div class="mb-3">
<MudStack Row="@true">
<MudTextField T="string" @bind-Text="@this.dataSourceHostname" Label="Data source: hostname" Validation="@this.ValidateHostname" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
<MudNumericField Label="Data source: port" Immediate="@true" Min="1" Max="65535" Validation="@this.ValidatePort" @bind-Value="@this.dataSourcePort" Variant="Variant.Outlined" Margin="Margin.Dense" OnKeyUp="@(() => this.DataSourcePortWasTyped())"/>
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.dataSourceHostname" Label="Data source: hostname" Validation="@this.ValidateHostname" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
<MudNumericField Disabled="@this.IsNoneERIServerSelected" Label="Data source: port" Immediate="@true" Min="1" Max="65535" Validation="@this.ValidatePort" @bind-Value="@this.dataSourcePort" Variant="Variant.Outlined" Margin="Margin.Dense" OnKeyUp="() => this.DataSourcePortWasTyped()"/>
</MudStack>
@if (this.dataSourcePort < 1024)
{
@ -115,6 +161,7 @@
<MudStack Row="@false" Spacing="1" Class="mb-1">
<MudSelectExtended
T="Auth"
Disabled="@this.IsNoneERIServerSelected"
ShrinkLabel="@true"
MultiSelection="@true"
MultiSelectionTextFunc="@this.GetMultiSelectionAuthText"
@ -129,12 +176,12 @@
<MudSelectItemExtended Value="@authMethod">@authMethod.Name()</MudSelectItemExtended>
}
</MudSelectExtended>
<MudTextField T="string" @bind-Text="@this.authDescription" Label="@this.AuthDescriptionTitle()" Validation="@this.ValidateAuthDescription" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.authDescription" Label="@this.AuthDescriptionTitle()" Validation="@this.ValidateAuthDescription" Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="6" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
</MudStack>
@if (this.selectedAuthenticationMethods.Contains(Auth.KERBEROS))
{
<MudSelect T="OperatingSystem" @bind-Value="@this.selectedOperatingSystem" Label="Operating system on which your ERI will run" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateOperatingSystem" Class="mb-1">
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="OperatingSystem" @bind-Value="@this.selectedOperatingSystem" Label="Operating system on which your ERI will run" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateOperatingSystem" Class="mb-1">
@foreach (var os in Enum.GetValues<OperatingSystem>())
{
<MudSelectItem Value="@os">@os.Name()</MudSelectItem>
@ -146,7 +193,7 @@
Data protection settings
</MudText>
<MudSelect T="AllowedLLMProviders" @bind-Value="@this.allowedLLMProviders" Label="Allowed LLM providers for this data source" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateAllowedLLMProviders" Class="mb-1">
<MudSelect Disabled="@this.IsNoneERIServerSelected" T="AllowedLLMProviders" @bind-Value="@this.allowedLLMProviders" Label="Allowed LLM providers for this data source" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateAllowedLLMProviders" Class="mb-1">
@foreach (var option in Enum.GetValues<AllowedLLMProviders>())
{
<MudSelectItem Value="@option">@option.Name()</MudSelectItem>
@ -170,37 +217,40 @@
or data types. For example, one embedding for texts, another for images, and a third for videos, etc.
</MudText>
<MudTable Items="@this.embeddings" Hover="@true" Class="border-dashed border rounded-lg">
<ColGroup>
<col/>
<col style="width: 34em;"/>
<col style="width: 34em;"/>
</ColGroup>
<HeaderContent>
<MudTh>Name</MudTh>
<MudTh>Type</MudTh>
<MudTh Style="text-align: left;">Actions</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>@context.EmbeddingName</MudTd>
<MudTd>@context.EmbeddingType</MudTd>
<MudTd Style="text-align: left;">
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditEmbedding(context)">
Edit
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="ma-2" OnClick="() => this.DeleteEmbedding(context)">
Delete
</MudButton>
</MudTd>
</RowTemplate>
</MudTable>
@if(this.embeddings.Count == 0)
@if (!this.IsNoneERIServerSelected)
{
<MudText Typo="Typo.h6" Class="mt-3">No embedding methods configured yet.</MudText>
<MudTable Items="@this.embeddings" Hover="@true" Class="border-dashed border rounded-lg">
<ColGroup>
<col/>
<col style="width: 34em;"/>
<col style="width: 34em;"/>
</ColGroup>
<HeaderContent>
<MudTh>Name</MudTh>
<MudTh>Type</MudTh>
<MudTh Style="text-align: left;">Actions</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>@context.EmbeddingName</MudTd>
<MudTd>@context.EmbeddingType</MudTd>
<MudTd Style="text-align: left;">
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditEmbedding(context)">
Edit
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="ma-2" OnClick="() => this.DeleteEmbedding(context)">
Delete
</MudButton>
</MudTd>
</RowTemplate>
</MudTable>
@if (this.embeddings.Count == 0)
{
<MudText Typo="Typo.h6" Class="mt-3">No embedding methods configured yet.</MudText>
}
}
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddEmbedding">
<MudButton Disabled="@this.IsNoneERIServerSelected" Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddEmbedding">
Add Embedding Method
</MudButton>
@ -215,34 +265,37 @@
the process that best suits their circumstances.
</MudText>
<MudTable Items="@this.retrievalProcesses" Hover="@true" Class="border-dashed border rounded-lg">
<ColGroup>
<col/>
<col style="width: 34em;"/>
</ColGroup>
<HeaderContent>
<MudTh>Name</MudTh>
<MudTh Style="text-align: left;">Actions</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>@context.Name</MudTd>
<MudTd Style="text-align: left;">
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditRetrievalProcess(context)">
Edit
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="ma-2" OnClick="() => this.DeleteRetrievalProcess(context)">
Delete
</MudButton>
</MudTd>
</RowTemplate>
</MudTable>
@if(this.retrievalProcesses.Count == 0)
@if (!this.IsNoneERIServerSelected)
{
<MudText Typo="Typo.h6" Class="mt-3">No retrieval process configured yet.</MudText>
<MudTable Items="@this.retrievalProcesses" Hover="@true" Class="border-dashed border rounded-lg">
<ColGroup>
<col/>
<col style="width: 34em;"/>
</ColGroup>
<HeaderContent>
<MudTh>Name</MudTh>
<MudTh Style="text-align: left;">Actions</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>@context.Name</MudTd>
<MudTd Style="text-align: left;">
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditRetrievalProcess(context)">
Edit
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="ma-2" OnClick="() => this.DeleteRetrievalProcess(context)">
Delete
</MudButton>
</MudTd>
</RowTemplate>
</MudTable>
@if (this.retrievalProcesses.Count == 0)
{
<MudText Typo="Typo.h6" Class="mt-3">No retrieval process configured yet.</MudText>
}
}
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddRetrievalProcess">
<MudButton Disabled="@this.IsNoneERIServerSelected" Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddRetrievalProcess">
Add Retrieval Process
</MudButton>
@ -254,7 +307,7 @@
the intended use. The LLM can then attempt to choose suitable libraries. However, hallucinations can occur, and fictional libraries might be selected.
</MudText>
<MudTextField T="string" @bind-Text="@this.additionalLibraries" Label="(Optional) Additional libraries" HelperText="Do you want to include additional libraries? Then name them and briefly describe what you want to achieve with them." Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="12" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
<MudTextField Disabled="@this.IsNoneERIServerSelected" T="string" @bind-Text="@this.additionalLibraries" Label="(Optional) Additional libraries" HelperText="Do you want to include additional libraries? Then name them and briefly describe what you want to achieve with them." Variant="Variant.Outlined" Margin="Margin.Normal" Lines="3" AutoGrow="@true" MaxLines="12" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
<MudText Typo="Typo.h4" Class="mt-9 mb-1">
Provider selection for generation

View File

@ -1,5 +1,6 @@
using AIStudio.Chat;
using AIStudio.Dialogs;
using AIStudio.Settings.DataModel;
using Microsoft.AspNetCore.Components;
@ -39,6 +40,8 @@ public partial class AssistantERI : AssistantBaseCore
protected override Func<Task> SubmitAction => this.GenerateServer;
protected override bool SubmitDisabled => this.IsNoneERIServerSelected;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
@ -72,29 +75,29 @@ public partial class AssistantERI : AssistantBaseCore
protected override bool MightPreselectValues()
{
this.autoSave = this.SettingsManager.ConfigurationData.ERI.AutoSaveChanges;
if (this.SettingsManager.ConfigurationData.ERI.PreselectOptions)
if (this.SettingsManager.ConfigurationData.ERI.PreselectOptions && this.selectedERIServer is not null)
{
this.serverName = this.SettingsManager.ConfigurationData.ERI.PreselectedServerName;
this.serverDescription = this.SettingsManager.ConfigurationData.ERI.PreselectedServerDescription;
this.selectedERIVersion = this.SettingsManager.ConfigurationData.ERI.PreselectedERIVersion;
this.selectedProgrammingLanguage = this.SettingsManager.ConfigurationData.ERI.PreselectedProgrammingLanguage;
this.otherProgrammingLanguage = this.SettingsManager.ConfigurationData.ERI.PreselectedOtherProgrammingLanguage;
this.selectedDataSource = this.SettingsManager.ConfigurationData.ERI.PreselectedDataSource;
this.dataSourceProductName = this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourceProductName;
this.otherDataSource = this.SettingsManager.ConfigurationData.ERI.PreselectedOtherDataSource;
this.dataSourceHostname = this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourceHostname;
this.dataSourcePort = this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourcePort;
this.userTypedPort = this.SettingsManager.ConfigurationData.ERI.UserTypedPort;
this.serverName = this.selectedERIServer.ServerName;
this.serverDescription = this.selectedERIServer.ServerDescription;
this.selectedERIVersion = this.selectedERIServer.ERIVersion;
this.selectedProgrammingLanguage = this.selectedERIServer.ProgrammingLanguage;
this.otherProgrammingLanguage = this.selectedERIServer.OtherProgrammingLanguage;
this.selectedDataSource = this.selectedERIServer.DataSource;
this.dataSourceProductName = this.selectedERIServer.DataSourceProductName;
this.otherDataSource = this.selectedERIServer.OtherDataSource;
this.dataSourceHostname = this.selectedERIServer.DataSourceHostname;
this.dataSourcePort = this.selectedERIServer.DataSourcePort;
this.userTypedPort = this.selectedERIServer.UserTypedPort;
var authMethods = new HashSet<Auth>(this.SettingsManager.ConfigurationData.ERI.PreselectedAuthMethods);
var authMethods = new HashSet<Auth>(this.selectedERIServer.AuthMethods);
this.selectedAuthenticationMethods = authMethods;
this.authDescription = this.SettingsManager.ConfigurationData.ERI.PreselectedAuthDescription;
this.selectedOperatingSystem = this.SettingsManager.ConfigurationData.ERI.PreselectedOperatingSystem;
this.allowedLLMProviders = this.SettingsManager.ConfigurationData.ERI.PreselectedAllowedLLMProviders;
this.embeddings = this.SettingsManager.ConfigurationData.ERI.PreselectedEmbeddingInfos;
this.retrievalProcesses = this.SettingsManager.ConfigurationData.ERI.PreselectedRetrievalInfos;
this.additionalLibraries = this.SettingsManager.ConfigurationData.ERI.PreselectedAdditionalLibraries;
this.authDescription = this.selectedERIServer.AuthDescription;
this.selectedOperatingSystem = this.selectedERIServer.OperatingSystem;
this.allowedLLMProviders = this.selectedERIServer.AllowedLLMProviders;
this.embeddings = this.selectedERIServer.EmbeddingInfos;
this.retrievalProcesses = this.selectedERIServer.RetrievalInfos;
this.additionalLibraries = this.selectedERIServer.AdditionalLibraries;
return true;
}
@ -106,32 +109,52 @@ public partial class AssistantERI : AssistantBaseCore
await this.AutoSave();
}
#region Overrides of AssistantBase
protected override async Task OnInitializedAsync()
{
this.selectedERIServer = this.SettingsManager.ConfigurationData.ERI.ERIServers.FirstOrDefault();
if(this.selectedERIServer is null)
{
await this.AddERIServer();
this.selectedERIServer = this.SettingsManager.ConfigurationData.ERI.ERIServers.First();
}
await base.OnInitializedAsync();
}
#endregion
private async Task AutoSave()
{
if(!this.autoSave || !this.SettingsManager.ConfigurationData.ERI.PreselectOptions)
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.UserTypedPort = this.userTypedPort;
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.PreselectedEmbeddingInfos = this.embeddings;
this.SettingsManager.ConfigurationData.ERI.PreselectedRetrievalInfos = this.retrievalProcesses;
this.SettingsManager.ConfigurationData.ERI.PreselectedAdditionalLibraries = this.additionalLibraries;
if(this.selectedERIServer is null)
return;
this.selectedERIServer.ServerName = this.serverName;
this.selectedERIServer.ServerDescription = this.serverDescription;
this.selectedERIServer.ERIVersion = this.selectedERIVersion;
this.selectedERIServer.ProgrammingLanguage = this.selectedProgrammingLanguage;
this.selectedERIServer.OtherProgrammingLanguage = this.otherProgrammingLanguage;
this.selectedERIServer.DataSource = this.selectedDataSource;
this.selectedERIServer.DataSourceProductName = this.dataSourceProductName;
this.selectedERIServer.OtherDataSource = this.otherDataSource;
this.selectedERIServer.DataSourceHostname = this.dataSourceHostname;
this.selectedERIServer.DataSourcePort = this.dataSourcePort;
this.selectedERIServer.UserTypedPort = this.userTypedPort;
this.selectedERIServer.AuthMethods = [..this.selectedAuthenticationMethods];
this.selectedERIServer.AuthDescription = this.authDescription;
this.selectedERIServer.OperatingSystem = this.selectedOperatingSystem;
this.selectedERIServer.AllowedLLMProviders = this.allowedLLMProviders;
this.selectedERIServer.EmbeddingInfos = this.embeddings;
this.selectedERIServer.RetrievalInfos = this.retrievalProcesses;
this.selectedERIServer.AdditionalLibraries = this.additionalLibraries;
await this.SettingsManager.StoreSettings();
}
private DataERIServer? selectedERIServer;
private bool autoSave;
private string serverName = string.Empty;
private string serverDescription = string.Empty;
@ -152,6 +175,54 @@ public partial class AssistantERI : AssistantBaseCore
private List<RetrievalInfo> retrievalProcesses = new();
private string additionalLibraries = string.Empty;
private bool AreServerPresetsBlocked => !this.SettingsManager.ConfigurationData.ERI.PreselectOptions;
private void SelectedERIServerChanged(DataERIServer? server)
{
this.selectedERIServer = server;
this.ResetForm();
}
private async Task AddERIServer()
{
this.SettingsManager.ConfigurationData.ERI.ERIServers.Add(new ()
{
ServerName = $"ERI Server {DateTimeOffset.UtcNow}",
});
await this.SettingsManager.StoreSettings();
}
private async Task RemoveERIServer()
{
if(this.selectedERIServer is null)
return;
this.SettingsManager.ConfigurationData.ERI.ERIServers.Remove(this.selectedERIServer);
this.selectedERIServer = null;
this.ResetForm();
await this.SettingsManager.StoreSettings();
this.form?.ResetValidation();
}
private bool IsNoneERIServerSelected => this.selectedERIServer is null;
/// <summary>
/// Gets called when the server name was changed by typing.
/// </summary>
/// <remarks>
/// This method is used to update the server name in the selected ERI server preset.
/// Otherwise, the users would be confused when they change the server name and the changes are not reflected in the UI.
/// </remarks>
private void ServerNameWasChanged()
{
if(this.selectedERIServer is null)
return;
this.selectedERIServer.ServerName = this.serverName;
}
private string? ValidateServerName(string name)
{
if(string.IsNullOrWhiteSpace(name))
@ -160,6 +231,9 @@ public partial class AssistantERI : AssistantBaseCore
if(name.Length is > 60 or < 6)
return "The name of your ERI server must be between 6 and 60 characters long.";
if(this.SettingsManager.ConfigurationData.ERI.ERIServers.Where(n => n != this.selectedERIServer).Any(n => n.ServerName == name))
return "An ERI server preset with this name already exists. Please choose a different name.";
return null;
}
@ -280,9 +354,12 @@ public partial class AssistantERI : AssistantBaseCore
private void DataSourceWasChanged()
{
if(this.selectedERIServer is null)
return;
if (this.selectedDataSource is DataSources.NONE)
{
this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourcePort = null;
this.selectedERIServer.DataSourcePort = null;
this.dataSourcePort = null;
this.userTypedPort = false;
return;
@ -537,6 +614,9 @@ public partial class AssistantERI : AssistantBaseCore
private async Task GenerateServer()
{
if(this.IsNoneERIServerSelected)
return;
await this.AutoSave();
await this.form!.Validate();
if (!this.inputIsValid)

View File

@ -1,8 +1,5 @@
using AIStudio.Assistants.ERI;
using AIStudio.Provider;
using OperatingSystem = AIStudio.Assistants.ERI.OperatingSystem;
namespace AIStudio.Settings.DataModel;
public sealed class DataERI
@ -18,94 +15,9 @@ public sealed class DataERI
public bool PreselectOptions { get; set; } = true;
/// <summary>
/// Preselect the server name?
/// Data for the ERI servers.
/// </summary>
public string PreselectedServerName { get; set; } = string.Empty;
/// <summary>
/// Preselect the server description?
/// </summary>
public string PreselectedServerDescription { get; set; } = string.Empty;
/// <summary>
/// Preselect the ERI version?
/// </summary>
public ERIVersion PreselectedERIVersion { get; set; } = ERIVersion.NONE;
/// <summary>
/// Preselect the language for implementing the ERI?
/// </summary>
public ProgrammingLanguages PreselectedProgrammingLanguage { get; set; }
/// <summary>
/// Do you want to preselect any other language?
/// </summary>
public string PreselectedOtherProgrammingLanguage { get; set; } = string.Empty;
/// <summary>
/// Preselect a data source?
/// </summary>
public DataSources PreselectedDataSource { get; set; }
/// <summary>
/// Do you want to preselect a product name for the data source?
/// </summary>
public string PreselectedDataSourceProductName { get; set; } = string.Empty;
/// <summary>
/// Do you want to preselect any other data source?
/// </summary>
public string PreselectedOtherDataSource { get; set; } = string.Empty;
/// <summary>
/// Do you want to preselect a hostname for the data source?
/// </summary>
public string PreselectedDataSourceHostname { get; set; } = string.Empty;
/// <summary>
/// Do you want to preselect a port for the data source?
/// </summary>
public int? PreselectedDataSourcePort { get; set; }
/// <summary>
/// Did the user type the port number?
/// </summary>
public bool UserTypedPort { get; set; } = false;
/// <summary>
/// Preselect any authentication methods?
/// </summary>
public HashSet<Auth> PreselectedAuthMethods { get; set; } = [];
/// <summary>
/// Do you want to preselect any authentication description?
/// </summary>
public string PreselectedAuthDescription { get; set; } = string.Empty;
/// <summary>
/// Do you want to preselect an operating system? This is necessary when SSO with Kerberos is used.
/// </summary>
public OperatingSystem PreselectedOperatingSystem { get; set; } = OperatingSystem.NONE;
/// <summary>
/// Do you want to preselect which LLM providers are allowed?
/// </summary>
public AllowedLLMProviders PreselectedAllowedLLMProviders { get; set; } = AllowedLLMProviders.NONE;
/// <summary>
/// Do you want to predefine any embedding information?
/// </summary>
public List<EmbeddingInfo> PreselectedEmbeddingInfos { get; set; } = new();
/// <summary>
/// Do you want to predefine any retrieval information?
/// </summary>
public List<RetrievalInfo> PreselectedRetrievalInfos { get; set; } = new();
/// <summary>
/// Do you want to preselect any additional libraries?
/// </summary>
public string PreselectedAdditionalLibraries { get; set; } = string.Empty;
public List<DataERIServer> ERIServers { get; set; } = new();
/// <summary>
/// The minimum confidence level required for a provider to be considered.

View File

@ -0,0 +1,98 @@
using AIStudio.Assistants.ERI;
using OperatingSystem = AIStudio.Assistants.ERI.OperatingSystem;
namespace AIStudio.Settings.DataModel;
public sealed class DataERIServer
{
/// <summary>
/// Preselect the server name?
/// </summary>
public string ServerName { get; set; } = string.Empty;
/// <summary>
/// Preselect the server description?
/// </summary>
public string ServerDescription { get; set; } = string.Empty;
/// <summary>
/// Preselect the ERI version?
/// </summary>
public ERIVersion ERIVersion { get; set; } = ERIVersion.NONE;
/// <summary>
/// Preselect the language for implementing the ERI?
/// </summary>
public ProgrammingLanguages ProgrammingLanguage { get; set; }
/// <summary>
/// Do you want to preselect any other language?
/// </summary>
public string OtherProgrammingLanguage { get; set; } = string.Empty;
/// <summary>
/// Preselect a data source?
/// </summary>
public DataSources DataSource { get; set; }
/// <summary>
/// Do you want to preselect a product name for the data source?
/// </summary>
public string DataSourceProductName { get; set; } = string.Empty;
/// <summary>
/// Do you want to preselect any other data source?
/// </summary>
public string OtherDataSource { get; set; } = string.Empty;
/// <summary>
/// Do you want to preselect a hostname for the data source?
/// </summary>
public string DataSourceHostname { get; set; } = string.Empty;
/// <summary>
/// Do you want to preselect a port for the data source?
/// </summary>
public int? DataSourcePort { get; set; }
/// <summary>
/// Did the user type the port number?
/// </summary>
public bool UserTypedPort { get; set; } = false;
/// <summary>
/// Preselect any authentication methods?
/// </summary>
public HashSet<Auth> AuthMethods { get; set; } = [];
/// <summary>
/// Do you want to preselect any authentication description?
/// </summary>
public string AuthDescription { get; set; } = string.Empty;
/// <summary>
/// Do you want to preselect an operating system? This is necessary when SSO with Kerberos is used.
/// </summary>
public OperatingSystem OperatingSystem { get; set; } = OperatingSystem.NONE;
/// <summary>
/// Do you want to preselect which LLM providers are allowed?
/// </summary>
public AllowedLLMProviders AllowedLLMProviders { get; set; } = AllowedLLMProviders.NONE;
/// <summary>
/// Do you want to predefine any embedding information?
/// </summary>
public List<EmbeddingInfo> EmbeddingInfos { get; set; } = new();
/// <summary>
/// Do you want to predefine any retrieval information?
/// </summary>
public List<RetrievalInfo> RetrievalInfos { get; set; } = new();
/// <summary>
/// Do you want to preselect any additional libraries?
/// </summary>
public string AdditionalLibraries { get; set; } = string.Empty;
}