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

View File

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

View File

@ -1,5 +1,7 @@
@using AIStudio.Settings.DataModel @using AIStudio.Settings.DataModel
@using AIStudio.Tools.ERIClient.DataModel @using AIStudio.Tools.ERIClient.DataModel
@inherits MSGComponentBase
<MudDialog> <MudDialog>
<DialogContent> <DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues"> <MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
@ -7,7 +9,7 @@
<MudTextField <MudTextField
T="string" T="string"
@bind-Text="@this.dataName" @bind-Text="@this.dataName"
Label="Data Source Name" Label="@T("Data Source Name")"
Class="mb-6" Class="mb-6"
MaxLength="40" MaxLength="40"
Counter="40" Counter="40"
@ -24,7 +26,7 @@
<MudTextField <MudTextField
T="string" T="string"
@bind-Text="@this.dataHostname" @bind-Text="@this.dataHostname"
Label="ERI v1 Server Hostname" Label="@T("ERI v1 Server Hostname")"
Class="mb-6" Class="mb-6"
Immediate="@true" Immediate="@true"
Validation="@this.dataSourceValidation.ValidatingHostname" Validation="@this.dataSourceValidation.ValidatingHostname"
@ -35,7 +37,7 @@
UserAttributes="@SPELLCHECK_ATTRIBUTES"/> UserAttributes="@SPELLCHECK_ATTRIBUTES"/>
<MudNumericField <MudNumericField
Label="Port" Label="@T("Port")"
Immediate="@true" Immediate="@true"
Min="1" Max="65535" Min="1" Max="65535"
Validation="@this.dataSourceValidation.ValidatePort" Validation="@this.dataSourceValidation.ValidatePort"
@ -47,9 +49,7 @@
@if (!this.IsConnectionEncrypted()) @if (!this.IsConnectionEncrypted())
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3"> <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 @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.")
data sent to the server is transmitted in plain text. Please ask the ERI server administrator
to enable encryption.
</MudJustifiedText> </MudJustifiedText>
} }
@ -57,7 +57,7 @@
{ {
<MudStack Row="@true" AlignItems="AlignItems.Center"> <MudStack Row="@true" AlignItems="AlignItems.Center">
<MudButton Variant="Variant.Filled" Color="@this.GetTestResultColor()" StartIcon="@this.GetTestResultIcon()" Class="mb-3" OnClick="@this.TestConnection"> <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> </MudButton>
<MudText Typo="Typo.body1" Class="mb-3"> <MudText Typo="Typo.body1" Class="mb-3">
@this.GetTestResultText() @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"> <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) @foreach (var authMethod in this.availableAuthMethods)
{ {
<MudSelectItem Value="@authMethod">@authMethod.DisplayName()</MudSelectItem> <MudSelectItem Value="@authMethod">
@authMethod.DisplayName()
</MudSelectItem>
} }
</MudSelect> </MudSelect>
} }
@ -83,7 +85,7 @@
<MudTextField <MudTextField
T="string" T="string"
@bind-Text="@this.dataUsername" @bind-Text="@this.dataUsername"
Label="Username" Label="@T("Username")"
Class="mb-6" Class="mb-6"
Immediate="@true" Immediate="@true"
Validation="@this.dataSourceValidation.ValidateUsername" Validation="@this.dataSourceValidation.ValidateUsername"
@ -112,7 +114,7 @@
@if (this.availableRetrievalProcesses.Count > 0) @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) @foreach (var retrievalProcess in this.availableRetrievalProcesses)
{ {
<MudSelectItem Value="@retrievalProcess"> <MudSelectItem Value="@retrievalProcess">
@ -122,7 +124,7 @@
</MudSelect> </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>()) @foreach (var policy in Enum.GetValues<DataSourceSecurity>())
{ {
<MudSelectItem Value="@policy"> <MudSelectItem Value="@policy">
@ -135,15 +137,17 @@
<Issues IssuesData="@this.dataIssues"/> <Issues IssuesData="@this.dataIssues"/>
</DialogContent> </DialogContent>
<DialogActions> <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"> <MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing) @if(this.IsEditing)
{ {
@:Update @T("Update")
} }
else else
{ {
@:Add @T("Add")
} }
</MudButton> </MudButton>
</DialogActions> </DialogActions>

View File

@ -1,4 +1,5 @@
using AIStudio.Assistants.ERI; using AIStudio.Assistants.ERI;
using AIStudio.Components;
using AIStudio.Settings; using AIStudio.Settings;
using AIStudio.Settings.DataModel; using AIStudio.Settings.DataModel;
using AIStudio.Tools.ERIClient; using AIStudio.Tools.ERIClient;
@ -13,7 +14,7 @@ using RetrievalInfo = AIStudio.Tools.ERIClient.DataModel.RetrievalInfo;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace AIStudio.Dialogs; namespace AIStudio.Dialogs;
public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId
{ {
[CascadingParameter] [CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!; private IMudDialogInstance MudDialog { get; set; } = null!;
@ -24,9 +25,6 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
[Parameter] [Parameter]
public DataSourceERI_V1 DataSource { get; set; } public DataSourceERI_V1 DataSource { get; set; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
[Inject] [Inject]
private ILogger<ProviderDialog> Logger { get; init; } = null!; private ILogger<ProviderDialog> Logger { get; init; } = null!;
@ -195,7 +193,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
await this.form.Validate(); await this.form.Validate();
Array.Resize(ref this.dataIssues, this.dataIssues.Length + 1); 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; return;
} }
@ -254,7 +252,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
await this.form.Validate(); await this.form.Validate();
Array.Resize(ref this.dataIssues, this.dataIssues.Length + 1); 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.Logger.LogError($"Failed to connect to the ERI v1 server. Message: {e.Message}");
this.connectionTested = true; this.connectionTested = true;
@ -265,9 +263,9 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
private string GetTestResultText() private string GetTestResultText()
{ {
if(!this.connectionTested) 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() private Color GetTestResultColor()
@ -290,9 +288,9 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
private string GetSecretLabel() => this.dataAuthMethod switch private string GetSecretLabel() => this.dataAuthMethod switch
{ {
AuthMethod.TOKEN => "Access Token", AuthMethod.TOKEN => T("Access Token"),
AuthMethod.USERNAME_PASSWORD => "Password", AuthMethod.USERNAME_PASSWORD => T("Password"),
_ => "Secret", _ => T("Secret"),
}; };
private async Task Store() private async Task Store()
@ -320,7 +318,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId
var storeResponse = await this.RustService.SetSecret(this, this.dataSecret); var storeResponse = await this.RustService.SetSecret(this, this.dataSecret);
if (!storeResponse.Success) 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(); await this.form.Validate();
return; return;
} }

View File

@ -1,4 +1,5 @@
@using AIStudio.Settings.DataModel @using AIStudio.Settings.DataModel
@inherits MSGComponentBase
<MudDialog> <MudDialog>
<DialogContent> <DialogContent>
@ -7,7 +8,7 @@
<MudTextField <MudTextField
T="string" T="string"
@bind-Text="@this.dataName" @bind-Text="@this.dataName"
Label="Data Source Name" Label="@T("Data Source Name")"
Class="mb-6" Class="mb-6"
MaxLength="40" MaxLength="40"
Counter="40" Counter="40"
@ -20,19 +21,19 @@
/> />
<MudJustifiedText Typo="Typo.body1" Class="mb-3"> <MudJustifiedText Typo="Typo.body1" Class="mb-3">
Select a root directory for this data source. All data in this directory and all @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.")
its subdirectories will be processed for this data source.
</MudJustifiedText> </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"> <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 @T("In order for the AI to be able to determine the appropriate data at any time, you must choose an embedding method.")
choose an embedding method.
</MudJustifiedText> </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) @foreach (var embedding in this.AvailableEmbeddings)
{ {
<MudSelectItem Value="@embedding.Value">@embedding.Name</MudSelectItem> <MudSelectItem Value="@embedding.Value">
@embedding.Name
</MudSelectItem>
} }
</MudSelect> </MudSelect>
@ -43,45 +44,46 @@
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3"> <MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
@if (string.IsNullOrWhiteSpace(this.dataPath)) @if (string.IsNullOrWhiteSpace(this.dataPath))
{ {
@: Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud. @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.")
@: Please confirm that you have read and understood this.
} }
else else
{ {
@: Please note: the embedding you selected runs in the cloud. All your data from the @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)
@: folder '@this.dataPath' and all its subdirectories will be sent to the cloud. Please
@: confirm that you have read and understood this.
} }
</MudJustifiedText> </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 else
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3"> <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> </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>()) @foreach (var policy in Enum.GetValues<DataSourceSecurity>())
{ {
<MudSelectItem Value="@policy">@policy.ToSelectionText()</MudSelectItem> <MudSelectItem Value="@policy">
@policy.ToSelectionText()
</MudSelectItem>
} }
</MudSelect> </MudSelect>
</MudForm> </MudForm>
<Issues IssuesData="@this.dataIssues"/> <Issues IssuesData="@this.dataIssues"/>
</DialogContent> </DialogContent>
<DialogActions> <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"> <MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing) @if(this.IsEditing)
{ {
@:Update @T("Update")
} }
else else
{ {
@:Add @T("Add")
} }
</MudButton> </MudButton>
</DialogActions> </DialogActions>

View File

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

View File

@ -1,56 +1,58 @@
@using AIStudio.Settings.DataModel @using AIStudio.Settings.DataModel
@inherits MSGComponentBase
<MudDialog> <MudDialog>
<DialogContent> <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) @if (!this.IsDirectoryAvailable)
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3"> <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> </MudJustifiedText>
} }
else else
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3"> <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> </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) @if (this.IsCloudEmbedding)
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3"> <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 @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)
will be sent to the cloud.
</MudJustifiedText> </MudJustifiedText>
} }
else else
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3"> <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> </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"/> <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="Files list" MaxLines="14" Value="@this.directoryFiles.ToString()" ClipboardTooltipSubject="the files list"/> <TextInfoLines Label="@T("Files list")" MaxLines="14" Value="@this.directoryFiles.ToString()" ClipboardTooltipSubject="@T("the files list")"/>
@if (this.directorySizeNumFiles > 100) @if (this.directorySizeNumFiles > 100)
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Warning" Class="mb-3"> <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> </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> </DialogContent>
<DialogActions> <DialogActions>
@if (this.IsOperationInProgress) @if (this.IsOperationInProgress)
{ {
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="ml-5 mr-5"/> <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> </DialogActions>
</MudDialog> </MudDialog>

View File

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

View File

@ -1,4 +1,6 @@
@using AIStudio.Settings.DataModel @using AIStudio.Settings.DataModel
@inherits MSGComponentBase
<MudDialog> <MudDialog>
<DialogContent> <DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues"> <MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
@ -6,7 +8,7 @@
<MudTextField <MudTextField
T="string" T="string"
@bind-Text="@this.dataName" @bind-Text="@this.dataName"
Label="Data Source Name" Label="@T("Data Source Name")"
Class="mb-6" Class="mb-6"
MaxLength="40" MaxLength="40"
Counter="40" Counter="40"
@ -19,18 +21,19 @@
/> />
<MudJustifiedText Typo="Typo.body1" Class="mb-3"> <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> </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"> <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 @T("In order for the AI to be able to determine the appropriate data at any time, you must choose an embedding method.")
choose an embedding method.
</MudJustifiedText> </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) @foreach (var embedding in this.AvailableEmbeddings)
{ {
<MudSelectItem Value="@embedding.Value">@embedding.Name</MudSelectItem> <MudSelectItem Value="@embedding.Value">
@embedding.Name
</MudSelectItem>
} }
</MudSelect> </MudSelect>
@ -41,45 +44,46 @@
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3"> <MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
@if (string.IsNullOrWhiteSpace(this.dataFilePath)) @if (string.IsNullOrWhiteSpace(this.dataFilePath))
{ {
@: Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud. @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.")
@: Please confirm that you have read and understood this.
} }
else else
{ {
@: Please note: the embedding you selected runs in the cloud. All your data within the @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)
@: file '@this.dataFilePath' will be sent to the cloud. Please confirm that you have read
@: and understood this.
} }
</MudJustifiedText> </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 else
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3"> <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> </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>()) @foreach (var policy in Enum.GetValues<DataSourceSecurity>())
{ {
<MudSelectItem Value="@policy">@policy.ToSelectionText()</MudSelectItem> <MudSelectItem Value="@policy">
@policy.ToSelectionText()
</MudSelectItem>
} }
</MudSelect> </MudSelect>
</MudForm> </MudForm>
<Issues IssuesData="@this.dataIssues"/> <Issues IssuesData="@this.dataIssues"/>
</DialogContent> </DialogContent>
<DialogActions> <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"> <MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing) @if(this.IsEditing)
{ {
@:Update @T("Update")
} }
else else
{ {
@:Add @T("Add")
} }
</MudButton> </MudButton>
</DialogActions> </DialogActions>

