diff --git a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs index 1a9ff997..877374ad 100644 --- a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs +++ b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs @@ -13,11 +13,8 @@ using DialogOptions = AIStudio.Dialogs.DialogOptions; namespace AIStudio.Assistants; -public abstract partial class AssistantBase : AssistantLowerBase, IMessageBusReceiver, IDisposable where TSettings : IComponent +public abstract partial class AssistantBase : AssistantLowerBase where TSettings : IComponent { - [Inject] - protected SettingsManager SettingsManager { get; init; } = null!; - [Inject] private IDialogService DialogService { get; init; } = null!; @@ -42,9 +39,6 @@ public abstract partial class AssistantBase : AssistantLowerBase, IMe [Inject] private MudTheme ColorTheme { get; init; } = null!; - [Inject] - private MessageBus MessageBus { get; init; } = null!; - protected abstract string Title { get; } protected abstract string Description { get; } @@ -119,10 +113,6 @@ public abstract partial class AssistantBase : AssistantLowerBase, IMe this.MightPreselectValues(); this.providerSettings = this.SettingsManager.GetPreselectedProvider(this.Component); this.currentProfile = this.SettingsManager.GetPreselectedProfile(this.Component); - - this.MessageBus.RegisterComponent(this); - this.MessageBus.ApplyFilters(this, [], [ Event.COLOR_THEME_CHANGED ]); - await base.OnInitializedAsync(); } @@ -144,29 +134,6 @@ public abstract partial class AssistantBase : AssistantLowerBase, IMe await base.OnAfterRenderAsync(firstRender); } - #endregion - - #region Implementation of IMessageBusReceiver - - public string ComponentName => nameof(AssistantBase); - - public Task ProcessMessage(ComponentBase? sendingComponent, Event triggeredEvent, T? data) - { - switch (triggeredEvent) - { - case Event.COLOR_THEME_CHANGED: - this.StateHasChanged(); - break; - } - - return Task.CompletedTask; - } - - public Task ProcessMessageWithResult(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data) - { - return Task.FromResult(default); - } - #endregion private string SubmitButtonStyle => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? this.providerSettings.UsedLLMProvider.GetConfidence(this.SettingsManager).StyleBorder(this.SettingsManager) : string.Empty; @@ -226,7 +193,7 @@ public abstract partial class AssistantBase : AssistantLowerBase, IMe SystemPrompt = this.SystemPrompt, WorkspaceId = Guid.Empty, ChatId = Guid.NewGuid(), - Name = $"Assistant - {this.Title}", + Name = string.Format(T("Assistant - {0}"), this.Title), Seed = this.RNG.Next(), Blocks = [], }; @@ -399,11 +366,10 @@ public abstract partial class AssistantBase : AssistantLowerBase, IMe false => $"background-color: {this.ColorTheme.GetCurrentPalette(this.SettingsManager).InfoLighten}", }; - #region Implementation of IDisposable + #region Overrides of MSGComponentBase - public void Dispose() + protected override void DisposeResources() { - this.MessageBus.Unregister(this); this.formChangeTimer.Dispose(); } diff --git a/app/MindWork AI Studio/Assistants/AssistantLowerBase.cs b/app/MindWork AI Studio/Assistants/AssistantLowerBase.cs index 8e053015..2f9e804f 100644 --- a/app/MindWork AI Studio/Assistants/AssistantLowerBase.cs +++ b/app/MindWork AI Studio/Assistants/AssistantLowerBase.cs @@ -1,8 +1,8 @@ -using Microsoft.AspNetCore.Components; +using AIStudio.Components; namespace AIStudio.Assistants; -public abstract class AssistantLowerBase : ComponentBase +public abstract class AssistantLowerBase : MSGComponentBase { protected static readonly Dictionary USER_INPUT_ATTRIBUTES = new(); diff --git a/app/MindWork AI Studio/Assistants/EMail/AssistantEMail.razor b/app/MindWork AI Studio/Assistants/EMail/AssistantEMail.razor index 7a441dc0..9220f499 100644 --- a/app/MindWork AI Studio/Assistants/EMail/AssistantEMail.razor +++ b/app/MindWork AI Studio/Assistants/EMail/AssistantEMail.razor @@ -1,23 +1,25 @@ @attribute [Route(Routes.ASSISTANT_EMAIL)] @inherits AssistantBaseCore - + @if (this.provideHistory) { - + } - - - + + + @foreach (var contentLine in this.bulletPointsLines) { - @contentLine + + @contentLine + } - - - + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Assistants/EMail/AssistantEMail.razor.cs b/app/MindWork AI Studio/Assistants/EMail/AssistantEMail.razor.cs index 7a91f1c8..cc0629d0 100644 --- a/app/MindWork AI Studio/Assistants/EMail/AssistantEMail.razor.cs +++ b/app/MindWork AI Studio/Assistants/EMail/AssistantEMail.razor.cs @@ -9,12 +9,9 @@ public partial class AssistantEMail : AssistantBaseCore Tools.Components.EMAIL_ASSISTANT; - protected override string Title => "E-Mail"; + protected override string Title => T("E-Mail"); - protected override string Description => - """ - Provide a list of bullet points and some basic information for an e-mail. The assistant will generate an e-mail based on that input. - """; + protected override string Description => T("Provide a list of bullet points and some basic information for an e-mail. The assistant will generate an e-mail based on that input."); protected override string SystemPrompt => $""" @@ -25,7 +22,7 @@ public partial class AssistantEMail : AssistantBaseCore FooterButtons => []; - protected override string SubmitText => "Create email"; + protected override string SubmitText => T("Create email"); protected override Func SubmitAction => this.CreateMail; @@ -100,12 +97,12 @@ public partial class AssistantEMail : AssistantBaseCore - - + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Assistants/GrammarSpelling/AssistantGrammarSpelling.razor.cs b/app/MindWork AI Studio/Assistants/GrammarSpelling/AssistantGrammarSpelling.razor.cs index 4a0e53c1..6025f133 100644 --- a/app/MindWork AI Studio/Assistants/GrammarSpelling/AssistantGrammarSpelling.razor.cs +++ b/app/MindWork AI Studio/Assistants/GrammarSpelling/AssistantGrammarSpelling.razor.cs @@ -7,12 +7,9 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore Tools.Components.GRAMMAR_SPELLING_ASSISTANT; - protected override string Title => "Grammar & Spelling Checker"; + protected override string Title => T("Grammar & Spelling Checker"); - protected override string Description => - """ - Check the grammar and spelling of a text. - """; + protected override string Description => T("Check the grammar and spelling of a text."); protected override string SystemPrompt => $""" @@ -40,7 +37,7 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore "Proofread"; + protected override string SubmitText => T("Proofread"); protected override Func SubmitAction => this.ProofreadText; @@ -93,7 +90,7 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore