Included a settings icon to every assistant that lets you edit the settings (#327)

This commit is contained in:
Peer Schütt authored and GitHub committed 2025-03-12 11:31:01 +01:00
1 parent 8a23b54e56
commit 200964422d
98 files changed
+685 -411

No files matched your search

@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_AGENDA)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogAgenda>
<MudTextField T="string" @bind-Text="@this.inputName" Validation="@this.ValidateName" Label="Meeting Name" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Tag" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Name the meeting, seminar, etc." Placeholder="Weekly jour fixe" Class="mb-3"/>
<MudTextField T="string" @bind-Text="@this.inputTopic" Validation="@this.ValidateTopic" Label="Topic" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.EventNote" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Describe the topic of the meeting, seminar, etc. Is it about quantum computing, software engineering, or is it a general business meeting?" Placeholder="Project meeting" Class="mb-3"/>
@@ -1,10 +1,12 @@
using System.Text;
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.Agenda;
public partial class AssistantAgenda : AssistantBaseCore
public partial class AssistantAgenda : AssistantBaseCore<SettingsDialogAgenda>
{
public override Tools.Components Component => Tools.Components.AGENDA_ASSISTANT;
@@ -1,4 +1,5 @@
@using AIStudio.Chat
@typeparam TSettings
<div class="inner-scrolling-context">
@@ -9,9 +10,16 @@
<InnerScrolling>
<ChildContent>
<MudForm @ref="@(this.form)" @bind-IsValid="@(this.inputIsValid)" @bind-Errors="@(this.inputIssues)" FieldChanged="@this.TriggerFormChange" Class="pr-2">
<MudText Typo="Typo.body1" Align="Align.Justify" Class="mb-6">
@this.Description
</MudText>
<MudGrid Class="mb-2">
<MudItem xs="10">
<MudText Typo="Typo.body1" Align="Align.Justify">
@this.Description
</MudText>
</MudItem>
<MudItem xs="2" Class="d-flex justify-end align-start">
<MudIconButton Variant="Variant.Filled" Icon="@Icons.Material.Filled.Settings" OnClick="() => this.OpenSettingsDialog()"/>
</MudItem>
</MudGrid>
@if (this.Body is not null)
{
@@ -22,6 +30,7 @@
<MudButton Disabled="@this.SubmitDisabled" Variant="Variant.Filled" Class="mb-3" OnClick="() => this.SubmitAction()" Style="@this.SubmitButtonStyle">
@this.SubmitText
</MudButton>
}
</MudForm>
<Issues IssuesData="@(this.inputIssues)"/>
@@ -1,4 +1,6 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
using AIStudio.Provider;
using AIStudio.Settings;
using AIStudio.Tools.Services;
@@ -9,13 +11,18 @@ using MudBlazor.Utilities;
using Timer = System.Timers.Timer;
using DialogOptions = AIStudio.Dialogs.DialogOptions;
namespace AIStudio.Assistants;
public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver, IDisposable
public abstract partial class AssistantBase<TSettings> : ComponentBase, IMessageBusReceiver, IDisposable where TSettings : IComponent
{
[Inject]
protected SettingsManager SettingsManager { get; init; } = null!;
[Inject]
private IDialogService DialogService { get; init; } = null!;
[Inject]
protected IJSRuntime JsRuntime { get; init; } = null!;
@@ -35,7 +42,7 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
protected NavigationManager NavigationManager { get; init; } = null!;
[Inject]
protected ILogger<AssistantBase> Logger { get; init; } = null!;
protected ILogger<AssistantBase<TSettings>> Logger { get; init; } = null!;
[Inject]
private MudTheme ColorTheme { get; init; } = null!;
@@ -68,7 +75,7 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
protected abstract string SubmitText { get; }
protected abstract Func<Task> SubmitAction { get; }
protected virtual bool SubmitDisabled => false;
private protected virtual RenderFragment? Body => null;
@@ -151,7 +158,7 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(AssistantBase);
public string ComponentName => nameof(AssistantBase<TSettings>);
public Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
@@ -315,6 +322,12 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
return icon;
}
protected async Task OpenSettingsDialog()
{
var dialogParameters = new DialogParameters();
await this.DialogService.ShowAsync<TSettings>("Open Settings", dialogParameters, DialogOptions.FULLSCREEN);
}
protected Task SendToAssistant(Tools.Components destination, SendToButton sendToButton)
{
if (!destination.AllowSendTo())
@@ -7,7 +7,7 @@ namespace AIStudio.Assistants;
// See https://stackoverflow.com/a/77300384/2258393 for why this class is necessary
//
public abstract class AssistantBaseCore : AssistantBase
public abstract class AssistantBaseCore<TSettings> : AssistantBase<TSettings> where TSettings : IComponent
{
private protected sealed override RenderFragment Body => this.BuildRenderTree;
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_BIAS)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogAssistantBias>
<MudText Typo="Typo.body1">
<b>Links:</b>
@@ -1,11 +1,13 @@
using System.Text;
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
using AIStudio.Settings.DataModel;
namespace AIStudio.Assistants.BiasDay;
public partial class BiasOfTheDayAssistant : AssistantBaseCore
public partial class BiasOfTheDayAssistant : AssistantBaseCore<SettingsDialogAssistantBias>
{
public override Tools.Components Component => Tools.Components.BIAS_DAY_ASSISTANT;
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_CODING)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogCoding>
<MudExpansionPanels Class="mb-3">
@for (var contextIndex = 0; contextIndex < this.codingContexts.Count; contextIndex++)
@@ -1,8 +1,10 @@
using System.Text;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.Coding;
public partial class AssistantCoding : AssistantBaseCore
public partial class AssistantCoding : AssistantBaseCore<SettingsDialogCoding>
{
public override Tools.Components Component => Tools.Components.CODING_ASSISTANT;
@@ -31,7 +33,7 @@ public partial class AssistantCoding : AssistantBaseCore
protected override string SubmitText => "Get Support";
protected override Func<Task> SubmitAction => this.GetSupport;
protected override void ResetForm()
{
this.codingContexts.Clear();
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_EMAIL)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogWritingEMails>
<MudTextSwitch Label="Is there a history, a previous conversation?" @bind-Value="@this.provideHistory" LabelOn="Yes, I provide the previous conversation" LabelOff="No, I don't provide a previous conversation" />
@if (this.provideHistory)
@@ -1,10 +1,12 @@
using System.Text;
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.EMail;
public partial class AssistantEMail : AssistantBaseCore
public partial class AssistantEMail : AssistantBaseCore<SettingsDialogWritingEMails>
{
public override Tools.Components Component => Tools.Components.EMAIL_ASSISTANT;
@@ -27,7 +29,7 @@ public partial class AssistantEMail : AssistantBaseCore
protected override string SubmitText => "Create email";
protected override Func<Task> SubmitAction => this.CreateMail;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
@@ -1,7 +1,7 @@
@attribute [Route(Routes.ASSISTANT_ERI)]
@using AIStudio.Settings.DataModel
@using MudExtensions
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogERIServer>
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
You can imagine it like this: Hypothetically, when Wikipedia implemented the ERI, it would vectorize
@@ -2,7 +2,9 @@ using System.Text;
using System.Text.RegularExpressions;
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs;
using AIStudio.Dialogs.Settings;
using AIStudio.Settings.DataModel;
using Microsoft.AspNetCore.Components;
@@ -11,7 +13,7 @@ using DialogOptions = AIStudio.Dialogs.DialogOptions;
namespace AIStudio.Assistants.ERI;
public partial class AssistantERI : AssistantBaseCore
public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
{
[Inject]
private HttpClient HttpClient { get; set; } = null!;
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_GRAMMAR_SPELLING)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogGrammarSpelling>
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to check" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelectingOptional())" @bind-Value="@this.selectedTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Language" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="Custom language" />
@@ -1,8 +1,10 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.GrammarSpelling;
public partial class AssistantGrammarSpelling : AssistantBaseCore
public partial class AssistantGrammarSpelling : AssistantBaseCore<SettingsDialogGrammarSpelling>
{
public override Tools.Components Component => Tools.Components.GRAMMAR_SPELLING_ASSISTANT;
@@ -42,7 +44,7 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore
protected override string SubmitText => "Proofread";
protected override Func<Task> SubmitAction => this.ProofreadText;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_ICON_FINDER)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogIconFinder>
<MudTextField T="string" @bind-Text="@this.inputContext" Validation="@this.ValidatingContext" AdornmentIcon="@Icons.Material.Filled.Description" Adornment="Adornment.Start" Label="Your context" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
@@ -1,6 +1,9 @@
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.IconFinder;
public partial class AssistantIconFinder : AssistantBaseCore
public partial class AssistantIconFinder : AssistantBaseCore<SettingsDialogIconFinder>
{
public override Tools.Components Component => Tools.Components.ICON_FINDER_ASSISTANT;
@@ -32,7 +35,7 @@ public partial class AssistantIconFinder : AssistantBaseCore
protected override string SubmitText => "Find Icon";
protected override Func<Task> SubmitAction => this.FindIcon;
protected override void ResetForm()
{
this.inputContext = string.Empty;
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_JOB_POSTING)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogJobPostings>
<MudTextField T="string" @bind-Text="@this.inputCompanyName" Label="(Optional) The company name" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Warehouse" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>
<MudTextField T="string" @bind-Text="@this.inputCountryLegalFramework" Label="Provide the country, where the company is located" Validation="@this.ValidateCountryLegalFramework" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Flag" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3" HelperText="This is important to consider the legal framework of the country."/>
@@ -1,8 +1,10 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.JobPosting;
public partial class AssistantJobPostings : AssistantBaseCore
public partial class AssistantJobPostings : AssistantBaseCore<SettingsDialogJobPostings>
{
public override Tools.Components Component => Tools.Components.JOB_POSTING_ASSISTANT;
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_LEGAL_CHECK)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogLegalCheck>
@if (!this.SettingsManager.ConfigurationData.LegalCheck.HideWebContentReader)
{
@@ -1,8 +1,10 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.LegalCheck;
public partial class AssistantLegalCheck : AssistantBaseCore
public partial class AssistantLegalCheck : AssistantBaseCore<SettingsDialogLegalCheck>
{
public override Tools.Components Component => Tools.Components.LEGAL_CHECK_ASSISTANT;
@@ -29,7 +31,7 @@ public partial class AssistantLegalCheck : AssistantBaseCore
protected override string SubmitText => "Ask your questions";
protected override Func<Task> SubmitAction => this.AksQuestions;
protected override bool SubmitDisabled => this.isAgentRunning;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_MY_TASKS)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogMyTasks>
<ProfileFormSelection Validation="@this.ValidateProfile" @bind-Profile="@this.currentProfile"/>
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Text or email" Variant="Variant.Outlined" Lines="12" AutoGrow="@true" MaxLines="24" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
@@ -1,9 +1,11 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
using AIStudio.Settings;
namespace AIStudio.Assistants.MyTasks;
public partial class AssistantMyTasks : AssistantBaseCore
public partial class AssistantMyTasks : AssistantBaseCore<SettingsDialogMyTasks>
{
public override Tools.Components Component => Tools.Components.MY_TASKS_ASSISTANT;
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_REWRITE)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogRewrite>
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to improve" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelectingOptional())" @bind-Value="@this.selectedTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Language" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="Custom language" />
@@ -1,8 +1,10 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.RewriteImprove;
public partial class AssistantRewriteImprove : AssistantBaseCore
public partial class AssistantRewriteImprove : AssistantBaseCore<SettingsDialogRewrite>
{
public override Tools.Components Component => Tools.Components.REWRITE_ASSISTANT;
@@ -43,7 +45,7 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
protected override string SubmitText => "Improve";
protected override Func<Task> SubmitAction => this.RewriteText;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_SYNONYMS)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogSynonyms>
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.Spellcheck" Adornment="Adornment.Start" Label="Your word or phrase" Variant="Variant.Outlined" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
<MudTextField T="string" @bind-Text="@this.inputContext" AdornmentIcon="@Icons.Material.Filled.Description" Adornment="Adornment.Start" Lines="2" AutoGrow="@false" Label="(Optional) The context for the given word or phrase" Variant="Variant.Outlined" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
@@ -1,8 +1,9 @@
using AIStudio.Chat;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.Synonym;
public partial class AssistantSynonyms : AssistantBaseCore
public partial class AssistantSynonyms : AssistantBaseCore<SettingsDialogSynonyms>
{
public override Tools.Components Component => Tools.Components.SYNONYMS_ASSISTANT;
@@ -54,7 +55,7 @@ public partial class AssistantSynonyms : AssistantBaseCore
protected override string SubmitText => "Find synonyms";
protected override Func<Task> SubmitAction => this.FindSynonyms;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_SUMMARIZER)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogTextSummarizer>
@if (!this.SettingsManager.ConfigurationData.TextSummarizer.HideWebContentReader)
{
@@ -1,8 +1,10 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.TextSummarizer;
public partial class AssistantTextSummarizer : AssistantBaseCore
public partial class AssistantTextSummarizer : AssistantBaseCore<SettingsDialogTextSummarizer>
{
public override Tools.Components Component => Tools.Components.TEXT_SUMMARIZER_ASSISTANT;
@@ -32,7 +34,7 @@ public partial class AssistantTextSummarizer : AssistantBaseCore
protected override string SubmitText => "Summarize";
protected override Func<Task> SubmitAction => this.SummarizeText;
protected override bool SubmitDisabled => this.isAgentRunning;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
@@ -1,5 +1,5 @@
@attribute [Route(Routes.ASSISTANT_TRANSLATION)]
@inherits AssistantBaseCore
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogTranslation>
@if (!this.SettingsManager.ConfigurationData.Translation.HideWebContentReader)
{
@@ -1,8 +1,10 @@
using AIStudio.Chat;
using AIStudio.Components.Settings;
using AIStudio.Dialogs.Settings;
namespace AIStudio.Assistants.Translation;
public partial class AssistantTranslation : AssistantBaseCore
public partial class AssistantTranslation : AssistantBaseCore<SettingsDialogTranslation>
{
public override Tools.Components Component => Tools.Components.TRANSLATION_ASSISTANT;
@@ -28,7 +30,7 @@ public partial class AssistantTranslation : AssistantBaseCore
protected override string SubmitText => "Translate";
protected override Func<Task> SubmitAction => () => this.TranslateText(true);
protected override bool SubmitDisabled => this.isAgentRunning;
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with