Migrated more text data to I18N

This commit is contained in:
Thorsten Sommer 2025-05-18 14:46:11 +02:00
parent 21c1c9b037
commit 9d4506f0a5
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
16 changed files with 220 additions and 216 deletions

View File

@ -1,6 +1,6 @@
@using AIStudio.Settings.DataModel
@using AIStudio.Tools.ERIClient.DataModel
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
@ -8,59 +8,57 @@
Common data source information
</MudText>
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="Data source name" Value="@this.DataSource.Name" ClipboardTooltipSubject="the data source name"/>
<TextInfoLine Icon="@Icons.Material.Filled.NetworkCheck" Label="ERI server hostname" Value="@this.DataSource.Hostname" ClipboardTooltipSubject="the ERI server hostname"/>
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="ERI server port" Value="@this.Port" ClipboardTooltipSubject="the ERI server port"/>
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="@T("Data source name")" Value="@this.DataSource.Name" ClipboardTooltipSubject="@T("the data source name")"/>
<TextInfoLine Icon="@Icons.Material.Filled.NetworkCheck" Label="@T("ERI server hostname")" Value="@this.DataSource.Hostname" ClipboardTooltipSubject="@T("the ERI server hostname")"/>
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="@T("ERI server port")" Value="@this.Port" ClipboardTooltipSubject="@T("the ERI server port")"/>
@if (!this.IsConnectionEncrypted())
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
Please note: the connection to the ERI v1 server is not encrypted. This means that all
data sent to the server is transmitted in plain text. Please ask the ERI server administrator
to enable encryption.
@T("Please note: the connection to the ERI v1 server is not encrypted. This means that all data sent to the server is transmitted in plain text. Please ask the ERI server administrator to enable encryption.")
</MudJustifiedText>
}
@if (this.DataSource.AuthMethod is AuthMethod.USERNAME_PASSWORD)
{
<TextInfoLine Icon="@Icons.Material.Filled.Person2" Label="Username" Value="@this.DataSource.Username" ClipboardTooltipSubject="the username"/>
<TextInfoLine Icon="@Icons.Material.Filled.Person2" Label="@T("Username")" Value="@this.DataSource.Username" ClipboardTooltipSubject="@T("the username")"/>
}
<TextInfoLines Label="Server description" MaxLines="14" Value="@this.serverDescription" ClipboardTooltipSubject="the server description"/>
<TextInfoLines Label="Security requirements of the data provider" MaxLines="3" Value="@this.securityRequirements.Explain()" ClipboardTooltipSubject="the security requirements of the data provider"/>
<TextInfoLines Label="Your security policy" MaxLines="3" Value="@this.DataSource.SecurityPolicy.ToInfoText()" Color="@this.DataSource.SecurityPolicy.GetColor()" ClipboardTooltipSubject="your security policy"/>
<TextInfoLines Label="@T("Server description")" MaxLines="14" Value="@this.serverDescription" ClipboardTooltipSubject="@T("the server description")"/>
<TextInfoLines Label="@T("Security requirements of the data provider")" MaxLines="3" Value="@this.securityRequirements.Explain()" ClipboardTooltipSubject="@T("the security requirements of the data provider")"/>
<TextInfoLines Label="@T("Your security policy")" MaxLines="3" Value="@this.DataSource.SecurityPolicy.ToInfoText()" Color="@this.DataSource.SecurityPolicy.GetColor()" ClipboardTooltipSubject="@T("your security policy")"/>
<MudText Typo="Typo.h5" Class="mt-6">
Retrieval information
@T("Retrieval information")
</MudText>
@if (!this.retrievalInfoformation.Any())
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Info" Class="mb-3">
The data source does not provide any retrieval information.
@T("The data source does not provide any retrieval information.")
</MudJustifiedText>
}
else
{
<MudExpansionPanels Class="mb-3">
<ExpansionPanel HeaderText="@this.RetrievalName(this.selectedRetrievalInfo)" HeaderIcon="@Icons.Material.Filled.Info">
<TextInfoLines Label="Description" MaxLines="14" Value="@this.selectedRetrievalInfo.Description" ClipboardTooltipSubject="the retrieval description"/>
<TextInfoLines Label="Parameters" MaxLines="14" Value="@this.RetrievalParameters(this.selectedRetrievalInfo)" ClipboardTooltipSubject="the retrieval parameters"/>
<TextInfoLines Label="Description" MaxLines="14" Value="@this.selectedRetrievalInfo.Description" ClipboardTooltipSubject="@T("the retrieval description")"/>
<TextInfoLines Label="Parameters" MaxLines="14" Value="@this.RetrievalParameters(this.selectedRetrievalInfo)" ClipboardTooltipSubject="@T("the retrieval parameters")"/>
@if (!string.IsNullOrWhiteSpace(this.selectedRetrievalInfo.Link))
{
<MudButton Href="@this.selectedRetrievalInfo.Link" Target="_blank" Class="mt-3" Color="Color.Primary" StartIcon="@Icons.Material.Filled.OpenInNew">
Open web link, show more information
@T("Open web link, show more information")
</MudButton>
}
<MudText Typo="Typo.h6" Class="mt-3">
Embeddings
@T("Embeddings")
</MudText>
@* ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract *@
@if (this.selectedRetrievalInfo.Embeddings is null || !this.selectedRetrievalInfo.Embeddings.Any())
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Info" Class="mb-3">
The data source does not provide any embedding information.
@T("The data source does not provide any embedding information.")
</MudJustifiedText>
}
else
@ -70,14 +68,14 @@
{
var embedding = this.selectedRetrievalInfo.Embeddings[embeddingIndex];
<ExpansionPanel HeaderText="@embedding.EmbeddingName" HeaderIcon="@Icons.Material.Filled.Info" IsExpanded="embeddingIndex == 0">
<TextInfoLine Icon="@Icons.Material.Filled.FormatShapes" Label="Type" Value="@embedding.EmbeddingType" ClipboardTooltipSubject="the embedding type"/>
<TextInfoLines Label="Description" MaxLines="14" Value="@embedding.Description" ClipboardTooltipSubject="the embedding description"/>
<TextInfoLines Label="When to use" MaxLines="3" Value="@embedding.UsedWhen" ClipboardTooltipSubject="when is the embedding used"/>
<TextInfoLine Icon="@Icons.Material.Filled.FormatShapes" Label="Type" Value="@embedding.EmbeddingType" ClipboardTooltipSubject="@T("the embedding type")"/>
<TextInfoLines Label="@T("Description")" MaxLines="14" Value="@embedding.Description" ClipboardTooltipSubject="@T("the embedding description")"/>
<TextInfoLines Label="@T("When to use")" MaxLines="3" Value="@embedding.UsedWhen" ClipboardTooltipSubject="@T("when is the embedding used")"/>
@if (!string.IsNullOrWhiteSpace(embedding.Link))
{
<MudButton Href="@embedding.Link" Target="_blank" Class="mt-3" Color="Color.Primary" StartIcon="@Icons.Material.Filled.OpenInNew">
Open web link, show more information
@T("Open web link, show more information")
</MudButton>
}
</ExpansionPanel>
@ -95,7 +93,11 @@
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="ml-5 mr-5"/>
}
<MudButton OnClick="@this.GetERIMetadata" Variant="Variant.Filled" Color="Color.Info">Reload</MudButton>
<MudButton OnClick="@this.Close" Variant="Variant.Filled">Close</MudButton>
<MudButton OnClick="@this.GetERIMetadata" Variant="Variant.Filled" Color="Color.Info">
@T("Reload")
</MudButton>
<MudButton OnClick="@this.Close" Variant="Variant.Filled">
@T("Close")
</MudButton>
</DialogActions>
</MudDialog>

