Added initial logic for jumping between assistant and settings. Currently, it only jumps to the settings page and nothing is expanded.

This commit is contained in:
Peer Schütt 2025-03-07 19:18:23 +01:00
parent 4c1e3afb71
commit bd4c9f7173
47 changed files with 188 additions and 37 deletions

View File

@ -1,6 +1,7 @@
using System.Text;
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.Agenda;
@ -101,6 +102,8 @@ public partial class AssistantAgenda : AssistantBaseCore
protected override Func<Task> SubmitAction => this.CreateAgenda;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_AGENDA_PANEL;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,

View File

@ -12,15 +12,13 @@
<ChildContent>
<MudForm @ref="@(this.form)" @bind-IsValid="@(this.inputIsValid)" @bind-Errors="@(this.inputIssues)" FieldChanged="@this.TriggerFormChange" Class="pr-2">
<MudGrid Class="mb-2">
<MudItem xs="9">
<MudItem xs="10">
<MudText Typo="Typo.body1" Align="Align.Justify">
@this.Description
</MudText>
</MudItem>
<MudItem xs="3" Class="d-flex justify-end align-start">
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Settings">
Settings
</MudButton>
<MudItem xs="2" Class="d-flex justify-end align-start">
<MudIconButton Variant="Variant.Filled" Icon="@Icons.Material.Filled.Settings" OnClick="() => this.NavigateToSettings()"/>
</MudItem>
</MudGrid>

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Provider;
using AIStudio.Settings;
using AIStudio.Tools.Services;
@ -69,6 +70,8 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
protected abstract Func<Task> SubmitAction { get; }
protected abstract SettingsPanel SettingsPanel { get; }
protected virtual bool SubmitDisabled => false;
private protected virtual RenderFragment? Body => null;
@ -317,6 +320,12 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
return icon;
}
protected void NavigateToSettings()
{
MessageBus.INSTANCE.DeferMessage(this, Event.SWITCH_TO_SETTINGS_PANEL, this.SettingsPanel);
this.NavigationManager.NavigateTo(Routes.SETTINGS);
}
protected Task SendToAssistant(Tools.Components destination, SendToButton sendToButton)
{
if (!destination.AllowSendTo())

View File

@ -1,6 +1,7 @@
using System.Text;
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Settings.DataModel;
namespace AIStudio.Assistants.BiasDay;
@ -44,6 +45,8 @@ public partial class BiasOfTheDayAssistant : AssistantBaseCore
protected override Func<Task> SubmitAction => this.TellBias;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_BIAS_OF_THE_DAY_PANEL;
protected override bool ShowSendTo => false;
protected override bool ShowCopyResult => false;

View File

@ -1,4 +1,5 @@
using System.Text;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.Coding;
@ -32,6 +33,8 @@ public partial class AssistantCoding : AssistantBaseCore
protected override Func<Task> SubmitAction => this.GetSupport;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_CODING_PANEL;
protected override void ResetForm()
{
this.codingContexts.Clear();

View File

@ -1,6 +1,7 @@
using System.Text;
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.EMail;
@ -28,6 +29,8 @@ public partial class AssistantEMail : AssistantBaseCore
protected override Func<Task> SubmitAction => this.CreateMail;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_EMAIL_PANEL;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,

View File

@ -2,6 +2,7 @@ using System.Text;
using System.Text.RegularExpressions;
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs;
using AIStudio.Settings.DataModel;
@ -306,6 +307,8 @@ public partial class AssistantERI : AssistantBaseCore
protected override Func<Task> SubmitAction => this.GenerateServer;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_ERI_SERVER_PANEL;
protected override bool SubmitDisabled => this.IsNoneERIServerSelected;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.GrammarSpelling;
@ -43,6 +44,8 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore
protected override Func<Task> SubmitAction => this.ProofreadText;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_GRAMMAR_SPELLING_PANEL;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,

View File

@ -1,3 +1,5 @@
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.IconFinder;
public partial class AssistantIconFinder : AssistantBaseCore
@ -33,6 +35,8 @@ public partial class AssistantIconFinder : AssistantBaseCore
protected override Func<Task> SubmitAction => this.FindIcon;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_ICON_FINDER_PANEL;
protected override void ResetForm()
{
this.inputContext = string.Empty;

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.JobPosting;
@ -50,6 +51,8 @@ public partial class AssistantJobPostings : AssistantBaseCore
protected override Func<Task> SubmitAction => this.CreateJobPosting;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_JOB_POSTING_PANEL;
protected override bool SubmitDisabled => false;
protected override bool AllowProfiles => false;

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.LegalCheck;
@ -30,6 +31,8 @@ public partial class AssistantLegalCheck : AssistantBaseCore
protected override Func<Task> SubmitAction => this.AksQuestions;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_LEGAL_CHECK_PANEL;
protected override bool SubmitDisabled => this.isAgentRunning;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Settings;
namespace AIStudio.Assistants.MyTasks;
@ -34,6 +35,8 @@ public partial class AssistantMyTasks : AssistantBaseCore
protected override Func<Task> SubmitAction => this.AnalyzeText;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_MY_TASKS_PANEL;
protected override bool ShowProfileSelection => false;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.RewriteImprove;
@ -44,6 +45,8 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
protected override Func<Task> SubmitAction => this.RewriteText;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_REWRITE_PANEL;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.Synonym;
@ -55,6 +56,8 @@ public partial class AssistantSynonyms : AssistantBaseCore
protected override Func<Task> SubmitAction => this.FindSynonyms;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_SYNONYMS_PANEL;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.TextSummarizer;
@ -33,6 +34,8 @@ public partial class AssistantTextSummarizer : AssistantBaseCore
protected override Func<Task> SubmitAction => this.SummarizeText;
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_TEXT_SUMMARIZER_PANEL;
protected override bool SubmitDisabled => this.isAgentRunning;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with

View File

@ -1,4 +1,5 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
namespace AIStudio.Assistants.Translation;
@ -29,6 +30,8 @@ public partial class AssistantTranslation : AssistantBaseCore
protected override Func<Task> SubmitAction => () => this.TranslateText(true);
protected override SettingsPanel SettingsPanel => SettingsPanel.ASSISTANT_TRANSLATION_PANEL;
protected override bool SubmitDisabled => this.isAgentRunning;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with

View File

@ -17,8 +17,15 @@
</MudStack>
</MudCardContent>
<MudCardActions>
<MudButton Size="Size.Large" Variant="Variant.Filled" StartIcon="@this.Icon" Color="Color.Default" Href="@this.Link">
@this.ButtonText
</MudButton>
<MudGrid Class="mb-1">
<MudItem xs="9">
<MudButton Size="Size.Large" Variant="Variant.Filled" StartIcon="@this.Icon" Color="Color.Default" Href="@this.Link">
@this.ButtonText
</MudButton>
</MudItem>
<MudItem xs="3">
<MudIconButton Size="Size.Large" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Settings" Color="Color.Default" Href="@this.Link"/>
</MudItem>
</MudGrid>
</MudCardActions>
</MudCard>

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelAgenda : SettingsPanelBase;
public partial class SettingsPanelAgenda : SettingsPanelBase
{
protected override SettingsPanel Type { get; }
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelAgentContentCleaner : SettingsPanelBase;
public partial class SettingsPanelAgentContentCleaner : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.AGENT_CONTENT_CLEANER_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelAgentDataSourceSelection : SettingsPanelBase;
public partial class SettingsPanelAgentDataSourceSelection : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.AGENT_DATA_SOURCE_SELECTION_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelAgentRetrievalContextValidation : SettingsPanelBase;
public partial class SettingsPanelAgentRetrievalContextValidation : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.AGENT_RETRIEVAL_CONTEXT_VALIDATION_PANEL;
}

View File

@ -9,4 +9,6 @@ public partial class SettingsPanelApp : SettingsPanelBase
this.SettingsManager.ConfigurationData.App.PreviewVisibility = previewVisibility;
this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = previewVisibility.FilterPreviewFeatures(this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures);
}
protected override SettingsPanel Type => SettingsPanel.APP_PANEL;
}

View File

@ -24,4 +24,6 @@ public partial class SettingsPanelAssistantBias : SettingsPanelBase
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
}
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_BIAS_OF_THE_DAY_PANEL;
}

