diff --git a/app/MindWork AI Studio/Components/DataSourceSelection.razor b/app/MindWork AI Studio/Components/DataSourceSelection.razor index f99aa6fa..389e234f 100644 --- a/app/MindWork AI Studio/Components/DataSourceSelection.razor +++ b/app/MindWork AI Studio/Components/DataSourceSelection.razor @@ -1,9 +1,9 @@ @using AIStudio.Settings - +@inherits MSGComponentBase @if (this.SelectionMode is DataSourceSelectionMode.SELECTION_MODE) {
- + @if (this.PopoverTriggerMode is PopoverTriggerMode.ICON) { @@ -11,7 +11,7 @@ else { - Select data + @T("Select data") } @@ -22,9 +22,11 @@ - Data Source Selection + + @T("Data Source Selection") + - + @@ -40,57 +42,52 @@ else if (this.SettingsManager.ConfigurationData.DataSources.Count == 0) { - You haven't configured any data sources. To grant the AI access to your data, you need to - add such a source. However, if you wish to use data from your device, you first have to set up - a so-called embedding. This embedding is necessary so the AI can effectively search your data, - find and retrieve the correct information required for each task. In addition to local data, - you can also incorporate your company's data. To do so, your company must provide the data through - an ERI (External Retrieval Interface). + @T("You haven't configured any data sources. To grant the AI access to your data, you need to add such a source. However, if you wish to use data from your device, you first have to set up a so-called embedding. This embedding is necessary so the AI can effectively search your data, find and retrieve the correct information required for each task. In addition to local data, you can also incorporate your company's data. To do so, your company must provide the data through an ERI (External Retrieval Interface).") - Manage Data Sources + @T("Manage Data Sources") - Read more about ERI + @T("Read more about ERI") } else if (this.showDataSourceSelection) { - + @if (this.areDataSourcesEnabled) { - + @if (this.SettingsManager.ConfigurationData.AgentRetrievalContextValidation.EnableRetrievalContextValidation) { - + } @switch (this.aiBasedSourceSelection) { case true when this.availableDataSources.Count == 0: - Your data sources cannot be used with the LLM provider you selected due to data privacy, or they are currently unavailable. + @T("Your data sources cannot be used with the LLM provider you selected due to data privacy, or they are currently unavailable.") break; case true when this.DataSourcesAISelected.Count == 0: - The AI evaluates each of your inputs to determine whether and which data sources are necessary. Currently, the AI has not selected any source. + @T("The AI evaluates each of your inputs to determine whether and which data sources are necessary. Currently, the AI has not selected any source.") break; case false when this.availableDataSources.Count == 0: - Your data sources cannot be used with the LLM provider you selected due to data privacy, or they are currently unavailable. + @T("Your data sources cannot be used with the LLM provider you selected due to data privacy, or they are currently unavailable.") break; case false: - + @foreach (var source in this.availableDataSources) { @@ -104,7 +101,7 @@ case true: - + @foreach (var source in this.availableDataSources) { @@ -114,7 +111,7 @@ } - + @foreach (var source in this.DataSourcesAISelected) { @@ -141,7 +138,7 @@ - Close + @T("Close") @@ -152,7 +149,9 @@ else if (this.SelectionMode is DataSourceSelectionMode.CONFIGURATION_MODE) { - Data Source Selection + + @T("Data Source Selection") + @if (!string.IsNullOrWhiteSpace(this.ConfigurationHeaderMessage)) { @@ -161,12 +160,12 @@ else if (this.SelectionMode is DataSourceSelectionMode.CONFIGURATION_MODE) } - + @if (this.areDataSourcesEnabled) { - - - + + + @foreach (var source in this.availableDataSources) { diff --git a/app/MindWork AI Studio/Components/DataSourceSelection.razor.cs b/app/MindWork AI Studio/Components/DataSourceSelection.razor.cs index 22d4b0cb..5715d52f 100644 --- a/app/MindWork AI Studio/Components/DataSourceSelection.razor.cs +++ b/app/MindWork AI Studio/Components/DataSourceSelection.razor.cs @@ -9,7 +9,7 @@ using DialogOptions = AIStudio.Dialogs.DialogOptions; namespace AIStudio.Components; -public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, IDisposable +public partial class DataSourceSelection : MSGComponentBase { [Parameter] public DataSourceSelectionMode SelectionMode { get; set; } = DataSourceSelectionMode.SELECTION_MODE; @@ -38,12 +38,6 @@ public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, I [Parameter] public bool AutoSaveAppSettings { get; set; } - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - - [Inject] - private MessageBus MessageBus { get; init; } = null!; - [Inject] private DataSourceService DataSourceService { get; init; } = null!; @@ -63,8 +57,7 @@ public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, I protected override async Task OnInitializedAsync() { - this.MessageBus.RegisterComponent(this); - this.MessageBus.ApplyFilters(this, [], [ Event.COLOR_THEME_CHANGED, Event.RAG_AUTO_DATA_SOURCES_SELECTED ]); + this.ApplyFilters([], [ Event.RAG_AUTO_DATA_SOURCES_SELECTED ]); // // Load the settings: @@ -253,19 +246,12 @@ public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, I private void HideDataSourceSelection() => this.showDataSourceSelection = false; - #region Implementation of IMessageBusReceiver + #region Overrides of MSGComponentBase - public string ComponentName => nameof(ConfidenceInfo); - - public Task ProcessMessage(ComponentBase? sendingComponent, Event triggeredEvent, T? data) + protected override Task ProcessIncomingMessage(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default { switch (triggeredEvent) { - case Event.COLOR_THEME_CHANGED: - this.showDataSourceSelection = false; - this.StateHasChanged(); - break; - case Event.RAG_AUTO_DATA_SOURCES_SELECTED: if(data is IReadOnlyList aiSelectedDataSources) this.DataSourcesAISelected = aiSelectedDataSources; @@ -273,23 +259,9 @@ public partial class DataSourceSelection : ComponentBase, IMessageBusReceiver, I this.StateHasChanged(); break; } - + return Task.CompletedTask; } - public Task ProcessMessageWithResult(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data) - { - return Task.FromResult(default); - } - - #endregion - - #region Implementation of IDisposable - - public void Dispose() - { - this.MessageBus.Unregister(this); - } - #endregion } \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/ConfirmDialog.razor b/app/MindWork AI Studio/Dialogs/ConfirmDialog.razor index 3f757260..455ac41b 100644 --- a/app/MindWork AI Studio/Dialogs/ConfirmDialog.razor +++ b/app/MindWork AI Studio/Dialogs/ConfirmDialog.razor @@ -1,9 +1,16 @@ +@inherits MSGComponentBase - @this.Message + + @this.Message + - No - Yes + + @T("No") + + + @T("Yes") + \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/ConfirmDialog.razor.cs b/app/MindWork AI Studio/Dialogs/ConfirmDialog.razor.cs index 78fb9ad3..f022152e 100644 --- a/app/MindWork AI Studio/Dialogs/ConfirmDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/ConfirmDialog.razor.cs @@ -1,3 +1,5 @@ +using AIStudio.Components; + using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; @@ -5,7 +7,7 @@ namespace AIStudio.Dialogs; /// /// A confirmation dialog that can be used to ask the user for confirmation. /// -public partial class ConfirmDialog : ComponentBase +public partial class ConfirmDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; diff --git a/app/MindWork AI Studio/Dialogs/ProfileDialog.razor b/app/MindWork AI Studio/Dialogs/ProfileDialog.razor index fb44439a..b7440a40 100644 --- a/app/MindWork AI Studio/Dialogs/ProfileDialog.razor +++ b/app/MindWork AI Studio/Dialogs/ProfileDialog.razor @@ -1,29 +1,23 @@ +@inherits MSGComponentBase - Store personal data about yourself in various profiles so that the AIs know your personal context. - This saves you from having to explain your context each time, for example, in every chat. When you - have different roles, you can create a profile for each role. + @T("Store personal data about yourself in various profiles so that the AIs know your personal context. This saves you from having to explain your context each time, for example, in every chat. When you have different roles, you can create a profile for each role.") - Are you a project manager in a research facility? You might want to create a profile for your project - management activities, one for your scientific work, and a profile for when you need to write program - code. In these profiles, you can record how much experience you have or which methods you like or - dislike using. Later, you can choose when and where you want to use each profile. + @T("Are you a project manager in a research facility? You might want to create a profile for your project management activities, one for your scientific work, and a profile for when you need to write program code. In these profiles, you can record how much experience you have or which methods you like or dislike using. Later, you can choose when and where you want to use each profile.") - The name of the profile is mandatory. Each profile must have a unique name. Whether you provide - information about yourself or only fill out the actions is up to you. Only one of these pieces - is required. + @T("The name of the profile is mandatory. Each profile must have a unique name. Whether you provide information about yourself or only fill out the actions is up to you. Only one of these pieces is required.") @* ReSharper disable once CSharpWarnings::CS8974 *@ - Cancel + + @T("Cancel") + @if(this.IsEditing) { - @:Update + @T("Update") } else { - @:Add + @T("Add") } diff --git a/app/MindWork AI Studio/Dialogs/ProfileDialog.razor.cs b/app/MindWork AI Studio/Dialogs/ProfileDialog.razor.cs index 28b9b4b1..0b2a65a0 100644 --- a/app/MindWork AI Studio/Dialogs/ProfileDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/ProfileDialog.razor.cs @@ -1,10 +1,11 @@ +using AIStudio.Components; using AIStudio.Settings; using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; -public partial class ProfileDialog : ComponentBase +public partial class ProfileDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -45,9 +46,6 @@ public partial class ProfileDialog : ComponentBase [Parameter] public bool IsEditing { get; init; } - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - [Inject] private ILogger Logger { get; init; } = null!; @@ -129,10 +127,10 @@ public partial class ProfileDialog : ComponentBase private string? ValidateNeedToKnow(string text) { if (string.IsNullOrWhiteSpace(this.DataNeedToKnow) && string.IsNullOrWhiteSpace(this.DataActions)) - return "Please enter what the LLM should know about you and/or what actions it should take."; + return T("Please enter what the LLM should know about you and/or what actions it should take."); if(text.Length > 444) - return "The text must not exceed 444 characters."; + return T("The text must not exceed 444 characters."); return null; } @@ -140,10 +138,10 @@ public partial class ProfileDialog : ComponentBase private string? ValidateActions(string text) { if (string.IsNullOrWhiteSpace(this.DataNeedToKnow) && string.IsNullOrWhiteSpace(this.DataActions)) - return "Please enter what the LLM should know about you and/or what actions it should take."; + return T("Please enter what the LLM should know about you and/or what actions it should take."); if(text.Length > 256) - return "The text must not exceed 256 characters."; + return T("The text must not exceed 256 characters."); return null; } @@ -151,15 +149,15 @@ public partial class ProfileDialog : ComponentBase private string? ValidateName(string name) { if (string.IsNullOrWhiteSpace(name)) - return "Please enter a profile name."; + return T("Please enter a profile name."); if (name.Length > 40) - return "The profile name must not exceed 40 characters."; + return T("The profile name must not exceed 40 characters."); // The instance name must be unique: var lowerName = name.ToLowerInvariant(); if (lowerName != this.dataEditingPreviousName && this.UsedNames.Contains(lowerName)) - return "The profile name must be unique; the chosen name is already in use."; + return T("The profile name must be unique; the chosen name is already in use."); return null; } diff --git a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor index 6e28d6fe..4b45637a 100644 --- a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor +++ b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor @@ -1,13 +1,13 @@ @using AIStudio.Provider @using AIStudio.Provider.HuggingFace @using AIStudio.Provider.SelfHosted - +@inherits MSGComponentBase @* ReSharper disable once CSharpWarnings::CS8974 *@ - + @foreach (LLMProviders provider in Enum.GetValues(typeof(LLMProviders))) { @@ -15,7 +15,9 @@ } - Create account + + @T("Create account") + @if (this.DataLLMProvider.IsAPIKeyNeeded(this.DataHost)) @@ -39,7 +41,7 @@ + @foreach (Host host in Enum.GetValues(typeof(Host))) { @@ -62,7 +64,7 @@ @if (this.DataLLMProvider.IsHFInstanceProviderNeeded()) { - + @foreach (HFInferenceProvider inferenceProvider in Enum.GetValues(typeof(HFInferenceProvider))) { @@ -71,7 +73,9 @@ } @* ReSharper disable Asp.Entity *@ - Please double-check if your model name matches the curl specifications provided by the inference provider. If it doesn't, you might get a Not Found error when trying to use the model. Here's a curl example. + + Please double-check if your model name matches the curl specifications provided by the inference provider. If it doesn't, you might get a Not Found error when trying to use the model. Here's a curl example. + @* ReSharper restore Asp.Entity *@ } @@ -80,12 +84,12 @@ @if (this.DataLLMProvider.IsLLMModelProvidedManually()) { - Show available models + @T("Show available models") - Load models + @T("Load models") @if(this.availableModels.Count is 0) { - No models loaded or available. + @T("No models loaded or available.") } else @@ -111,7 +115,9 @@ Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingModel"> @foreach (var model in this.availableModels) { - @model + + @model + } } @@ -123,7 +129,7 @@ - Cancel + + @T("Cancel") + @if(this.IsEditing) { - @:Update + @T("Update") } else { - @:Add + @T("Add") } diff --git a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs index 5be79fa3..562e424e 100644 --- a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs @@ -1,6 +1,6 @@ +using AIStudio.Components; using AIStudio.Provider; using AIStudio.Provider.HuggingFace; -using AIStudio.Settings; using AIStudio.Tools.Services; using AIStudio.Tools.Validation; @@ -13,7 +13,7 @@ namespace AIStudio.Dialogs; /// /// The provider settings dialog. /// -public partial class ProviderDialog : ComponentBase, ISecretId +public partial class ProviderDialog : MSGComponentBase, ISecretId { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -78,9 +78,6 @@ public partial class ProviderDialog : ComponentBase, ISecretId [Parameter] public bool IsEditing { get; init; } - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - [Inject] private ILogger Logger { get; init; } = null!; @@ -182,7 +179,7 @@ public partial class ProviderDialog : ComponentBase, ISecretId this.dataAPIKey = string.Empty; if (this.DataLLMProvider is not LLMProviders.SELF_HOSTED) { - this.dataAPIKeyStorageIssue = $"Failed to load the API key from the operating system. The message was: {requestedSecret.Issue}. You might ignore this message and provide the API key again."; + this.dataAPIKeyStorageIssue = string.Format(T("Failed to load the API key from the operating system. The message was: {0}. You might ignore this message and provide the API key again."), requestedSecret.Issue); await this.form.Validate(); } } @@ -232,7 +229,7 @@ public partial class ProviderDialog : ComponentBase, ISecretId var storeResponse = await this.RustService.SetAPIKey(this, this.dataAPIKey); if (!storeResponse.Success) { - this.dataAPIKeyStorageIssue = $"Failed to store the API key in the operating system. The message was: {storeResponse.Issue}. Please try again."; + this.dataAPIKeyStorageIssue = string.Format(T("Failed to store the API key in the operating system. The message was: {0}. Please try again."), storeResponse.Issue); await this.form.Validate(); return; } @@ -244,7 +241,7 @@ public partial class ProviderDialog : ComponentBase, ISecretId private string? ValidateManuallyModel(string manuallyModel) { if ((this.DataLLMProvider is LLMProviders.FIREWORKS or LLMProviders.HUGGINGFACE) && string.IsNullOrWhiteSpace(manuallyModel)) - return "Please enter a model name."; + return T("Please enter a model name."); return null; } @@ -269,7 +266,7 @@ public partial class ProviderDialog : ComponentBase, ISecretId private string APIKeyText => this.DataLLMProvider switch { - LLMProviders.SELF_HOSTED => "(Optional) API Key", - _ => "API Key", + LLMProviders.SELF_HOSTED => T("(Optional) API Key"), + _ => T("API Key"), }; } \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/SingleInputDialog.razor b/app/MindWork AI Studio/Dialogs/SingleInputDialog.razor index f58d5ecf..1583fc04 100644 --- a/app/MindWork AI Studio/Dialogs/SingleInputDialog.razor +++ b/app/MindWork AI Studio/Dialogs/SingleInputDialog.razor @@ -1,10 +1,17 @@ +@inherits MSGComponentBase - @this.Message - + + @this.Message + + - Cancel - @this.ConfirmText + + @T("Cancel") + + + @this.ConfirmText + \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/SingleInputDialog.razor.cs b/app/MindWork AI Studio/Dialogs/SingleInputDialog.razor.cs index 914b20e4..c4686571 100644 --- a/app/MindWork AI Studio/Dialogs/SingleInputDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/SingleInputDialog.razor.cs @@ -1,10 +1,10 @@ -using AIStudio.Settings; +using AIStudio.Components; using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; -public partial class SingleInputDialog : ComponentBase +public partial class SingleInputDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -21,9 +21,6 @@ public partial class SingleInputDialog : ComponentBase [Parameter] public Color ConfirmColor { get; set; } = Color.Error; - [Inject] - private SettingsManager SettingsManager { get; set; } = null!; - private static readonly Dictionary USER_INPUT_ATTRIBUTES = new(); #region Overrides of ComponentBase diff --git a/app/MindWork AI Studio/Dialogs/UpdateDialog.razor b/app/MindWork AI Studio/Dialogs/UpdateDialog.razor index f3551424..9f3ef694 100644 --- a/app/MindWork AI Studio/Dialogs/UpdateDialog.razor +++ b/app/MindWork AI Studio/Dialogs/UpdateDialog.razor @@ -1,13 +1,18 @@ +@inherits MSGComponentBase - Update from v@(META_DATA.Version) to v@(this.UpdateResponse.NewVersion) + @this.HeaderText - Install later - Install now + + @T("Install later") + + + @T("Install now") + \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/UpdateDialog.razor.cs b/app/MindWork AI Studio/Dialogs/UpdateDialog.razor.cs index 0623b164..51280dce 100644 --- a/app/MindWork AI Studio/Dialogs/UpdateDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/UpdateDialog.razor.cs @@ -1,5 +1,6 @@ using System.Reflection; +using AIStudio.Components; using AIStudio.Tools.Metadata; using AIStudio.Tools.Rust; @@ -10,7 +11,7 @@ namespace AIStudio.Dialogs; /// /// The update dialog that is used to inform the user about an available update. /// -public partial class UpdateDialog : ComponentBase +public partial class UpdateDialog : MSGComponentBase { private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly(); private static readonly MetaDataAttribute META_DATA = ASSEMBLY.GetCustomAttribute()!; @@ -20,7 +21,9 @@ public partial class UpdateDialog : ComponentBase [Parameter] public UpdateResponse UpdateResponse { get; set; } - + + private string HeaderText => string.Format(T("Update from v{0} to v{1}"), META_DATA.Version, this.UpdateResponse.NewVersion); + private void Cancel() => this.MudDialog.Cancel(); private void Confirm() => this.MudDialog.Close(DialogResult.Ok(true)); diff --git a/app/MindWork AI Studio/Dialogs/WorkspaceSelectionDialog.razor b/app/MindWork AI Studio/Dialogs/WorkspaceSelectionDialog.razor index 3c185087..05493cff 100644 --- a/app/MindWork AI Studio/Dialogs/WorkspaceSelectionDialog.razor +++ b/app/MindWork AI Studio/Dialogs/WorkspaceSelectionDialog.razor @@ -1,6 +1,9 @@ +@inherits MSGComponentBase - @this.Message + + @this.Message + @foreach (var (workspaceName, workspaceId) in this.workspaces) { @@ -9,7 +12,11 @@ - Cancel - @this.ConfirmText + + @T("Cancel") + + + @this.ConfirmText + \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/WorkspaceSelectionDialog.razor.cs b/app/MindWork AI Studio/Dialogs/WorkspaceSelectionDialog.razor.cs index f2c3d090..9a096e27 100644 --- a/app/MindWork AI Studio/Dialogs/WorkspaceSelectionDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/WorkspaceSelectionDialog.razor.cs @@ -1,12 +1,13 @@ using System.Text; +using AIStudio.Components; using AIStudio.Settings; using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; -public partial class WorkspaceSelectionDialog : ComponentBase +public partial class WorkspaceSelectionDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;