View File

@ -3,6 +3,7 @@
using System.Text;
using AIStudio.Assistants.ERI;
using AIStudio.Components;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.ERIClient;
using AIStudio.Tools.ERIClient.DataModel;
@ -14,7 +15,7 @@ using RetrievalInfo = AIStudio.Tools.ERIClient.DataModel.RetrievalInfo;
namespace AIStudio.Dialogs;
public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposable, ISecretId
public partial class DataSourceERI_V1InfoDialog : MSGComponentBase, IAsyncDisposable, ISecretId
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
@ -29,8 +30,8 @@ public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposabl
protected override async Task OnInitializedAsync()
{
this.eriServerTasks.Add(this.GetERIMetadata());
await base.OnInitializedAsync();
this.eriServerTasks.Add(this.GetERIMetadata());
}
#endregion
@ -59,21 +60,21 @@ public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposabl
return $"[{retrievalInfo.Id}] {retrievalInfo.Name}";
if (hasId)
return $"[{retrievalInfo.Id}] Unnamed retrieval process";
return string.Format(T("[{0}] Unnamed retrieval process"), retrievalInfo.Id);
return hasName ? retrievalInfo.Name : "Unnamed retrieval process";
return hasName ? retrievalInfo.Name : T("Unnamed retrieval process");
}
private string RetrievalParameters(RetrievalInfo retrievalInfo)
{
var parameters = retrievalInfo.ParametersDescription;
if (parameters is null || parameters.Count == 0)
return "This retrieval process has no parameters.";
return T("This retrieval process has no parameters.");
var sb = new StringBuilder();
foreach (var (paramName, description) in parameters)
{
sb.Append("Parameter: ");
sb.Append(T("Parameter: "));
sb.AppendLine(paramName);
sb.AppendLine(description);
sb.AppendLine();
@ -94,7 +95,7 @@ public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposabl
using var client = ERIClientFactory.Get(ERIVersion.V1, this.DataSource);
if(client is null)
{
this.dataIssues.Add("Failed to connect to the ERI v1 server. The server is not supported.");
this.dataIssues.Add(T("Failed to connect to the ERI v1 server. The server is not supported."));
return;
}
@ -136,7 +137,7 @@ public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposabl
}
catch (Exception e)
{
this.dataIssues.Add($"Failed to connect to the ERI v1 server. The message was: {e.Message}");
this.dataIssues.Add(string.Format(T("Failed to connect to the ERI v1 server. The message was: {0}"), e.Message));
}
finally
{

View File

@ -1,5 +1,7 @@
@using AIStudio.Settings.DataModel
@using AIStudio.Tools.ERIClient.DataModel
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
@ -7,7 +9,7 @@
<MudTextField
T="string"
@bind-Text="@this.dataName"
Label="Data Source Name"
Label="@T("Data Source Name")"
Class="mb-6"
MaxLength="40"
Counter="40"
@ -24,7 +26,7 @@
<MudTextField
T="string"
@bind-Text="@this.dataHostname"
Label="ERI v1 Server Hostname"
Label="@T("ERI v1 Server Hostname")"
Class="mb-6"
Immediate="@true"
Validation="@this.dataSourceValidation.ValidatingHostname"
@ -35,7 +37,7 @@
UserAttributes="@SPELLCHECK_ATTRIBUTES"/>
<MudNumericField
Label="Port"
Label="@T("Port")"
Immediate="@true"
Min="1" Max="65535"
Validation="@this.dataSourceValidation.ValidatePort"
@ -47,9 +49,7 @@
@if (!this.IsConnectionEncrypted())
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
Please note: the connection to the ERI v1 server is not encrypted. This means that all
data sent to the server is transmitted in plain text. Please ask the ERI server administrator
to enable encryption.
@T("Please note: the connection to the ERI v1 server is not encrypted. This means that all data sent to the server is transmitted in plain text. Please ask the ERI server administrator to enable encryption.")
</MudJustifiedText>
}
@ -57,7 +57,7 @@
{
<MudStack Row="@true" AlignItems="AlignItems.Center">
<MudButton Variant="Variant.Filled" Color="@this.GetTestResultColor()" StartIcon="@this.GetTestResultIcon()" Class="mb-3" OnClick="@this.TestConnection">
Test connection & read available metadata
@T("Test connection & read available metadata")
</MudButton>
<MudText Typo="Typo.body1" Class="mb-3">
@this.GetTestResultText()
@ -70,7 +70,9 @@
<MudSelect @bind-Value="@this.dataAuthMethod" Text="@this.dataAuthMethod.DisplayName()" Label="Authentication Method" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateAuthMethod">
@foreach (var authMethod in this.availableAuthMethods)
{
<MudSelectItem Value="@authMethod">@authMethod.DisplayName()</MudSelectItem>
<MudSelectItem Value="@authMethod">
@authMethod.DisplayName()
</MudSelectItem>
}
</MudSelect>
}
@ -83,7 +85,7 @@
<MudTextField
T="string"
@bind-Text="@this.dataUsername"
Label="Username"
Label="@T("Username")"
Class="mb-6"
Immediate="@true"
Validation="@this.dataSourceValidation.ValidateUsername"
@ -112,7 +114,7 @@
@if (this.availableRetrievalProcesses.Count > 0)
{
<MudSelect @bind-Value="@this.dataSelectedRetrievalProcess" Text="@this.dataSelectedRetrievalProcess.Name" Label="Select one retrieval process" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateRetrievalProcess">
<MudSelect @bind-Value="@this.dataSelectedRetrievalProcess" Text="@this.dataSelectedRetrievalProcess.Name" Label="@T("Select one retrieval process")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateRetrievalProcess">
@foreach (var retrievalProcess in this.availableRetrievalProcesses)
{
<MudSelectItem Value="@retrievalProcess">
@ -122,7 +124,7 @@
</MudSelect>
}
<MudSelect @bind-Value="@this.dataSecurityPolicy" Text="@this.dataSecurityPolicy.ToSelectionText()" Label="Your security policy" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateSecurityPolicy">
<MudSelect @bind-Value="@this.dataSecurityPolicy" Text="@this.dataSecurityPolicy.ToSelectionText()" Label="@T("Your security policy")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateSecurityPolicy">
@foreach (var policy in Enum.GetValues<DataSourceSecurity>())
{
<MudSelectItem Value="@policy">
@ -135,15 +137,17 @@
<Issues IssuesData="@this.dataIssues"/>
</DialogContent>
<DialogActions>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">Cancel</MudButton>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing)
{
@:Update
@T("Update")
}
else
{
@:Add
@T("Add")
}
</MudButton>
</DialogActions>

View File

@ -1,4 +1,5 @@
using AIStudio.Assistants.ERI;
using AIStudio.Components;
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.ERIClient;
@ -13,7 +14,7 @@ using RetrievalInfo = AIStudio.Tools.ERIClient.DataModel.RetrievalInfo;
// ReSharper disable InconsistentNaming
namespace AIStudio.Dialogs;
public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
@ -24,9 +25,6 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
[Parameter]
public DataSourceERI_V1 DataSource { get; set; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
[Inject]
private ILogger<ProviderDialog> Logger { get; init; } = null!;
@ -195,7 +193,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
await this.form.Validate();
Array.Resize(ref this.dataIssues, this.dataIssues.Length + 1);
this.dataIssues[^1] = "Failed to connect to the ERI v1 server. The server is not supported.";
this.dataIssues[^1] = T("Failed to connect to the ERI v1 server. The server is not supported.");
return;
}
@ -254,7 +252,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
await this.form.Validate();
Array.Resize(ref this.dataIssues, this.dataIssues.Length + 1);
this.dataIssues[^1] = $"Failed to connect to the ERI v1 server. The message was: {e.Message}";
this.dataIssues[^1] = string.Format(T("Failed to connect to the ERI v1 server. The message was: {0}"), e.Message);
this.Logger.LogError($"Failed to connect to the ERI v1 server. Message: {e.Message}");
this.connectionTested = true;
@ -265,9 +263,9 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
private string GetTestResultText()
{
if(!this.connectionTested)
return "Not tested yet.";
return T("Not tested yet.");
return this.connectionSuccessfulTested ? "Connection successful." : "Connection failed.";
return this.connectionSuccessfulTested ? T("Connection successful.") : T("Connection failed.");
}
private Color GetTestResultColor()
@ -290,9 +288,9 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
private string GetSecretLabel() => this.dataAuthMethod switch
{
AuthMethod.TOKEN => "Access Token",
AuthMethod.USERNAME_PASSWORD => "Password",
_ => "Secret",
AuthMethod.TOKEN => T("Access Token"),
AuthMethod.USERNAME_PASSWORD => T("Password"),
_ => T("Secret"),
};
private async Task Store()
@ -320,7 +318,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
var storeResponse = await this.RustService.SetSecret(this, this.dataSecret);
if (!storeResponse.Success)
{
this.dataSecretStorageIssue = $"Failed to store the auth. secret in the operating system. The message was: {storeResponse.Issue}. Please try again.";
this.dataSecretStorageIssue = string.Format(T("Failed to store the auth. secret in the operating system. The message was: {0}. Please try again."), storeResponse.Issue);
await this.form.Validate();
return;
}

View File

@ -1,4 +1,5 @@
@using AIStudio.Settings.DataModel
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
@ -7,7 +8,7 @@
<MudTextField
T="string"
@bind-Text="@this.dataName"
Label="Data Source Name"
Label="@T("Data Source Name")"
Class="mb-6"
MaxLength="40"
Counter="40"
@ -20,19 +21,19 @@
/>
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
Select a root directory for this data source. All data in this directory and all
its subdirectories will be processed for this data source.
@T("Select a root directory for this data source. All data in this directory and all its subdirectories will be processed for this data source.")
</MudJustifiedText>
<SelectDirectory @bind-Directory="@this.dataPath" Label="Selected base directory for this data source" DirectoryDialogTitle="Select the base directory" Validation="@this.dataSourceValidation.ValidatePath" />
<SelectDirectory @bind-Directory="@this.dataPath" Label="@T("Selected base directory for this data source")" DirectoryDialogTitle="@T("Select the base directory")" Validation="@this.dataSourceValidation.ValidatePath" />
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
In order for the AI to be able to determine the appropriate data at any time, you must
choose an embedding method.
@T("In order for the AI to be able to determine the appropriate data at any time, you must choose an embedding method.")
</MudJustifiedText>
<MudSelect @bind-Value="@this.dataEmbeddingId" Label="Embedding" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateEmbeddingId">
<MudSelect @bind-Value="@this.dataEmbeddingId" Label="@T("Embedding")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateEmbeddingId">
@foreach (var embedding in this.AvailableEmbeddings)
{
<MudSelectItem Value="@embedding.Value">@embedding.Name</MudSelectItem>
<MudSelectItem Value="@embedding.Value">
@embedding.Name
</MudSelectItem>
}
</MudSelect>
@ -43,45 +44,46 @@
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
@if (string.IsNullOrWhiteSpace(this.dataPath))
{
@: Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud.
@: Please confirm that you have read and understood this.
@T("Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud. Please confirm that you have read and understood this.")
}
else
{
@: Please note: the embedding you selected runs in the cloud. All your data from the
@: folder '@this.dataPath' and all its subdirectories will be sent to the cloud. Please
@: confirm that you have read and understood this.
@string.Format(T("Please note: the embedding you selected runs in the cloud. All your data from the folder '{0}' and all its subdirectories will be sent to the cloud. Please confirm that you have read and understood this."), this.dataPath)
}
</MudJustifiedText>
<MudTextSwitch @bind-Value="@this.dataUserAcknowledgedCloudEmbedding" Label="I confirm that I have read and understood the above" LabelOn="Yes, please send my data to the cloud" LabelOff="No, I will chose another embedding" Validation="@this.dataSourceValidation.ValidateUserAcknowledgedCloudEmbedding"/>
<MudTextSwitch @bind-Value="@this.dataUserAcknowledgedCloudEmbedding" Label="@T("I confirm that I have read and understood the above")" LabelOn="@T("Yes, please send my data to the cloud")" LabelOff="@T("No, I will chose another embedding")" Validation="@this.dataSourceValidation.ValidateUserAcknowledgedCloudEmbedding"/>
}
else
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3">
The embedding you selected runs locally or in your organization. Your data is not sent to the cloud.
@T("The embedding you selected runs locally or in your organization. Your data is not sent to the cloud.")
</MudJustifiedText>
}
}
<MudSelect @bind-Value="@this.dataSecurityPolicy" Text="@this.dataSecurityPolicy.ToSelectionText()" Label="Your security policy" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateSecurityPolicy">
<MudSelect @bind-Value="@this.dataSecurityPolicy" Text="@this.dataSecurityPolicy.ToSelectionText()" Label="@T("Your security policy")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateSecurityPolicy">
@foreach (var policy in Enum.GetValues<DataSourceSecurity>())
{
<MudSelectItem Value="@policy">@policy.ToSelectionText()</MudSelectItem>
<MudSelectItem Value="@policy">
@policy.ToSelectionText()
</MudSelectItem>
}
</MudSelect>
</MudForm>
<Issues IssuesData="@this.dataIssues"/>
</DialogContent>
<DialogActions>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">Cancel</MudButton>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing)
{
@:Update
@T("Update")
}
else
{
@:Add
@T("Add")
}
</MudButton>
</DialogActions>