View File

@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using AIStudio.Settings;
using AIStudio.Tools.Services;
@ -10,6 +11,11 @@ public abstract class SettingsPanelBase : ComponentBase
[Parameter]
public Func<IReadOnlyList<ConfigurationSelectData<string>>> AvailableLLMProvidersFunc { get; set; } = () => [];
[Parameter]
public SettingsPanel ChosenPanel { get; set; }
protected abstract SettingsPanel Type { get; }
[Inject]
protected SettingsManager SettingsManager { get; init; } = null!;
@ -21,4 +27,6 @@ public abstract class SettingsPanelBase : ComponentBase
[Inject]
protected RustService RustService { get; init; } = null!;
protected bool IsExtended() => this.Type == this.ChosenPanel;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelChat : SettingsPanelBase;
public partial class SettingsPanelChat : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.CHAT_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelCoding : SettingsPanelBase;
public partial class SettingsPanelCoding : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_CODING_PANEL;
}

View File

@ -256,4 +256,6 @@ public partial class SettingsPanelDataSources : SettingsPanelBase
await this.AvailableDataSourcesChanged.InvokeAsync(this.AvailableDataSources);
}
protected override SettingsPanel Type => SettingsPanel.DATA_SOURCES_PANEL;
}

View File

@ -1,7 +1,7 @@
@using AIStudio.Settings
@inherits SettingsPanelBase
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.PrivateConnectivity" HeaderText="Assistant: ERI Server Options">
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.PrivateConnectivity" HeaderText="Assistant: ERI Server Options" IsExpanded="@this.IsExtended()">
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
<ConfigurationOption OptionDescription="Preselect ERI server options?" LabelOn="ERI server options are preselected" LabelOff="No ERI server options are preselected" State="@(() => this.SettingsManager.ConfigurationData.ERI.PreselectOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.ERI.PreselectOptions = updatedState)" OptionHelp="When enabled, you can preselect some ERI server options."/>
<ConfigurationMinConfidenceSelection Disabled="@(() => !this.SettingsManager.ConfigurationData.ERI.PreselectOptions)" RestrictToGlobalMinimumConfidence="@true" SelectedValue="@(() => this.SettingsManager.ConfigurationData.ERI.MinimumProviderConfidence)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.ERI.MinimumProviderConfidence = selectedValue)"/>

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelERIServer : SettingsPanelBase;
public partial class SettingsPanelERIServer : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_ERI_SERVER_PANEL;
}

