From 8518fadd1a10312d8807d6b60d2094ef0a473cb6 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Wed, 12 Mar 2025 18:03:54 +0100 Subject: [PATCH] Refactor AssistantBase to inherit from AssistantLowerBase and update related references --- .../Assistants/AssistantBase.razor | 1 + .../Assistants/AssistantBase.razor.cs | 8 +------- .../Assistants/AssistantLowerBase.cs | 12 ++++++++++++ app/MindWork AI Studio/Tools/JsRuntimeExtensions.cs | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 app/MindWork AI Studio/Assistants/AssistantLowerBase.cs diff --git a/app/MindWork AI Studio/Assistants/AssistantBase.razor b/app/MindWork AI Studio/Assistants/AssistantBase.razor index 21d92846..634b55e4 100644 --- a/app/MindWork AI Studio/Assistants/AssistantBase.razor +++ b/app/MindWork AI Studio/Assistants/AssistantBase.razor @@ -1,4 +1,5 @@ @using AIStudio.Chat +@inherits AssistantLowerBase @typeparam TSettings
diff --git a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs index 4fd10eb0..0b3986f2 100644 --- a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs +++ b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs @@ -15,7 +15,7 @@ using DialogOptions = AIStudio.Dialogs.DialogOptions; namespace AIStudio.Assistants; -public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver, IDisposable where TSettings : IComponent +public abstract partial class AssistantBase : AssistantLowerBase, IMessageBusReceiver, IDisposable where TSettings : IComponent { [Inject] protected SettingsManager SettingsManager { get; init; } = null!; @@ -50,10 +50,6 @@ public abstract partial class AssistantBase : ComponentBase, IMessage [Inject] private MessageBus MessageBus { get; init; } = null!; - internal const string RESULT_DIV_ID = "assistantResult"; - internal const string BEFORE_RESULT_DIV_ID = "beforeAssistantResult"; - internal const string AFTER_RESULT_DIV_ID = "afterAssistantResult"; - protected abstract string Title { get; } protected abstract string Description { get; } @@ -99,8 +95,6 @@ public abstract partial class AssistantBase : ComponentBase, IMessage protected virtual ChatThread ConvertToChatThread => this.chatThread ?? new(); protected virtual IReadOnlyList FooterButtons => []; - - protected static readonly Dictionary USER_INPUT_ATTRIBUTES = new(); protected AIStudio.Settings.Provider providerSettings; protected MudForm? form; diff --git a/app/MindWork AI Studio/Assistants/AssistantLowerBase.cs b/app/MindWork AI Studio/Assistants/AssistantLowerBase.cs new file mode 100644 index 00000000..8e053015 --- /dev/null +++ b/app/MindWork AI Studio/Assistants/AssistantLowerBase.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Components; + +namespace AIStudio.Assistants; + +public abstract class AssistantLowerBase : ComponentBase +{ + protected static readonly Dictionary USER_INPUT_ATTRIBUTES = new(); + + internal const string RESULT_DIV_ID = "assistantResult"; + internal const string BEFORE_RESULT_DIV_ID = "beforeAssistantResult"; + internal const string AFTER_RESULT_DIV_ID = "afterAssistantResult"; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/JsRuntimeExtensions.cs b/app/MindWork AI Studio/Tools/JsRuntimeExtensions.cs index e00cf16a..52671f93 100644 --- a/app/MindWork AI Studio/Tools/JsRuntimeExtensions.cs +++ b/app/MindWork AI Studio/Tools/JsRuntimeExtensions.cs @@ -7,7 +7,7 @@ public static class JsRuntimeExtensions { public static async Task GenerateAndShowDiff(this IJSRuntime jsRuntime, string text1, string text2) { - await jsRuntime.InvokeVoidAsync("generateDiff", text1, text2, AssistantBase.RESULT_DIV_ID, AssistantBase.BEFORE_RESULT_DIV_ID); + await jsRuntime.InvokeVoidAsync("generateDiff", text1, text2, AssistantLowerBase.RESULT_DIV_ID, AssistantLowerBase.BEFORE_RESULT_DIV_ID); } public static async Task ClearDiv(this IJSRuntime jsRuntime, string divId)