View File

@ -1,3 +1,4 @@
using AIStudio.Components;
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.Validation;
@ -6,7 +7,7 @@ using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs;
public partial class DataSourceLocalDirectoryDialog : ComponentBase
public partial class DataSourceLocalDirectoryDialog : MSGComponentBase
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
@ -20,9 +21,6 @@ public partial class DataSourceLocalDirectoryDialog : ComponentBase
[Parameter]
public IReadOnlyList<ConfigurationSelectData<string>> AvailableEmbeddings { get; set; } = [];
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
private readonly DataSourceValidation dataSourceValidation;

View File

@ -1,56 +1,58 @@
@using AIStudio.Settings.DataModel
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="Data source name" Value="@this.DataSource.Name" ClipboardTooltipSubject="the data source name"/>
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="@T("Data source name")" Value="@this.DataSource.Name" ClipboardTooltipSubject="@T("the data source name")"/>
<TextInfoLine Icon="@Icons.Material.Filled.FolderOpen" Label="Path" Value="@this.DataSource.Path" ClipboardTooltipSubject="this path"/>
<TextInfoLine Icon="@Icons.Material.Filled.FolderOpen" Label="@T("Path")" Value="@this.DataSource.Path" ClipboardTooltipSubject="@T("this path")"/>
@if (!this.IsDirectoryAvailable)
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
The directory chosen for the data source does not exist anymore. Please edit the data source and correct the path.
@T("The directory chosen for the data source does not exist anymore. Please edit the data source and correct the path.")
</MudJustifiedText>
}
else
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3">
The directory chosen for the data source exists.
@T("The directory chosen for the data source exists.")
</MudJustifiedText>
}
<TextInfoLine Icon="@Icons.Material.Filled.Layers" Label="Embedding name" Value="@this.embeddingProvider.Name" ClipboardTooltipSubject="the embedding name"/>
<TextInfoLine Icon="@Icons.Material.Filled.Layers" Label="@T("Embedding name")" Value="@this.embeddingProvider.Name" ClipboardTooltipSubject="@T("the embedding name")"/>
@if (this.IsCloudEmbedding)
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
The embedding runs in the cloud. All your data from the folder '@this.DataSource.Path' and all its subdirectories
will be sent to the cloud.
@string.Format(T("The embedding runs in the cloud. All your data from the folder '{0}' and all its subdirectories will be sent to the cloud."), this.DataSource.Path)
</MudJustifiedText>
}
else
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3">
The embedding runs locally or in your organization. Your data is not sent to the cloud.
@T("The embedding runs locally or in your organization. Your data is not sent to the cloud.")
</MudJustifiedText>
}
<TextInfoLines Label="Your security policy" MaxLines="3" Value="@this.DataSource.SecurityPolicy.ToInfoText()" Color="@this.DataSource.SecurityPolicy.GetColor()" ClipboardTooltipSubject="your security policy"/>
<TextInfoLines Label="@T("Your security policy")" MaxLines="3" Value="@this.DataSource.SecurityPolicy.ToInfoText()" Color="@this.DataSource.SecurityPolicy.GetColor()" ClipboardTooltipSubject="@T("your security policy")"/>
<TextInfoLine Icon="@Icons.Material.Filled.SquareFoot" Label="Number of files" Value="@this.NumberFilesInDirectory" ClipboardTooltipSubject="the number of files in the directory"/>
<TextInfoLines Label="Files list" MaxLines="14" Value="@this.directoryFiles.ToString()" ClipboardTooltipSubject="the files list"/>
<TextInfoLine Icon="@Icons.Material.Filled.SquareFoot" Label="@T("Number of files")" Value="@this.NumberFilesInDirectory" ClipboardTooltipSubject="@T("the number of files in the directory")"/>
<TextInfoLines Label="@T("Files list")" MaxLines="14" Value="@this.directoryFiles.ToString()" ClipboardTooltipSubject="@T("the files list")"/>
@if (this.directorySizeNumFiles > 100)
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Warning" Class="mb-3">
For performance reasons, only the first 100 files are shown. The directory contains @this.NumberFilesInDirectory files in total.
@string.Format(T("For performance reasons, only the first 100 files are shown. The directory contains {0} files in total."), this.NumberFilesInDirectory)
</MudJustifiedText>
}
<TextInfoLine Icon="@Icons.Material.Filled.SquareFoot" Label="Total directory size" Value="@this.directorySizeBytes.FileSize()" ClipboardTooltipSubject="the total directory size"/>
<TextInfoLine Icon="@Icons.Material.Filled.SquareFoot" Label="@T("Total directory size")" Value="@this.directorySizeBytes.FileSize()" ClipboardTooltipSubject="@T("the total directory size")"/>
</DialogContent>
<DialogActions>
@if (this.IsOperationInProgress)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="ml-5 mr-5"/>
}
<MudButton OnClick="@this.Close" Variant="Variant.Filled">Close</MudButton>
<MudButton OnClick="@this.Close" Variant="Variant.Filled">
@T("Close")
</MudButton>
</DialogActions>
</MudDialog>