View File

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

View File

@ -1,42 +1,44 @@
@using AIStudio.Settings.DataModel @using AIStudio.Settings.DataModel
@inherits MSGComponentBase
<MudDialog> <MudDialog>
<DialogContent> <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) @if (!this.IsFileAvailable)
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3"> <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> </MudJustifiedText>
} }
else else
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3"> <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> </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) @if (this.IsCloudEmbedding)
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3"> <MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
The embedding runs in the cloud. All your data within the @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)
file '@this.DataSource.FilePath' will be sent to the cloud.
</MudJustifiedText> </MudJustifiedText>
} }
else else
{ {
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3"> <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> </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="File size" Value="@this.FileSize" ClipboardTooltipSubject="the file size"/> <TextInfoLine Icon="@Icons.Material.Filled.SquareFoot" Label="@T("File size")" Value="@this.FileSize" ClipboardTooltipSubject="@T("the file size")"/>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<MudButton OnClick="@this.Close" Variant="Variant.Filled">Close</MudButton> <MudButton OnClick="@this.Close" Variant="Variant.Filled">
@T("Close")
</MudButton>
</DialogActions> </DialogActions>
</MudDialog> </MudDialog>

View File

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

View File

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

View File

@ -1,11 +1,12 @@
using AIStudio.Assistants.ERI; using AIStudio.Assistants.ERI;
using AIStudio.Components;
using AIStudio.Settings; using AIStudio.Settings;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs; namespace AIStudio.Dialogs;
public partial class EmbeddingMethodDialog : ComponentBase public partial class EmbeddingMethodDialog : MSGComponentBase
{ {
[CascadingParameter] [CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!; private IMudDialogInstance MudDialog { get; set; } = null!;
@ -52,9 +53,6 @@ public partial class EmbeddingMethodDialog : ComponentBase
[Parameter] [Parameter]
public bool IsEditing { get; init; } public bool IsEditing { get; init; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new(); private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
private bool dataIsValid; private bool dataIsValid;
@ -90,13 +88,13 @@ public partial class EmbeddingMethodDialog : ComponentBase
private string? ValidateName(string name) private string? ValidateName(string name)
{ {
if (string.IsNullOrWhiteSpace(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) 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)) 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; return null;
} }
@ -104,10 +102,10 @@ public partial class EmbeddingMethodDialog : ComponentBase
private string? ValidateType(string type) private string? ValidateType(string type)
{ {
if (string.IsNullOrWhiteSpace(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) 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; return null;
} }
@ -115,7 +113,7 @@ public partial class EmbeddingMethodDialog : ComponentBase
private string? ValidateDescription(string description) private string? ValidateDescription(string description)
{ {
if (string.IsNullOrWhiteSpace(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; return null;
} }
@ -123,7 +121,7 @@ public partial class EmbeddingMethodDialog : ComponentBase
private string? ValidateUsedWhen(string usedWhen) private string? ValidateUsedWhen(string usedWhen)
{ {
if (string.IsNullOrWhiteSpace(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; return null;
} }

View File

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

View File

@ -1,11 +1,11 @@
using AIStudio.Assistants.ERI; using AIStudio.Assistants.ERI;
using AIStudio.Settings; using AIStudio.Components;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs; namespace AIStudio.Dialogs;
public partial class RetrievalProcessDialog : ComponentBase public partial class RetrievalProcessDialog : MSGComponentBase
{ {
[CascadingParameter] [CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = null!; private IMudDialogInstance MudDialog { get; set; } = null!;
@ -60,9 +60,6 @@ public partial class RetrievalProcessDialog : ComponentBase
[Parameter] [Parameter]
public bool IsEditing { get; init; } public bool IsEditing { get; init; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new(); private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
private bool dataIsValid; private bool dataIsValid;
@ -80,13 +77,13 @@ public partial class RetrievalProcessDialog : ComponentBase
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
await base.OnInitializedAsync();
// Configure the spellchecking for the instance name input: // Configure the spellchecking for the instance name input:
this.SettingsManager.InjectSpellchecking(SPELLCHECK_ATTRIBUTES); this.SettingsManager.InjectSpellchecking(SPELLCHECK_ATTRIBUTES);
// Convert the parameters: // Convert the parameters:
this.retrievalParameters = this.DataParametersDescription.Select(pair => new RetrievalParameter { Name = pair.Key, Description = pair.Value }).ToList(); 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) protected override async Task OnAfterRenderAsync(bool firstRender)
@ -104,13 +101,13 @@ public partial class RetrievalProcessDialog : ComponentBase
private string? ValidateName(string name) private string? ValidateName(string name)
{ {
if (string.IsNullOrWhiteSpace(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) 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)) 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; return null;
} }
@ -118,26 +115,26 @@ public partial class RetrievalProcessDialog : ComponentBase
private string? ValidateDescription(string description) private string? ValidateDescription(string description)
{ {
if (string.IsNullOrWhiteSpace(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; return null;
} }
private void AddRetrievalProcessParameter() 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) private string? ValidateParameterName(string name)
{ {
if (string.IsNullOrWhiteSpace(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) 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) 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; return null;
} }
@ -145,7 +142,7 @@ public partial class RetrievalProcessDialog : ComponentBase
private string? ValidateParameterDescription(string description) private string? ValidateParameterDescription(string description)
{ {
if (string.IsNullOrWhiteSpace(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; return null;
} }
@ -156,7 +153,7 @@ public partial class RetrievalProcessDialog : ComponentBase
return nameIssue; return nameIssue;
if (string.IsNullOrWhiteSpace(parameter.Description)) 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; return null;
} }
@ -172,12 +169,12 @@ public partial class RetrievalProcessDialog : ComponentBase
private string GetMultiSelectionText(List<EmbeddingInfo> selectedEmbeddings) private string GetMultiSelectionText(List<EmbeddingInfo> selectedEmbeddings)
{ {
if(selectedEmbeddings.Count == 0) if(selectedEmbeddings.Count == 0)
return "No embedding methods selected."; return T("No embedding methods selected.");
if(selectedEmbeddings.Count == 1) 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) private void EmbeddingsChanged(IEnumerable<EmbeddingInfo>? updatedEmbeddings)