View File

@ -119,4 +119,6 @@ public partial class SettingsPanelEmbeddings : SettingsPanelBase
await this.AvailableEmbeddingProvidersChanged.InvokeAsync(this.AvailableEmbeddingProviders);
}
protected override SettingsPanel Type => SettingsPanel.EMBEDDINGS_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelGrammarSpelling : SettingsPanelBase;
public partial class SettingsPanelGrammarSpelling : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_GRAMMAR_SPELLING_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelIconFinder : SettingsPanelBase;
public partial class SettingsPanelIconFinder : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_ICON_FINDER_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelJobPostings : SettingsPanelBase;
public partial class SettingsPanelJobPostings : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_JOB_POSTING_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelLegalCheck : SettingsPanelBase;
public partial class SettingsPanelLegalCheck : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_LEGAL_CHECK_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelMyTasks : SettingsPanelBase;
public partial class SettingsPanelMyTasks : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_MY_TASKS_PANEL;
}

View File

@ -69,4 +69,6 @@ public partial class SettingsPanelProfiles : SettingsPanelBase
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
}
protected override SettingsPanel Type => SettingsPanel.PROFILES_PANEL;
}

View File

@ -148,4 +148,6 @@ public partial class SettingsPanelProviders : SettingsPanelBase
this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme[llmProvider] = level;
await this.SettingsManager.StoreSettings();
}
protected override SettingsPanel Type => SettingsPanel.PROVIDER_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelRewrite : SettingsPanelBase;
public partial class SettingsPanelRewrite : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_REWRITE_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelSynonyms : SettingsPanelBase;
public partial class SettingsPanelSynonyms : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_SYNONYMS_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelTextSummarizer : SettingsPanelBase;
public partial class SettingsPanelTextSummarizer : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_TEXT_SUMMARIZER_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelTranslation : SettingsPanelBase;
public partial class SettingsPanelTranslation : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_TRANSLATION_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelWorkspaces : SettingsPanelBase;
public partial class SettingsPanelWorkspaces : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.WORKSPACE_PANEL;
}