View File

@ -1,5 +1,6 @@
using System.Text;
using AIStudio.Components;
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
@ -9,16 +10,13 @@ using Timer = System.Timers.Timer;
namespace AIStudio.Dialogs;
public partial class DataSourceLocalDirectoryInfoDialog : ComponentBase, IAsyncDisposable
public partial class DataSourceLocalDirectoryInfoDialog : MSGComponentBase, IAsyncDisposable
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public DataSourceLocalDirectory DataSource { get; set; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
private readonly Timer refreshTimer = new(TimeSpan.FromSeconds(1.6))
{

View File

@ -1,4 +1,6 @@
@using AIStudio.Settings.DataModel
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
@ -6,7 +8,7 @@
<MudTextField
T="string"
@bind-Text="@this.dataName"
Label="Data Source Name"
Label="@T("Data Source Name")"
Class="mb-6"
MaxLength="40"
Counter="40"
@ -19,18 +21,19 @@
/>
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
Select a file for this data source. The content of this file will be processed for the data source.
@T("Select a file for this data source. The content of this file will be processed for the data source.")
</MudJustifiedText>
<SelectFile @bind-File="@this.dataFilePath" Label="Selected file path for this data source" FileDialogTitle="Select the file" Validation="@this.dataSourceValidation.ValidateFilePath" />
<SelectFile @bind-File="@this.dataFilePath" Label="@T("Selected file path for this data source")" FileDialogTitle="@T("Select the file")" Validation="@this.dataSourceValidation.ValidateFilePath" />
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
In order for the AI to be able to determine the appropriate data at any time, you must
choose an embedding method.
@T("In order for the AI to be able to determine the appropriate data at any time, you must choose an embedding method.")
</MudJustifiedText>
<MudSelect @bind-Value="@this.dataEmbeddingId" Label="Embedding" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.GetSelectedCloudEmbedding">
<MudSelect @bind-Value="@this.dataEmbeddingId" Label="@T("Embedding")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.GetSelectedCloudEmbedding">
@foreach (var embedding in this.AvailableEmbeddings)
{
<MudSelectItem Value="@embedding.Value">@embedding.Name</MudSelectItem>
<MudSelectItem Value="@embedding.Value">
@embedding.Name
</MudSelectItem>
}
</MudSelect>
@ -41,45 +44,46 @@
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
@if (string.IsNullOrWhiteSpace(this.dataFilePath))
{
@: Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud.
@: Please confirm that you have read and understood this.
@T("Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud. Please confirm that you have read and understood this.")
}
else
{
@: Please note: the embedding you selected runs in the cloud. All your data within the
@: file '@this.dataFilePath' will be sent to the cloud. Please confirm that you have read
@: and understood this.
@string.Format(T("Please note: the embedding you selected runs in the cloud. All your data within the file '{0}' will be sent to the cloud. Please confirm that you have read and understood this."), this.dataFilePath)
}
</MudJustifiedText>
<MudTextSwitch @bind-Value="@this.dataUserAcknowledgedCloudEmbedding" Label="I confirm that I have read and understood the above" LabelOn="Yes, please send my data to the cloud" LabelOff="No, I will chose another embedding" Validation="@this.dataSourceValidation.ValidateUserAcknowledgedCloudEmbedding"/>
<MudTextSwitch @bind-Value="@this.dataUserAcknowledgedCloudEmbedding" Label="@T("I confirm that I have read and understood the above")" LabelOn="@T("Yes, please send my data to the cloud")" LabelOff="@T("No, I will chose another embedding")" Validation="@this.dataSourceValidation.ValidateUserAcknowledgedCloudEmbedding"/>
}
else
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3">
The embedding you selected runs locally or in your organization. Your data is not sent to the cloud.
@T("The embedding you selected runs locally or in your organization. Your data is not sent to the cloud.")
</MudJustifiedText>
}
}
<MudSelect @bind-Value="@this.dataSecurityPolicy" Text="@this.dataSecurityPolicy.ToSelectionText()" Label="Your security policy" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateSecurityPolicy">
<MudSelect @bind-Value="@this.dataSecurityPolicy" Text="@this.dataSecurityPolicy.ToSelectionText()" Label="@T("Your security policy")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateSecurityPolicy">
@foreach (var policy in Enum.GetValues<DataSourceSecurity>())
{
<MudSelectItem Value="@policy">@policy.ToSelectionText()</MudSelectItem>
<MudSelectItem Value="@policy">
@policy.ToSelectionText()
</MudSelectItem>
}
</MudSelect>
</MudForm>
<Issues IssuesData="@this.dataIssues"/>
</DialogContent>
<DialogActions>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">Cancel</MudButton>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing)
{
@:Update
@T("Update")
}
else
{
@:Add
@T("Add")
}
</MudButton>
</DialogActions>

View File

@ -1,3 +1,4 @@
using AIStudio.Components;
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.Validation;
@ -6,7 +7,7 @@ using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs;
public partial class DataSourceLocalFileDialog : ComponentBase
public partial class DataSourceLocalFileDialog : MSGComponentBase
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
@ -20,9 +21,6 @@ public partial class DataSourceLocalFileDialog : ComponentBase
[Parameter]
public IReadOnlyList<ConfigurationSelectData<string>> AvailableEmbeddings { get; set; } = [];
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
private readonly DataSourceValidation dataSourceValidation;

View File

@ -1,42 +1,44 @@
@using AIStudio.Settings.DataModel
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="Data source name" Value="@this.DataSource.Name" ClipboardTooltipSubject="the data source name"/>
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="@T("Data source name")" Value="@this.DataSource.Name" ClipboardTooltipSubject="@T("the data source name")"/>
<TextInfoLine Icon="@Icons.Material.Filled.FolderOpen" Label="File path" Value="@this.DataSource.FilePath" ClipboardTooltipSubject="this path"/>
<TextInfoLine Icon="@Icons.Material.Filled.FolderOpen" Label="@T("File path")" Value="@this.DataSource.FilePath" ClipboardTooltipSubject="@T("this path")"/>
@if (!this.IsFileAvailable)
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
The file chosen for the data source does not exist anymore. Please edit the data source and choose another file or correct the path.
@T("The file chosen for the data source does not exist anymore. Please edit the data source and choose another file or correct the path.")
</MudJustifiedText>
}
else
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3">
The file chosen for the data source exists.
@T("The file chosen for the data source exists.")
</MudJustifiedText>
}
<TextInfoLine Icon="@Icons.Material.Filled.Layers" Label="Embedding name" Value="@this.embeddingProvider.Name" ClipboardTooltipSubject="the embedding name"/>
<TextInfoLine Icon="@Icons.Material.Filled.Layers" Label="@T("Embedding name")" Value="@this.embeddingProvider.Name" ClipboardTooltipSubject="@T("the embedding name")"/>
@if (this.IsCloudEmbedding)
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
The embedding runs in the cloud. All your data within the
file '@this.DataSource.FilePath' will be sent to the cloud.
@string.Format(T("The embedding runs in the cloud. All your data within the file '{0}' will be sent to the cloud."), this.DataSource.FilePath)
</MudJustifiedText>
}
else
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3">
The embedding runs locally or in your organization. Your data is not sent to the cloud.
@T("The embedding runs locally or in your organization. Your data is not sent to the cloud.")
</MudJustifiedText>
}
<TextInfoLines Label="Your security policy" MaxLines="3" Value="@this.DataSource.SecurityPolicy.ToInfoText()" Color="@this.DataSource.SecurityPolicy.GetColor()" ClipboardTooltipSubject="your security policy"/>
<TextInfoLine Icon="@Icons.Material.Filled.SquareFoot" Label="File size" Value="@this.FileSize" ClipboardTooltipSubject="the file size"/>
<TextInfoLines Label="@T("Your security policy")" MaxLines="3" Value="@this.DataSource.SecurityPolicy.ToInfoText()" Color="@this.DataSource.SecurityPolicy.GetColor()" ClipboardTooltipSubject="@T("your security policy")"/>
<TextInfoLine Icon="@Icons.Material.Filled.SquareFoot" Label="@T("File size")" Value="@this.FileSize" ClipboardTooltipSubject="@T("the file size")"/>
</DialogContent>
<DialogActions>
<MudButton OnClick="@this.Close" Variant="Variant.Filled">Close</MudButton>
<MudButton OnClick="@this.Close" Variant="Variant.Filled">
@T("Close")
</MudButton>
</DialogActions>
</MudDialog>