View File

@ -1,3 +1,6 @@
namespace AIStudio.Components.Settings;
public partial class SettingsPanelWritingEMails : SettingsPanelBase;
public partial class SettingsPanelWritingEMails : SettingsPanelBase
{
protected override SettingsPanel Type => SettingsPanel.ASSISTANT_EMAIL_PANEL;
}

View File

@ -24,7 +24,7 @@
@if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager))
{
<SettingsPanelERIServer AvailableLLMProvidersFunc="() => this.availableLLMProviders"/>
<SettingsPanelERIServer AvailableLLMProvidersFunc="() => this.availableLLMProviders" />
}
<SettingsPanelTextSummarizer AvailableLLMProvidersFunc="() => this.availableLLMProviders" />

View File

@ -1,3 +1,4 @@
using AIStudio.Components.Settings;
using AIStudio.Settings;
using Microsoft.AspNetCore.Components;
@ -15,6 +16,7 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
private List<ConfigurationSelectData<string>> availableLLMProviders = new();
private List<ConfigurationSelectData<string>> availableEmbeddingProviders = new();
private List<ConfigurationSelectData<string>> availableDataSources = new();
private SettingsPanel chosenSettingsPanel;
#region Overrides of ComponentBase
@ -24,6 +26,18 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
this.MessageBus.RegisterComponent(this);
this.MessageBus.ApplyFilters(this, [], [ Event.CONFIGURATION_CHANGED ]);
this.chosenSettingsPanel = MessageBus.INSTANCE.CheckDeferredMessages<SettingsPanel>(Event.SWITCH_TO_SETTINGS_PANEL).FirstOrDefault();
// var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<SettingsPanel>(Event.SWITCH_TO_SETTINGS_PANEL).FirstOrDefault();
//if (deferredContent != default)
//{
//switch (deferredContent)
//{
// case SettingsPanel -am besten nicht alle individuell
//}
//}
//chosenSettingsPanel = deferredContent;
await base.OnInitializedAsync();
}

View File

@ -26,4 +26,7 @@ public sealed partial class Routes
public const string ASSISTANT_BIAS = "/assistant/bias-of-the-day";
public const string ASSISTANT_ERI = "/assistant/eri";
// ReSharper restore InconsistentNaming
public const string SETTINGS_ICON_FINDER = "/settings/icons";
}

View File

@ -40,4 +40,7 @@ public enum Event
SEND_TO_SYNONYMS_ASSISTANT,
SEND_TO_MY_TASKS_ASSISTANT,
SEND_TO_JOB_POSTING_ASSISTANT,
// Setting events:
SWITCH_TO_SETTINGS_PANEL,
}