View File

@ -1,3 +1,4 @@
using AIStudio.Components;
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
@ -5,16 +6,13 @@ using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs;
public partial class DataSourceLocalFileInfoDialog : ComponentBase
public partial class DataSourceLocalFileInfoDialog : MSGComponentBase
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public DataSourceLocalFile DataSource { get; set; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
#region Overrides of ComponentBase

View File

@ -1,3 +1,5 @@
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
@ -5,8 +7,8 @@
<MudTextField
T="string"
@bind-Text="@this.DataEmbeddingName"
Label="Embedding Name"
HelperText="The name of the embedding method."
Label="@T("Embedding Name")"
HelperText="@T("The name of the embedding method.")"
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Label"
@ -22,8 +24,8 @@
<MudTextField
T="string"
@bind-Text="@this.DataEmbeddingType"
Label="Embedding Type"
HelperText="What kind of embedding is used. For example, Transformer Embedding, Contextual Word Embedding, Graph Embedding, etc."
Label="@T("Embedding Type")"
HelperText="@T("What kind of embedding is used. For example, Transformer Embedding, Contextual Word Embedding, Graph Embedding, etc.")"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Extension"
AdornmentColor="Color.Info"
@ -35,16 +37,16 @@
/>
<MudList T="@string" Class="mb-3">
<MudListItem Icon="@Icons.Material.Filled.Link" Href="https://en.wikipedia.org/wiki/Word_embedding" Target="_blank" Text="See Wikipedia for more information about word embeddings"/>
<MudListItem Icon="@Icons.Material.Filled.Link" Href="https://en.wikipedia.org/wiki/Knowledge_graph_embedding" Target="_blank" Text="See Wikipedia for more information about knowledge graph embeddings"/>
<MudListItem Icon="@Icons.Material.Filled.Link" Href="https://en.wikipedia.org/wiki/Word_embedding" Target="_blank" Text="@T("See Wikipedia for more information about word embeddings")"/>
<MudListItem Icon="@Icons.Material.Filled.Link" Href="https://en.wikipedia.org/wiki/Knowledge_graph_embedding" Target="_blank" Text="@T("See Wikipedia for more information about knowledge graph embeddings")"/>
</MudList>
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField
T="string"
@bind-Text="@this.DataDescription"
Label="Embedding Description"
HelperText="A short description of the embedding method."
Label="@T("Embedding Description")"
HelperText="@T("A short description of the embedding method.")"
Lines="3"
AutoGrow="@true"
MaxLines="6"
@ -62,8 +64,8 @@
<MudTextField
T="string"
@bind-Text="@this.DataUsedWhen"
Label="Used when"
HelperText="When is this embedding used? When you define multiple embeddings, it is helpful to know when to use which one."
Label="@T("Used when")"
HelperText="@T("When is this embedding used? When you define multiple embeddings, it is helpful to know when to use which one.")"
Lines="3"
AutoGrow="@true"
MaxLines="6"
@ -81,8 +83,8 @@
<MudTextField
T="string"
@bind-Text="@this.DataLink"
Label="Embedding Link"
HelperText="A link to the embedding, e.g., to the model, the source code, the paper, it's Wikipedia page, etc."
Label="@T("Embedding Link")"
HelperText="@T("A link to the embedding, e.g., to the model, the source code, the paper, it's Wikipedia page, etc.")"
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Link"
@ -94,15 +96,17 @@
<Issues IssuesData="@this.dataIssues"/>
</DialogContent>
<DialogActions>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">Cancel</MudButton>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing)
{
@:Update
@T("Update")
}
else
{
@:Add
@T("Add")
}
</MudButton>
</DialogActions>

View File

@ -1,11 +1,12 @@
using AIStudio.Assistants.ERI;
using AIStudio.Components;
using AIStudio.Settings;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs;
public partial class EmbeddingMethodDialog : ComponentBase
public partial class EmbeddingMethodDialog : MSGComponentBase
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
@ -52,9 +53,6 @@ public partial class EmbeddingMethodDialog : ComponentBase
[Parameter]
public bool IsEditing { get; init; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
private bool dataIsValid;
@ -90,13 +88,13 @@ public partial class EmbeddingMethodDialog : ComponentBase
private string? ValidateName(string name)
{
if (string.IsNullOrWhiteSpace(name))
return "The embedding name must not be empty. Please name the embedding.";
return T("The embedding name must not be empty. Please name the embedding.");
if (name.Length > 26)
return "The embedding name must not be longer than 26 characters.";
return T("The embedding name must not be longer than 26 characters.");
if (this.UsedEmbeddingMethodNames.Contains(name))
return $"The embedding method name '{name}' is already used. Please choose a unique name.";
return string.Format(T("The embedding method name '{0}' is already used. Please choose a unique name."), name);
return null;
}
@ -104,10 +102,10 @@ public partial class EmbeddingMethodDialog : ComponentBase
private string? ValidateType(string type)
{
if (string.IsNullOrWhiteSpace(type))
return "The embedding type must not be empty. Please specify the embedding type.";
return T("The embedding type must not be empty. Please specify the embedding type.");
if (type.Length > 56)
return "The embedding type must not be longer than 56 characters.";
return T("The embedding type must not be longer than 56 characters.");
return null;
}
@ -115,7 +113,7 @@ public partial class EmbeddingMethodDialog : ComponentBase
private string? ValidateDescription(string description)
{
if (string.IsNullOrWhiteSpace(description))
return "The description must not be empty. Please describe the embedding method.";
return T("The description must not be empty. Please describe the embedding method.");
return null;
}
@ -123,7 +121,7 @@ public partial class EmbeddingMethodDialog : ComponentBase
private string? ValidateUsedWhen(string usedWhen)
{
if (string.IsNullOrWhiteSpace(usedWhen))
return "Please describe when the embedding is used. Might be anytime or when certain keywords are present, etc.";
return T("Please describe when the embedding is used. Might be anytime or when certain keywords are present, etc.");
return null;
}

View File

@ -1,24 +1,25 @@
@using AIStudio.Assistants.ERI
@using MudExtensions
@inherits MSGComponentBase
<MudDialog>
<DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
<MudText Typo="Typo.h5" Class="mb-3">
General Information
@T("General Information")
</MudText>
<MudText Typo="Typo.body1" Class="mb-3">
Please provide some general information about your retrieval process first. This data may be
displayed to the users.
@T("Please provide some general information about your retrieval process first. This data may be displayed to the users.")
</MudText>
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField
T="string"
@bind-Text="@this.DataName"
Label="Retrieval Process Name"
HelperText="The name of your retrieval process."
Label="@T("Retrieval Process Name")"
HelperText="@T("The name of your retrieval process.")"
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Label"
@ -34,8 +35,8 @@
<MudTextField
T="string"
@bind-Text="@this.DataDescription"
Label="Retrieval Process Description"
HelperText="A short description of the retrieval process."
Label="@T("Retrieval Process Description")"
HelperText="@T("A short description of the retrieval process.")"
Lines="3"
AutoGrow="@true"
MaxLines="6"
@ -53,8 +54,8 @@
<MudTextField
T="string"
@bind-Text="@this.DataLink"
Label="Retrieval Process Link"
HelperText="A link to the retrieval process, e.g., the source code, the paper, it's Wikipedia page, etc. Make sense for common retrieval processes. Leave empty if not applicable."
Label="@T("Retrieval Process Link")"
HelperText="@T("A link to the retrieval process, e.g., the source code, the paper, it's Wikipedia page, etc. Make sense for common retrieval processes. Leave empty if not applicable.")"
Class="mb-6"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Link"
@ -63,13 +64,11 @@
/>
<MudText Typo="Typo.h5" Class="mb-3">
Retrieval Process Parameters
@T("Retrieval Process Parameters")
</MudText>
<MudText Typo="Typo.body1" Class="mb-3">
You may want to parameterize your retrieval process. However, this is optional. You can specify any
parameters that can be set by the user or the system during the call. Nevertheless, you should use
sensible default values in your code so that users are not forced to set the parameters manually.
@T("You may want to parameterize your retrieval process. However, this is optional. You can specify any parameters that can be set by the user or the system during the call. Nevertheless, you should use sensible default values in your code so that users are not forced to set the parameters manually.")
</MudText>
<MudStack Row="@true" Spacing="6" AlignItems="AlignItems.Start" StretchItems="StretchItems.None">
@ -87,7 +86,7 @@
</MudList>
}
<MudButton OnClick="@this.AddRetrievalProcessParameter" Variant="Variant.Filled" Color="Color.Primary" Class="mt-1">
Add Parameter
@T("Add Parameter")
</MudButton>
</MudStack>
@ -98,13 +97,13 @@
@if(this.retrievalParameters.Count == 0)
{
<MudText>
Add a parameter first, then select it to edit.
@T("Add a parameter first, then select it to edit.")
</MudText>
}
else
{
<MudText>
Select a parameter to show and edit it.
@T("Select a parameter to show and edit it.")
</MudText>
}
}
@ -114,8 +113,8 @@
<MudTextField
T="string"
@bind-Text="@this.selectedParameter.Name"
Label="Parameter Name"
HelperText="The parameter name. It must be unique within the retrieval process."
Label="@T("Parameter Name")"
HelperText="@T("The parameter name. It must be unique within the retrieval process.")"
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Label"
@ -130,8 +129,8 @@
<MudTextField
T="string"
@bind-Text="@this.selectedParameter.Description"
Label="Parameter Description"
HelperText="A short description of the parameter. What data type is it? What is it used for? What are the possible values?"
Label="@T("Parameter Description")"
HelperText="@T("A short description of the parameter. What data type is it? What is it used for? What are the possible values?")"
Lines="3"
AutoGrow="@true"
MaxLines="6"
@ -146,7 +145,7 @@
<MudStack Row="@true">
<MudButton OnClick="@this.RemoveRetrievalProcessParameter" Variant="Variant.Filled" Color="Color.Secondary">
Delete this parameter
@T("Delete this parameter")
</MudButton>
</MudStack>
@ -155,22 +154,19 @@
</MudStack>
<MudText Typo="Typo.h5" Class="mb-3">
Embeddings
@T("Embeddings")
</MudText>
@if(this.AvailableEmbeddings.Count == 0)
{
<MudText Typo="Typo.body1" Class="mb-3">
Currently, you have not defined any embedding methods. If your retrieval process does not require embedding, you can ignore this part.
Otherwise, you can define one or more embedding methods in the previous view to assign them to your retrieval process here.
@T("Currently, you have not defined any embedding methods. If your retrieval process does not require embedding, you can ignore this part. Otherwise, you can define one or more embedding methods in the previous view to assign them to your retrieval process here.")
</MudText>
}
else
{
<MudText Typo="Typo.body1" Class="mb-3">
Here you can select which embedding methods are used for this retrieval process. Embeddings are optional;
if your retrieval process works without embedding, you can ignore this part. You can only choose the embedding
methods you have previously defined.
@T("Here you can select which embedding methods are used for this retrieval process. Embeddings are optional; if your retrieval process works without embedding, you can ignore this part. You can only choose the embedding methods you have previously defined.")
</MudText>
<MudSelectExtended
@ -181,11 +177,11 @@
SelectedValuesChanged="@this.EmbeddingsChanged"
Strict="@true"
Margin="Margin.Dense"
Label="Embeddings methods"
Label="@T("Embeddings methods")"
ShrinkLabel="@true"
Class="mb-3"
Variant="Variant.Outlined"
HelperText="Optional. Select the embedding methods that are used for this retrieval process.">
HelperText="@T("Optional. Select the embedding methods that are used for this retrieval process.")">
@foreach (var embedding in this.AvailableEmbeddings)
{
<MudSelectItemExtended Value="@embedding">
@ -198,15 +194,17 @@
<Issues IssuesData="@this.dataIssues"/>
</DialogContent>
<DialogActions>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">Cancel</MudButton>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing)
{
@:Update
@T("Update")
}
else
{
@:Add
@T("Add")
}
</MudButton>
</DialogActions>

View File

@ -1,11 +1,11 @@
using AIStudio.Assistants.ERI;
using AIStudio.Settings;
using AIStudio.Components;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs;
public partial class RetrievalProcessDialog : ComponentBase
public partial class RetrievalProcessDialog : MSGComponentBase
{
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!;
@ -60,9 +60,6 @@ public partial class RetrievalProcessDialog : ComponentBase
[Parameter]
public bool IsEditing { get; init; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
private bool dataIsValid;
@ -80,13 +77,13 @@ public partial class RetrievalProcessDialog : ComponentBase
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
// Configure the spellchecking for the instance name input:
this.SettingsManager.InjectSpellchecking(SPELLCHECK_ATTRIBUTES);
// Convert the parameters:
this.retrievalParameters = this.DataParametersDescription.Select(pair => new RetrievalParameter { Name = pair.Key, Description = pair.Value }).ToList();
await base.OnInitializedAsync();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
@ -104,13 +101,13 @@ public partial class RetrievalProcessDialog : ComponentBase
private string? ValidateName(string name)
{
if (string.IsNullOrWhiteSpace(name))
return "The retrieval process name must not be empty. Please name your retrieval process.";
return T("The retrieval process name must not be empty. Please name your retrieval process.");
if (name.Length > 26)
return "The retrieval process name must not be longer than 26 characters.";
return T("The retrieval process name must not be longer than 26 characters.");
if (this.UsedRetrievalProcessNames.Contains(name))
return $"The retrieval process name '{name}' must be unique. Please choose a different name.";
return string.Format(T("The retrieval process name '{0}' must be unique. Please choose a different name."), name);
return null;
}
@ -118,26 +115,26 @@ public partial class RetrievalProcessDialog : ComponentBase
private string? ValidateDescription(string description)
{
if (string.IsNullOrWhiteSpace(description))
return "The description must not be empty. Please describe the retrieval process.";
return T("The description must not be empty. Please describe the retrieval process.");
return null;
}
private void AddRetrievalProcessParameter()
{
this.retrievalParameters.Add(new() { Name = $"New Parameter {this.nextParameterId++}", Description = string.Empty });
this.retrievalParameters.Add(new() { Name = string.Format(T("New Parameter {0}"), this.nextParameterId++), Description = string.Empty });
}
private string? ValidateParameterName(string name)
{
if (string.IsNullOrWhiteSpace(name))
return "The parameter name must not be empty. Please name the parameter.";
return T("The parameter name must not be empty. Please name the parameter.");
if(name.Length > 26)
return "The parameter name must not be longer than 26 characters.";
return T("The parameter name must not be longer than 26 characters.");
if (this.retrievalParameters.Count(parameter => parameter.Name == name) > 1)
return $"The parameter name '{name}' must be unique. Please choose a different name.";
return string.Format(T("The parameter name '{0}' must be unique. Please choose a different name."), name);
return null;
}
@ -145,7 +142,7 @@ public partial class RetrievalProcessDialog : ComponentBase
private string? ValidateParameterDescription(string description)
{
if (string.IsNullOrWhiteSpace(description))
return $"The parameter description must not be empty. Please describe the parameter '{this.selectedParameter?.Name}'. What data type is it? What is it used for? What are the possible values?";
return string.Format(T("The parameter description must not be empty. Please describe the parameter '{0}'. What data type is it? What is it used for? What are the possible values?"), this.selectedParameter?.Name);
return null;
}
@ -156,7 +153,7 @@ public partial class RetrievalProcessDialog : ComponentBase
return nameIssue;
if (string.IsNullOrWhiteSpace(parameter.Description))
return $"The parameter description must not be empty. Please describe the parameter '{parameter.Name}'. What data type is it? What is it used for? What are the possible values?";
return string.Format(T("The parameter description must not be empty. Please describe the parameter '{0}'. What data type is it? What is it used for? What are the possible values?"), parameter.Name);
return null;
}
@ -172,12 +169,12 @@ public partial class RetrievalProcessDialog : ComponentBase
private string GetMultiSelectionText(List<EmbeddingInfo> selectedEmbeddings)
{
if(selectedEmbeddings.Count == 0)
return "No embedding methods selected.";
return T("No embedding methods selected.");
if(selectedEmbeddings.Count == 1)
return "You have selected 1 embedding method.";
return T("You have selected 1 embedding method.");
return $"You have selected {selectedEmbeddings.Count} embedding methods.";
return string.Format(T("You have selected {0} embedding methods."), selectedEmbeddings.Count);
}
private void EmbeddingsChanged(IEnumerable<EmbeddingInfo>? updatedEmbeddings)