From 06f66fdab2a72ce2700389c84d4d8302fcd1d474 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 5 Jan 2025 15:11:15 +0100 Subject: [PATCH] Refactored the settings page (#258) --- .../Agents/AgentTextContentCleaner.cs | 2 +- .../Components/ChatComponent.razor.cs | 4 +- .../Components/ProviderSelection.razor.cs | 10 +- .../Components/ReadWebContent.razor.cs | 4 +- .../Settings/SettingsPanelAgenda.razor | 32 + .../Settings/SettingsPanelAgenda.razor.cs | 3 + .../SettingsPanelAgentContentCleaner.razor | 12 + .../SettingsPanelAgentContentCleaner.razor.cs | 3 + .../Settings/SettingsPanelApp.razor | 24 + .../Settings/SettingsPanelApp.razor.cs | 12 + .../Settings/SettingsPanelAssistantBias.razor | 29 + .../SettingsPanelAssistantBias.razor.cs | 27 + .../Components/Settings/SettingsPanelBase.cs | 23 + .../Settings/SettingsPanelChat.razor | 15 + .../Settings/SettingsPanelChat.razor.cs | 3 + .../Settings/SettingsPanelCoding.razor | 18 + .../Settings/SettingsPanelCoding.razor.cs | 3 + .../Settings/SettingsPanelERIServer.razor | 19 + .../Settings/SettingsPanelERIServer.razor.cs | 3 + .../Settings/SettingsPanelEmbeddings.razor | 70 +++ .../Settings/SettingsPanelEmbeddings.razor.cs | 112 ++++ .../SettingsPanelGrammarSpelling.razor | 15 + .../SettingsPanelGrammarSpelling.razor.cs | 3 + .../Settings/SettingsPanelIconFinder.razor | 11 + .../Settings/SettingsPanelIconFinder.razor.cs | 3 + .../Settings/SettingsPanelJobPostings.razor | 22 + .../SettingsPanelJobPostings.razor.cs | 3 + .../Settings/SettingsPanelLegalCheck.razor | 14 + .../Settings/SettingsPanelLegalCheck.razor.cs | 3 + .../Settings/SettingsPanelMyTasks.razor | 16 + .../Settings/SettingsPanelMyTasks.razor.cs | 3 + .../Settings/SettingsPanelProfiles.razor | 50 ++ .../Settings/SettingsPanelProfiles.razor.cs | 72 +++ .../Settings/SettingsPanelProviders.razor | 124 ++++ .../Settings/SettingsPanelProviders.razor.cs | 145 +++++ .../Settings/SettingsPanelRewrite.razor | 17 + .../Settings/SettingsPanelRewrite.razor.cs | 3 + .../Settings/SettingsPanelSynonyms.razor | 15 + .../Settings/SettingsPanelSynonyms.razor.cs | 3 + .../SettingsPanelTextSummarizer.razor | 24 + .../SettingsPanelTextSummarizer.razor.cs | 3 + .../Settings/SettingsPanelTranslation.razor | 20 + .../SettingsPanelTranslation.razor.cs | 3 + .../Settings/SettingsPanelWorkspaces.razor | 13 + .../Settings/SettingsPanelWorkspaces.razor.cs | 3 + .../Settings/SettingsPanelWritingEMails.razor | 19 + .../SettingsPanelWritingEMails.razor.cs | 3 + .../Dialogs/ProviderDialog.razor.cs | 2 +- app/MindWork AI Studio/Pages/Settings.razor | 559 +----------------- .../Pages/Settings.razor.cs | 338 +---------- .../Provider/LLMProvidersExtensions.cs | 2 +- .../PreviousModels/ProviderV4Extensions.cs | 4 +- .../Tools/ComponentsExtensions.cs | 2 +- 53 files changed, 1057 insertions(+), 888 deletions(-) create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelAgenda.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelAgenda.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelAgentContentCleaner.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelAgentContentCleaner.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelAssistantBias.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelAssistantBias.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelBase.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelCoding.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelCoding.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelERIServer.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelERIServer.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelGrammarSpelling.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelGrammarSpelling.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelIconFinder.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelIconFinder.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelJobPostings.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelJobPostings.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelLegalCheck.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelLegalCheck.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelMyTasks.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelMyTasks.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelProfiles.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelProfiles.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelRewrite.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelRewrite.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelSynonyms.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelSynonyms.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelTextSummarizer.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelTextSummarizer.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelTranslation.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelTranslation.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelWorkspaces.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelWorkspaces.razor.cs create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelWritingEMails.razor create mode 100644 app/MindWork AI Studio/Components/Settings/SettingsPanelWritingEMails.razor.cs diff --git a/app/MindWork AI Studio/Agents/AgentTextContentCleaner.cs b/app/MindWork AI Studio/Agents/AgentTextContentCleaner.cs index f98b80e..e8d19aa 100644 --- a/app/MindWork AI Studio/Agents/AgentTextContentCleaner.cs +++ b/app/MindWork AI Studio/Agents/AgentTextContentCleaner.cs @@ -18,7 +18,7 @@ public sealed class AgentTextContentCleaner(ILogger logger, SettingsM #region Overrides of AgentBase - public override Settings.Provider? ProviderSettings { get; set; } + public override AIStudio.Settings.Provider? ProviderSettings { get; set; } protected override Type Type => Type.SYSTEM; diff --git a/app/MindWork AI Studio/Components/ChatComponent.razor.cs b/app/MindWork AI Studio/Components/ChatComponent.razor.cs index 72bbe01..5ca0ebd 100644 --- a/app/MindWork AI Studio/Components/ChatComponent.razor.cs +++ b/app/MindWork AI Studio/Components/ChatComponent.razor.cs @@ -20,10 +20,10 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable public EventCallback ChatThreadChanged { get; set; } [Parameter] - public Settings.Provider Provider { get; set; } + public AIStudio.Settings.Provider Provider { get; set; } [Parameter] - public EventCallback ProviderChanged { get; set; } + public EventCallback ProviderChanged { get; set; } [Parameter] public Action WorkspaceName { get; set; } = _ => { }; diff --git a/app/MindWork AI Studio/Components/ProviderSelection.razor.cs b/app/MindWork AI Studio/Components/ProviderSelection.razor.cs index a5e39e5..927c1d6 100644 --- a/app/MindWork AI Studio/Components/ProviderSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ProviderSelection.razor.cs @@ -12,24 +12,24 @@ public partial class ProviderSelection : ComponentBase public AssistantBase? AssistantBase { get; set; } [Parameter] - public Settings.Provider ProviderSettings { get; set; } + public AIStudio.Settings.Provider ProviderSettings { get; set; } [Parameter] - public EventCallback ProviderSettingsChanged { get; set; } + public EventCallback ProviderSettingsChanged { get; set; } [Parameter] - public Func ValidateProvider { get; set; } = _ => null; + public Func ValidateProvider { get; set; } = _ => null; [Inject] private SettingsManager SettingsManager { get; init; } = null!; - private async Task SelectionChanged(Settings.Provider provider) + private async Task SelectionChanged(AIStudio.Settings.Provider provider) { this.ProviderSettings = provider; await this.ProviderSettingsChanged.InvokeAsync(provider); } - private IEnumerable GetAvailableProviders() + private IEnumerable GetAvailableProviders() { var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(this.AssistantBase?.Component ?? Tools.Components.NONE); foreach (var provider in this.SettingsManager.ConfigurationData.Providers) diff --git a/app/MindWork AI Studio/Components/ReadWebContent.razor.cs b/app/MindWork AI Studio/Components/ReadWebContent.razor.cs index b1511b3..aebe7ef 100644 --- a/app/MindWork AI Studio/Components/ReadWebContent.razor.cs +++ b/app/MindWork AI Studio/Components/ReadWebContent.razor.cs @@ -24,7 +24,7 @@ public partial class ReadWebContent : ComponentBase public EventCallback ContentChanged { get; set; } [Parameter] - public Settings.Provider ProviderSettings { get; set; } + public AIStudio.Settings.Provider ProviderSettings { get; set; } [Parameter] public bool AgentIsRunning { get; set; } @@ -47,7 +47,7 @@ public partial class ReadWebContent : ComponentBase private bool urlIsValid; private bool isProviderValid; - private Settings.Provider providerSettings; + private AIStudio.Settings.Provider providerSettings; #region Overrides of ComponentBase diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelAgenda.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelAgenda.razor new file mode 100644 index 0000000..6412d15 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelAgenda.razor @@ -0,0 +1,32 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + + + + + + + + + + + + + + + @if (this.SettingsManager.ConfigurationData.Agenda.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelAgenda.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelAgenda.razor.cs new file mode 100644 index 0000000..82368a5 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelAgenda.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelAgenda : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelAgentContentCleaner.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelAgentContentCleaner.razor new file mode 100644 index 0000000..6bdd377 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelAgentContentCleaner.razor @@ -0,0 +1,12 @@ +@inherits SettingsPanelBase + + + + + Use Case: this agent is used to clean up text content. It extracts the main content, removes advertisements and other irrelevant things, + and attempts to convert relative links into absolute links so that they can be used. + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelAgentContentCleaner.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelAgentContentCleaner.razor.cs new file mode 100644 index 0000000..e588f06 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelAgentContentCleaner.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelAgentContentCleaner : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor new file mode 100644 index 0000000..5cdb326 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor @@ -0,0 +1,24 @@ +@using AIStudio.Settings +@using AIStudio.Settings.DataModel +@inherits SettingsPanelBase + + + + + + + + + + @if(this.SettingsManager.ConfigurationData.App.PreviewVisibility > PreviewVisibility.NONE) + { + var availablePreviewFeatures = ConfigurationSelectDataFactory.GetPreviewFeaturesData(this.SettingsManager).ToList(); + if (availablePreviewFeatures.Count > 0) + { + + } + } + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor.cs new file mode 100644 index 0000000..f4b75bf --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor.cs @@ -0,0 +1,12 @@ +using AIStudio.Settings.DataModel; + +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelApp : SettingsPanelBase +{ + private void UpdatePreviewFeatures(PreviewVisibility previewVisibility) + { + this.SettingsManager.ConfigurationData.App.PreviewVisibility = previewVisibility; + this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = previewVisibility.FilterPreviewFeatures(this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures); + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelAssistantBias.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelAssistantBias.razor new file mode 100644 index 0000000..40f178e --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelAssistantBias.razor @@ -0,0 +1,29 @@ +@using AIStudio.Settings +@using AIStudio.Settings.DataModel +@inherits SettingsPanelBase + + + + + + + + You have learned about @this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias.Count out of @BiasCatalog.ALL_BIAS.Count biases. + + + Reset + + + + + + + @if (this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelAssistantBias.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelAssistantBias.razor.cs new file mode 100644 index 0000000..375d644 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelAssistantBias.razor.cs @@ -0,0 +1,27 @@ +using AIStudio.Dialogs; + +using DialogOptions = AIStudio.Dialogs.DialogOptions; + +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelAssistantBias : SettingsPanelBase +{ + private async Task ResetBiasOfTheDayHistory() + { + var dialogParameters = new DialogParameters + { + { "Message", "Are you sure you want to reset your bias-of-the-day statistics? The system will no longer remember which biases you already know. As a result, biases you are already familiar with may be addressed again." }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Reset your bias-of-the-day statistics", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias.Clear(); + this.SettingsManager.ConfigurationData.BiasOfTheDay.DateLastBiasDrawn = DateOnly.MinValue; + await this.SettingsManager.StoreSettings(); + + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelBase.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelBase.cs new file mode 100644 index 0000000..f7f3a1d --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelBase.cs @@ -0,0 +1,23 @@ +using AIStudio.Settings; + +using Microsoft.AspNetCore.Components; + +namespace AIStudio.Components.Settings; + +public abstract class SettingsPanelBase : ComponentBase +{ + [Parameter] + public Func>> AvailableLLMProvidersFunc { get; set; } = () => []; + + [Inject] + protected SettingsManager SettingsManager { get; init; } = null!; + + [Inject] + protected IDialogService DialogService { get; init; } = null!; + + [Inject] + protected MessageBus MessageBus { get; init; } = null!; + + [Inject] + protected RustService RustService { get; init; } = null!; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor new file mode 100644 index 0000000..602af63 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor @@ -0,0 +1,15 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor.cs new file mode 100644 index 0000000..2650923 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelChat : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelCoding.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelCoding.razor new file mode 100644 index 0000000..12bf879 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelCoding.razor @@ -0,0 +1,18 @@ +@using AIStudio.Assistants.Coding +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + @if (this.SettingsManager.ConfigurationData.Coding.PreselectedProgrammingLanguage is CommonCodingLanguages.OTHER) + { + + } + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelCoding.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelCoding.razor.cs new file mode 100644 index 0000000..060a30a --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelCoding.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelCoding : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelERIServer.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelERIServer.razor new file mode 100644 index 0000000..62d2fd0 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelERIServer.razor @@ -0,0 +1,19 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + + Most ERI server options can be customized and saved directly in the ERI server assistant. + For this, the ERI server assistant has an auto-save function. + + + + Switch to ERI server assistant + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelERIServer.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelERIServer.razor.cs new file mode 100644 index 0000000..0e01ed2 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelERIServer.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelERIServer : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor new file mode 100644 index 0000000..ea82ce7 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor @@ -0,0 +1,70 @@ +@using AIStudio.Provider +@using AIStudio.Settings.DataModel +@inherits SettingsPanelBase + +@if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager)) +{ + + + + Configured Embeddings + + + Embeddings are a way to represent words, sentences, entire documents, or even images and videos as digital + fingerprints. Just like each person has a unique fingerprint, embedding models create unique digital patterns + that capture the meaning and characteristics of the content they analyze. When two things are similar in meaning + or content, their digital fingerprints will look very similar. For example, the fingerprints for 'happy' and + 'joyful' would be more alike than those for 'happy' and 'sad'. + + + + This helps AI Studio understand and compare things in a way that's similar to how humans do. When you're working on + something, AI Studio can automatically identify related documents and data by comparing their digital fingerprints. + For instance, if you're writing about customer service, AI Studio can instantly find other documents in your data that + discuss similar topics or experiences, even if they use different words. + + + + + + + + + + + # + Name + Provider + Model + Actions + + + @context.Num + @context.Name + @context.UsedLLMProvider + @this.GetEmbeddingProviderModelName(context) + + + + Open Dashboard + + + Edit + + + Delete + + + + + + @if (this.SettingsManager.ConfigurationData.EmbeddingProviders.Count == 0) + { + No embeddings configured yet. + } + + + Add Embedding + + +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor.cs new file mode 100644 index 0000000..afa5024 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor.cs @@ -0,0 +1,112 @@ +using AIStudio.Dialogs; +using AIStudio.Settings; + +using Microsoft.AspNetCore.Components; + +using DialogOptions = AIStudio.Dialogs.DialogOptions; + +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelEmbeddings : SettingsPanelBase +{ + [Parameter] + public List> AvailableEmbeddingProviders { get; set; } = new(); + + [Parameter] + public EventCallback>> AvailableEmbeddingProvidersChanged { get; set; } + + private string GetEmbeddingProviderModelName(EmbeddingProvider provider) + { + const int MAX_LENGTH = 36; + var modelName = provider.Model.ToString(); + return modelName.Length > MAX_LENGTH ? "[...] " + modelName[^Math.Min(MAX_LENGTH, modelName.Length)..] : modelName; + } + + private async Task AddEmbeddingProvider() + { + var dialogParameters = new DialogParameters + { + { x => x.IsEditing, false }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Add Embedding Provider", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + var addedEmbedding = (EmbeddingProvider)dialogResult.Data!; + addedEmbedding = addedEmbedding with { Num = this.SettingsManager.ConfigurationData.NextEmbeddingNum++ }; + + this.SettingsManager.ConfigurationData.EmbeddingProviders.Add(addedEmbedding); + await this.UpdateEmbeddingProviders(); + + await this.SettingsManager.StoreSettings(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } + + private async Task EditEmbeddingProvider(EmbeddingProvider embeddingProvider) + { + var dialogParameters = new DialogParameters + { + { x => x.DataNum, embeddingProvider.Num }, + { x => x.DataId, embeddingProvider.Id }, + { x => x.DataName, embeddingProvider.Name }, + { x => x.DataLLMProvider, embeddingProvider.UsedLLMProvider }, + { x => x.DataModel, embeddingProvider.Model }, + { x => x.DataHostname, embeddingProvider.Hostname }, + { x => x.IsSelfHosted, embeddingProvider.IsSelfHosted }, + { x => x.IsEditing, true }, + { x => x.DataHost, embeddingProvider.Host }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Edit Embedding Provider", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + var editedEmbeddingProvider = (EmbeddingProvider)dialogResult.Data!; + + // Set the provider number if it's not set. This is important for providers + // added before we started saving the provider number. + if(editedEmbeddingProvider.Num == 0) + editedEmbeddingProvider = editedEmbeddingProvider with { Num = this.SettingsManager.ConfigurationData.NextEmbeddingNum++ }; + + this.SettingsManager.ConfigurationData.EmbeddingProviders[this.SettingsManager.ConfigurationData.EmbeddingProviders.IndexOf(embeddingProvider)] = editedEmbeddingProvider; + await this.UpdateEmbeddingProviders(); + + await this.SettingsManager.StoreSettings(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } + + private async Task DeleteEmbeddingProvider(EmbeddingProvider provider) + { + var dialogParameters = new DialogParameters + { + { "Message", $"Are you sure you want to delete the embedding provider '{provider.Name}'?" }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Delete Embedding Provider", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + var deleteSecretResponse = await this.RustService.DeleteAPIKey(provider); + if(deleteSecretResponse.Success) + { + this.SettingsManager.ConfigurationData.EmbeddingProviders.Remove(provider); + await this.SettingsManager.StoreSettings(); + } + + await this.UpdateEmbeddingProviders(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } + + private async Task UpdateEmbeddingProviders() + { + this.AvailableEmbeddingProviders.Clear(); + foreach (var provider in this.SettingsManager.ConfigurationData.EmbeddingProviders) + this.AvailableEmbeddingProviders.Add(new (provider.Name, provider.Id)); + + await this.AvailableEmbeddingProvidersChanged.InvokeAsync(this.AvailableEmbeddingProviders); + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelGrammarSpelling.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelGrammarSpelling.razor new file mode 100644 index 0000000..73b31ca --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelGrammarSpelling.razor @@ -0,0 +1,15 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + @if (this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelGrammarSpelling.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelGrammarSpelling.razor.cs new file mode 100644 index 0000000..b15d58a --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelGrammarSpelling.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelGrammarSpelling : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelIconFinder.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelIconFinder.razor new file mode 100644 index 0000000..76317e9 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelIconFinder.razor @@ -0,0 +1,11 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelIconFinder.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelIconFinder.razor.cs new file mode 100644 index 0000000..e545163 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelIconFinder.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelIconFinder : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelJobPostings.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelJobPostings.razor new file mode 100644 index 0000000..b9b56a5 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelJobPostings.razor @@ -0,0 +1,22 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + + + + + + @if (this.SettingsManager.ConfigurationData.JobPostings.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelJobPostings.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelJobPostings.razor.cs new file mode 100644 index 0000000..20ecab6 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelJobPostings.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelJobPostings : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelLegalCheck.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelLegalCheck.razor new file mode 100644 index 0000000..00c2f7d --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelLegalCheck.razor @@ -0,0 +1,14 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelLegalCheck.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelLegalCheck.razor.cs new file mode 100644 index 0000000..66db469 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelLegalCheck.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelLegalCheck : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelMyTasks.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelMyTasks.razor new file mode 100644 index 0000000..2a443f7 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelMyTasks.razor @@ -0,0 +1,16 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + @if (this.SettingsManager.ConfigurationData.MyTasks.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelMyTasks.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelMyTasks.razor.cs new file mode 100644 index 0000000..2c4291d --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelMyTasks.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelMyTasks : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelProfiles.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelProfiles.razor new file mode 100644 index 0000000..924eb77 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelProfiles.razor @@ -0,0 +1,50 @@ +@inherits SettingsPanelBase + + + Your Profiles + + 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. + + + + + + + + + # + Profile Name + Actions + + + @context.Num + @context.Name + + + Edit + + + Delete + + + + + + @if(this.SettingsManager.ConfigurationData.Profiles.Count == 0) + { + No profiles configured yet. + } + + + Add Profile + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelProfiles.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelProfiles.razor.cs new file mode 100644 index 0000000..15b3214 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelProfiles.razor.cs @@ -0,0 +1,72 @@ +using AIStudio.Dialogs; +using AIStudio.Settings; + +using DialogOptions = AIStudio.Dialogs.DialogOptions; + +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelProfiles : SettingsPanelBase +{ + private async Task AddProfile() + { + var dialogParameters = new DialogParameters + { + { x => x.IsEditing, false }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Add Profile", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + var addedProfile = (Profile)dialogResult.Data!; + addedProfile = addedProfile with { Num = this.SettingsManager.ConfigurationData.NextProfileNum++ }; + + this.SettingsManager.ConfigurationData.Profiles.Add(addedProfile); + + await this.SettingsManager.StoreSettings(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } + + private async Task EditProfile(Profile profile) + { + var dialogParameters = new DialogParameters + { + { x => x.DataNum, profile.Num }, + { x => x.DataId, profile.Id }, + { x => x.DataName, profile.Name }, + { x => x.DataNeedToKnow, profile.NeedToKnow }, + { x => x.DataActions, profile.Actions }, + { x => x.IsEditing, true }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Edit Profile", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + var editedProfile = (Profile)dialogResult.Data!; + this.SettingsManager.ConfigurationData.Profiles[this.SettingsManager.ConfigurationData.Profiles.IndexOf(profile)] = editedProfile; + + await this.SettingsManager.StoreSettings(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } + + private async Task DeleteProfile(Profile profile) + { + var dialogParameters = new DialogParameters + { + { "Message", $"Are you sure you want to delete the profile '{profile.Name}'?" }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Delete Profile", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + this.SettingsManager.ConfigurationData.Profiles.Remove(profile); + await this.SettingsManager.StoreSettings(); + + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor new file mode 100644 index 0000000..cd1b4ff --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor @@ -0,0 +1,124 @@ +@using AIStudio.Provider +@using AIStudio.Settings +@using AIStudio.Provider.SelfHosted +@inherits SettingsPanelBase + + + Configured Providers + + What we call a provider is the combination of an LLM provider such as OpenAI and a model like GPT-4o. + You can configure as many providers as you want. This way, you can use the appropriate model for each + task. As an LLM provider, you can also choose local providers. However, to use this app, you must + configure at least one provider. + + + + + + + + + + + # + Instance Name + Provider + Model + Actions + + + @context.Num + @context.InstanceName + @context.UsedLLMProvider + + @if (context.UsedLLMProvider is not LLMProviders.SELF_HOSTED) + { + @this.GetLLMProviderModelName(context) + } + else if (context.UsedLLMProvider is LLMProviders.SELF_HOSTED && context.Host is not Host.LLAMACPP) + { + @this.GetLLMProviderModelName(context) + } + else + { + @("as selected by provider") + } + + + + Open Dashboard + + + Edit + + + Delete + + + + + + @if(this.SettingsManager.ConfigurationData.Providers.Count == 0) + { + No providers configured yet. + } + + + Add Provider + + + LLM Provider Confidence + + Do you want to always be able to recognize how trustworthy your LLM providers are? This way, + you keep control over which provider you send your data to. You have two options for this: + Either you choose a common schema, or you configure the trust levels for each LLM provider yourself. + + + + @if(this.SettingsManager.ConfigurationData.LLMProviders.EnforceGlobalMinimumConfidence) + { + + } + + + @if (this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence) + { + + @if (this.SettingsManager.ConfigurationData.LLMProviders.ConfidenceScheme is ConfidenceSchemes.CUSTOM) + { + + + + + + + + LLM Provider + Description + Confidence Level + + + + @context.ToName() + + + + + + + @foreach (var confidenceLevel in Enum.GetValues().OrderBy(n => n)) + { + if(confidenceLevel is ConfidenceLevel.NONE or ConfidenceLevel.UNKNOWN) + continue; + + + @confidenceLevel.GetName() + + } + + + + + } + } + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor.cs new file mode 100644 index 0000000..e2c434f --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelProviders.razor.cs @@ -0,0 +1,145 @@ +using AIStudio.Dialogs; +using AIStudio.Provider; +using AIStudio.Settings; + +using Microsoft.AspNetCore.Components; + +using DialogOptions = AIStudio.Dialogs.DialogOptions; + +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelProviders : SettingsPanelBase +{ + [Parameter] + public List> AvailableLLMProviders { get; set; } = new(); + + [Parameter] + public EventCallback>> AvailableLLMProvidersChanged { get; set; } + + #region Overrides of ComponentBase + + protected override async Task OnInitializedAsync() + { + await this.UpdateProviders(); + await base.OnInitializedAsync(); + } + + #endregion + + private async Task AddLLMProvider() + { + var dialogParameters = new DialogParameters + { + { x => x.IsEditing, false }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Add LLM Provider", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + var addedProvider = (AIStudio.Settings.Provider)dialogResult.Data!; + addedProvider = addedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ }; + + this.SettingsManager.ConfigurationData.Providers.Add(addedProvider); + await this.UpdateProviders(); + + await this.SettingsManager.StoreSettings(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } + + private async Task EditLLMProvider(AIStudio.Settings.Provider provider) + { + var dialogParameters = new DialogParameters + { + { x => x.DataNum, provider.Num }, + { x => x.DataId, provider.Id }, + { x => x.DataInstanceName, provider.InstanceName }, + { x => x.DataLLMProvider, provider.UsedLLMProvider }, + { x => x.DataModel, provider.Model }, + { x => x.DataHostname, provider.Hostname }, + { x => x.IsSelfHosted, provider.IsSelfHosted }, + { x => x.IsEditing, true }, + { x => x.DataHost, provider.Host }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Edit LLM Provider", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + var editedProvider = (AIStudio.Settings.Provider)dialogResult.Data!; + + // Set the provider number if it's not set. This is important for providers + // added before we started saving the provider number. + if(editedProvider.Num == 0) + editedProvider = editedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ }; + + this.SettingsManager.ConfigurationData.Providers[this.SettingsManager.ConfigurationData.Providers.IndexOf(provider)] = editedProvider; + await this.UpdateProviders(); + + await this.SettingsManager.StoreSettings(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } + + private async Task DeleteLLMProvider(AIStudio.Settings.Provider provider) + { + var dialogParameters = new DialogParameters + { + { "Message", $"Are you sure you want to delete the provider '{provider.InstanceName}'?" }, + }; + + var dialogReference = await this.DialogService.ShowAsync("Delete LLM Provider", dialogParameters, DialogOptions.FULLSCREEN); + var dialogResult = await dialogReference.Result; + if (dialogResult is null || dialogResult.Canceled) + return; + + var deleteSecretResponse = await this.RustService.DeleteAPIKey(provider); + if(deleteSecretResponse.Success) + { + this.SettingsManager.ConfigurationData.Providers.Remove(provider); + await this.SettingsManager.StoreSettings(); + } + + await this.UpdateProviders(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + } + + private string GetLLMProviderModelName(AIStudio.Settings.Provider provider) + { + const int MAX_LENGTH = 36; + var modelName = provider.Model.ToString(); + return modelName.Length > MAX_LENGTH ? "[...] " + modelName[^Math.Min(MAX_LENGTH, modelName.Length)..] : modelName; + } + + private async Task UpdateProviders() + { + this.AvailableLLMProviders.Clear(); + foreach (var provider in this.SettingsManager.ConfigurationData.Providers) + this.AvailableLLMProviders.Add(new (provider.InstanceName, provider.Id)); + + await this.AvailableLLMProvidersChanged.InvokeAsync(this.AvailableLLMProviders); + } + + private string GetCurrentConfidenceLevelName(LLMProviders llmProvider) + { + if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(llmProvider, out var level)) + return level.GetName(); + + return "Not yet configured"; + } + + private string SetCurrentConfidenceLevelColorStyle(LLMProviders llmProvider) + { + if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(llmProvider, out var level)) + return $"background-color: {level.GetColor(this.SettingsManager)};"; + + return $"background-color: {ConfidenceLevel.UNKNOWN.GetColor(this.SettingsManager)};"; + } + + private async Task ChangeCustomConfidenceLevel(LLMProviders llmProvider, ConfidenceLevel level) + { + this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme[llmProvider] = level; + await this.SettingsManager.StoreSettings(); + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelRewrite.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelRewrite.razor new file mode 100644 index 0000000..fe91199 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelRewrite.razor @@ -0,0 +1,17 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + @if (this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelRewrite.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelRewrite.razor.cs new file mode 100644 index 0000000..ca72bef --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelRewrite.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelRewrite : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelSynonyms.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelSynonyms.razor new file mode 100644 index 0000000..6468c53 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelSynonyms.razor @@ -0,0 +1,15 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + @if (this.SettingsManager.ConfigurationData.Synonyms.PreselectedLanguage is CommonLanguages.OTHER) + { + + } + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelSynonyms.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelSynonyms.razor.cs new file mode 100644 index 0000000..c4a9ee4 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelSynonyms.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelSynonyms : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelTextSummarizer.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelTextSummarizer.razor new file mode 100644 index 0000000..f8afa49 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelTextSummarizer.razor @@ -0,0 +1,24 @@ +@using AIStudio.Assistants.TextSummarizer +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + + @if (this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + @if(this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedComplexity is Complexity.SCIENTIFIC_LANGUAGE_OTHER_EXPERTS) + { + + } + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelTextSummarizer.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelTextSummarizer.razor.cs new file mode 100644 index 0000000..8eab6d8 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelTextSummarizer.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelTextSummarizer : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelTranslation.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelTranslation.razor new file mode 100644 index 0000000..6ad8776 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelTranslation.razor @@ -0,0 +1,20 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + + + + @if (this.SettingsManager.ConfigurationData.Translation.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelTranslation.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelTranslation.razor.cs new file mode 100644 index 0000000..d68b578 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelTranslation.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelTranslation : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelWorkspaces.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelWorkspaces.razor new file mode 100644 index 0000000..b304298 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelWorkspaces.razor @@ -0,0 +1,13 @@ +@using AIStudio.Settings +@using AIStudio.Settings.DataModel +@inherits SettingsPanelBase + + + + + @if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is not WorkspaceStorageBehavior.DISABLE_WORKSPACES) + { + + + } + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelWorkspaces.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelWorkspaces.razor.cs new file mode 100644 index 0000000..881a738 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelWorkspaces.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelWorkspaces : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelWritingEMails.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelWritingEMails.razor new file mode 100644 index 0000000..0126ecf --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelWritingEMails.razor @@ -0,0 +1,19 @@ +@using AIStudio.Settings +@inherits SettingsPanelBase + + + + + + + + @if (this.SettingsManager.ConfigurationData.EMail.PreselectedTargetLanguage is CommonLanguages.OTHER) + { + + } + + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelWritingEMails.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelWritingEMails.razor.cs new file mode 100644 index 0000000..5d87b61 --- /dev/null +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelWritingEMails.razor.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Settings; + +public partial class SettingsPanelWritingEMails : SettingsPanelBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs index 9e5fcb6..87e5569 100644 --- a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs @@ -113,7 +113,7 @@ public partial class ProviderDialog : ComponentBase, ISecretId }; } - private Settings.Provider CreateProviderSettings() + private AIStudio.Settings.Provider CreateProviderSettings() { var cleanedHostname = this.DataHostname.Trim(); return new() diff --git a/app/MindWork AI Studio/Pages/Settings.razor b/app/MindWork AI Studio/Pages/Settings.razor index 27e762e..4a00473 100644 --- a/app/MindWork AI Studio/Pages/Settings.razor +++ b/app/MindWork AI Studio/Pages/Settings.razor @@ -1,545 +1,30 @@ @attribute [Route(Routes.SETTINGS)] -@using AIStudio.Assistants.Coding -@using AIStudio.Assistants.TextSummarizer -@using AIStudio.Provider -@using AIStudio.Settings -@using AIStudio.Settings.DataModel -@using Host = AIStudio.Provider.SelfHosted.Host +@using AIStudio.Components.Settings Settings - - Configured Providers - - What we call a provider is the combination of an LLM provider such as OpenAI and a model like GPT-4o. - You can configure as many providers as you want. This way, you can use the appropriate model for each - task. As an LLM provider, you can also choose local providers. However, to use this app, you must - configure at least one provider. - - - - - - - - - - - # - Instance Name - Provider - Model - Actions - - - @context.Num - @context.InstanceName - @context.UsedLLMProvider - - @if (context.UsedLLMProvider is not LLMProviders.SELF_HOSTED) - { - @this.GetLLMProviderModelName(context) - } - else if (context.UsedLLMProvider is LLMProviders.SELF_HOSTED && context.Host is not Host.LLAMACPP) - { - @this.GetLLMProviderModelName(context) - } - else - { - @("as selected by provider") - } - - - - Open Dashboard - - - Edit - - - Delete - - - - - - @if(this.SettingsManager.ConfigurationData.Providers.Count == 0) - { - No providers configured yet. - } - - - Add Provider - - - LLM Provider Confidence - - Do you want to always be able to recognize how trustworthy your LLM providers are? This way, - you keep control over which provider you send your data to. You have two options for this: - Either you choose a common schema, or you configure the trust levels for each LLM provider yourself. - - - - @if(this.SettingsManager.ConfigurationData.LLMProviders.EnforceGlobalMinimumConfidence) - { - - } - - - @if (this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence) - { - - @if (this.SettingsManager.ConfigurationData.LLMProviders.ConfidenceScheme is ConfidenceSchemes.CUSTOM) - { - - - - - - - - LLM Provider - Description - Confidence Level - - - - @context.ToName() - - - - - - - @foreach (var confidenceLevel in Enum.GetValues().OrderBy(n => n)) - { - if(confidenceLevel is ConfidenceLevel.NONE or ConfidenceLevel.UNKNOWN) - continue; - - - @confidenceLevel.GetName() - - } - - - - - } - } - - - - @if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager)) - { - - - - Configured Embeddings - - - Embeddings are a way to represent words, sentences, entire documents, or even images and videos as digital - fingerprints. Just like each person has a unique fingerprint, embedding models create unique digital patterns - that capture the meaning and characteristics of the content they analyze. When two things are similar in meaning - or content, their digital fingerprints will look very similar. For example, the fingerprints for 'happy' and - 'joyful' would be more alike than those for 'happy' and 'sad'. - - - - This helps AI Studio understand and compare things in a way that's similar to how humans do. When you're working on - something, AI Studio can automatically identify related documents and data by comparing their digital fingerprints. - For instance, if you're writing about customer service, AI Studio can instantly find other documents in your data that - discuss similar topics or experiences, even if they use different words. - - - - - - - - - - - # - Name - Provider - Model - Actions - - - @context.Num - @context.Name - @context.UsedLLMProvider - @this.GetEmbeddingProviderModelName(context) - - - - Open Dashboard - - - Edit - - - Delete - - - - - - @if (this.SettingsManager.ConfigurationData.EmbeddingProviders.Count == 0) - { - No embeddings configured yet. - } - - - Add Embedding - - - } - - - Your Profiles - - 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. - - - - - - - - - # - Profile Name - Actions - - - @context.Num - @context.Name - - - Edit - - - Delete - - - - - - @if(this.SettingsManager.ConfigurationData.Profiles.Count == 0) - { - No profiles configured yet. - } - - - Add Profile - - - - - - - - - - - - @if(this.SettingsManager.ConfigurationData.App.PreviewVisibility > PreviewVisibility.NONE) - { - var availablePreviewFeatures = ConfigurationSelectDataFactory.GetPreviewFeaturesData(this.SettingsManager).ToList(); - if (availablePreviewFeatures.Count > 0) - { - - } - } - - - - - - - - - - - - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is not WorkspaceStorageBehavior.DISABLE_WORKSPACES) - { - - - } - - - - - - - - - - - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.Translation.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.Coding.PreselectedProgrammingLanguage is CommonCodingLanguages.OTHER) - { - - } - - - - - - - - - - - - - - Most ERI server options can be customized and saved directly in the ERI server assistant. - For this, the ERI server assistant has an auto-save function. - - - - Switch to ERI server assistant - - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - @if(this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedComplexity is Complexity.SCIENTIFIC_LANGUAGE_OTHER_EXPERTS) - { - - } - - - - - - - - - - - - - - - - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.Agenda.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.EMail.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.JobPostings.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - - - - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.Synonyms.PreselectedLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - @if (this.SettingsManager.ConfigurationData.MyTasks.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - - - - You have learned about @this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias.Count out of @BiasCatalog.ALL_BIAS.Count biases. - - - Reset - - - - - - - @if (this.SettingsManager.ConfigurationData.BiasOfTheDay.PreselectedTargetLanguage is CommonLanguages.OTHER) - { - - } - - - - - - - - - - Use Case: this agent is used to clean up text content. It extracts the main content, removes advertisements and other irrelevant things, - and attempts to convert relative links into absolute links so that they can be used. - - - - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Pages/Settings.razor.cs b/app/MindWork AI Studio/Pages/Settings.razor.cs index eb43631..d06ab02 100644 --- a/app/MindWork AI Studio/Pages/Settings.razor.cs +++ b/app/MindWork AI Studio/Pages/Settings.razor.cs @@ -1,33 +1,16 @@ -using AIStudio.Dialogs; -using AIStudio.Provider; using AIStudio.Settings; -using AIStudio.Settings.DataModel; using Microsoft.AspNetCore.Components; -using DialogOptions = AIStudio.Dialogs.DialogOptions; -using RustService = AIStudio.Tools.RustService; - -// ReSharper disable ClassNeverInstantiated.Global - namespace AIStudio.Pages; public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable { - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - - [Inject] - private IDialogService DialogService { get; init; } = null!; - [Inject] private MessageBus MessageBus { get; init; } = null!; - [Inject] - private RustService RustService { get; init; } = null!; - - private readonly List> availableLLMProviders = new(); - private readonly List> availableEmbeddingProviders = new(); + private List> availableLLMProviders = new(); + private List> availableEmbeddingProviders = new(); #region Overrides of ComponentBase @@ -37,326 +20,9 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable this.MessageBus.RegisterComponent(this); this.MessageBus.ApplyFilters(this, [], [ Event.CONFIGURATION_CHANGED ]); - this.UpdateProviders(); await base.OnInitializedAsync(); } - #endregion - - #region Preview-feature related - - private void UpdatePreviewFeatures(PreviewVisibility previewVisibility) - { - this.SettingsManager.ConfigurationData.App.PreviewVisibility = previewVisibility; - this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures = previewVisibility.FilterPreviewFeatures(this.SettingsManager.ConfigurationData.App.EnabledPreviewFeatures); - } - - #endregion - - #region Provider related - - private async Task AddLLMProvider() - { - var dialogParameters = new DialogParameters - { - { x => x.IsEditing, false }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Add LLM Provider", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - var addedProvider = (AIStudio.Settings.Provider)dialogResult.Data!; - addedProvider = addedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ }; - - this.SettingsManager.ConfigurationData.Providers.Add(addedProvider); - this.UpdateProviders(); - - await this.SettingsManager.StoreSettings(); - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - private async Task EditLLMProvider(AIStudio.Settings.Provider provider) - { - var dialogParameters = new DialogParameters - { - { x => x.DataNum, provider.Num }, - { x => x.DataId, provider.Id }, - { x => x.DataInstanceName, provider.InstanceName }, - { x => x.DataLLMProvider, provider.UsedLLMProvider }, - { x => x.DataModel, provider.Model }, - { x => x.DataHostname, provider.Hostname }, - { x => x.IsSelfHosted, provider.IsSelfHosted }, - { x => x.IsEditing, true }, - { x => x.DataHost, provider.Host }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Edit LLM Provider", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - var editedProvider = (AIStudio.Settings.Provider)dialogResult.Data!; - - // Set the provider number if it's not set. This is important for providers - // added before we started saving the provider number. - if(editedProvider.Num == 0) - editedProvider = editedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ }; - - this.SettingsManager.ConfigurationData.Providers[this.SettingsManager.ConfigurationData.Providers.IndexOf(provider)] = editedProvider; - this.UpdateProviders(); - - await this.SettingsManager.StoreSettings(); - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - private async Task DeleteLLMProvider(AIStudio.Settings.Provider provider) - { - var dialogParameters = new DialogParameters - { - { "Message", $"Are you sure you want to delete the provider '{provider.InstanceName}'?" }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Delete LLM Provider", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - var deleteSecretResponse = await this.RustService.DeleteAPIKey(provider); - if(deleteSecretResponse.Success) - { - this.SettingsManager.ConfigurationData.Providers.Remove(provider); - await this.SettingsManager.StoreSettings(); - } - - this.UpdateProviders(); - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - private string GetLLMProviderModelName(AIStudio.Settings.Provider provider) - { - const int MAX_LENGTH = 36; - var modelName = provider.Model.ToString(); - return modelName.Length > MAX_LENGTH ? "[...] " + modelName[^Math.Min(MAX_LENGTH, modelName.Length)..] : modelName; - } - - private void UpdateProviders() - { - this.availableLLMProviders.Clear(); - foreach (var provider in this.SettingsManager.ConfigurationData.Providers) - this.availableLLMProviders.Add(new (provider.InstanceName, provider.Id)); - } - - private string GetCurrentConfidenceLevelName(LLMProviders llmProvider) - { - if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(llmProvider, out var level)) - return level.GetName(); - - return "Not yet configured"; - } - - private string SetCurrentConfidenceLevelColorStyle(LLMProviders llmProvider) - { - if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(llmProvider, out var level)) - return $"background-color: {level.GetColor(this.SettingsManager)};"; - - return $"background-color: {ConfidenceLevel.UNKNOWN.GetColor(this.SettingsManager)};"; - } - - private async Task ChangeCustomConfidenceLevel(LLMProviders llmProvider, ConfidenceLevel level) - { - this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme[llmProvider] = level; - await this.SettingsManager.StoreSettings(); - } - - #endregion - - #region Embedding provider related - - private string GetEmbeddingProviderModelName(EmbeddingProvider provider) - { - const int MAX_LENGTH = 36; - var modelName = provider.Model.ToString(); - return modelName.Length > MAX_LENGTH ? "[...] " + modelName[^Math.Min(MAX_LENGTH, modelName.Length)..] : modelName; - } - - private async Task AddEmbeddingProvider() - { - var dialogParameters = new DialogParameters - { - { x => x.IsEditing, false }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Add Embedding Provider", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - var addedEmbedding = (EmbeddingProvider)dialogResult.Data!; - addedEmbedding = addedEmbedding with { Num = this.SettingsManager.ConfigurationData.NextEmbeddingNum++ }; - - this.SettingsManager.ConfigurationData.EmbeddingProviders.Add(addedEmbedding); - this.UpdateEmbeddingProviders(); - - await this.SettingsManager.StoreSettings(); - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - private async Task EditEmbeddingProvider(EmbeddingProvider embeddingProvider) - { - var dialogParameters = new DialogParameters - { - { x => x.DataNum, embeddingProvider.Num }, - { x => x.DataId, embeddingProvider.Id }, - { x => x.DataName, embeddingProvider.Name }, - { x => x.DataLLMProvider, embeddingProvider.UsedLLMProvider }, - { x => x.DataModel, embeddingProvider.Model }, - { x => x.DataHostname, embeddingProvider.Hostname }, - { x => x.IsSelfHosted, embeddingProvider.IsSelfHosted }, - { x => x.IsEditing, true }, - { x => x.DataHost, embeddingProvider.Host }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Edit Embedding Provider", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - var editedEmbeddingProvider = (EmbeddingProvider)dialogResult.Data!; - - // Set the provider number if it's not set. This is important for providers - // added before we started saving the provider number. - if(editedEmbeddingProvider.Num == 0) - editedEmbeddingProvider = editedEmbeddingProvider with { Num = this.SettingsManager.ConfigurationData.NextEmbeddingNum++ }; - - this.SettingsManager.ConfigurationData.EmbeddingProviders[this.SettingsManager.ConfigurationData.EmbeddingProviders.IndexOf(embeddingProvider)] = editedEmbeddingProvider; - this.UpdateEmbeddingProviders(); - - await this.SettingsManager.StoreSettings(); - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - private async Task DeleteEmbeddingProvider(EmbeddingProvider provider) - { - var dialogParameters = new DialogParameters - { - { "Message", $"Are you sure you want to delete the embedding provider '{provider.Name}'?" }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Delete Embedding Provider", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - var deleteSecretResponse = await this.RustService.DeleteAPIKey(provider); - if(deleteSecretResponse.Success) - { - this.SettingsManager.ConfigurationData.EmbeddingProviders.Remove(provider); - await this.SettingsManager.StoreSettings(); - } - - this.UpdateEmbeddingProviders(); - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - private void UpdateEmbeddingProviders() - { - this.availableEmbeddingProviders.Clear(); - foreach (var provider in this.SettingsManager.ConfigurationData.EmbeddingProviders) - this.availableEmbeddingProviders.Add(new (provider.Name, provider.Id)); - } - - #endregion - - #region Profile related - - private async Task AddProfile() - { - var dialogParameters = new DialogParameters - { - { x => x.IsEditing, false }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Add Profile", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - var addedProfile = (Profile)dialogResult.Data!; - addedProfile = addedProfile with { Num = this.SettingsManager.ConfigurationData.NextProfileNum++ }; - - this.SettingsManager.ConfigurationData.Profiles.Add(addedProfile); - - await this.SettingsManager.StoreSettings(); - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - private async Task EditProfile(Profile profile) - { - var dialogParameters = new DialogParameters - { - { x => x.DataNum, profile.Num }, - { x => x.DataId, profile.Id }, - { x => x.DataName, profile.Name }, - { x => x.DataNeedToKnow, profile.NeedToKnow }, - { x => x.DataActions, profile.Actions }, - { x => x.IsEditing, true }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Edit Profile", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - var editedProfile = (Profile)dialogResult.Data!; - this.SettingsManager.ConfigurationData.Profiles[this.SettingsManager.ConfigurationData.Profiles.IndexOf(profile)] = editedProfile; - - await this.SettingsManager.StoreSettings(); - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - private async Task DeleteProfile(Profile profile) - { - var dialogParameters = new DialogParameters - { - { "Message", $"Are you sure you want to delete the profile '{profile.Name}'?" }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Delete Profile", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - this.SettingsManager.ConfigurationData.Profiles.Remove(profile); - await this.SettingsManager.StoreSettings(); - - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - - #endregion - - #region Bias-of-the-day related - - private async Task ResetBiasOfTheDayHistory() - { - var dialogParameters = new DialogParameters - { - { "Message", "Are you sure you want to reset your bias-of-the-day statistics? The system will no longer remember which biases you already know. As a result, biases you are already familiar with may be addressed again." }, - }; - - var dialogReference = await this.DialogService.ShowAsync("Reset your bias-of-the-day statistics", dialogParameters, DialogOptions.FULLSCREEN); - var dialogResult = await dialogReference.Result; - if (dialogResult is null || dialogResult.Canceled) - return; - - this.SettingsManager.ConfigurationData.BiasOfTheDay.UsedBias.Clear(); - this.SettingsManager.ConfigurationData.BiasOfTheDay.DateLastBiasDrawn = DateOnly.MinValue; - await this.SettingsManager.StoreSettings(); - - await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); - } - #endregion #region Implementation of IMessageBusReceiver diff --git a/app/MindWork AI Studio/Provider/LLMProvidersExtensions.cs b/app/MindWork AI Studio/Provider/LLMProvidersExtensions.cs index d2921c9..f9addf8 100644 --- a/app/MindWork AI Studio/Provider/LLMProvidersExtensions.cs +++ b/app/MindWork AI Studio/Provider/LLMProvidersExtensions.cs @@ -107,7 +107,7 @@ public static class LLMProvidersExtensions /// The provider settings. /// The logger to use. /// The provider instance. - public static IProvider CreateProvider(this Settings.Provider providerSettings, ILogger logger) + public static IProvider CreateProvider(this AIStudio.Settings.Provider providerSettings, ILogger logger) { return providerSettings.UsedLLMProvider.CreateProvider(providerSettings.InstanceName, providerSettings.Host, providerSettings.Hostname, logger); } diff --git a/app/MindWork AI Studio/Settings/DataModel/PreviousModels/ProviderV4Extensions.cs b/app/MindWork AI Studio/Settings/DataModel/PreviousModels/ProviderV4Extensions.cs index 50be698..4699f7b 100644 --- a/app/MindWork AI Studio/Settings/DataModel/PreviousModels/ProviderV4Extensions.cs +++ b/app/MindWork AI Studio/Settings/DataModel/PreviousModels/ProviderV4Extensions.cs @@ -2,12 +2,12 @@ namespace AIStudio.Settings.DataModel.PreviousModels; public static class ProviderV4Extensions { - public static List MigrateFromV4ToV5(this IEnumerable providers) + public static List MigrateFromV4ToV5(this IEnumerable providers) { return providers.Select(provider => provider.MigrateFromV4ToV5()).ToList(); } - public static Settings.Provider MigrateFromV4ToV5(this Provider provider) => new() + public static AIStudio.Settings.Provider MigrateFromV4ToV5(this Provider provider) => new() { Num = provider.Num, Id = provider.Id, diff --git a/app/MindWork AI Studio/Tools/ComponentsExtensions.cs b/app/MindWork AI Studio/Tools/ComponentsExtensions.cs index 4374b27..0f8107c 100644 --- a/app/MindWork AI Studio/Tools/ComponentsExtensions.cs +++ b/app/MindWork AI Studio/Tools/ComponentsExtensions.cs @@ -75,7 +75,7 @@ public static class ComponentsExtensions _ => default, }; - public static Settings.Provider PreselectedProvider(this Components component, SettingsManager settingsManager) => component switch + public static AIStudio.Settings.Provider PreselectedProvider(this Components component, SettingsManager settingsManager) => component switch { Components.GRAMMAR_SPELLING_ASSISTANT => settingsManager.ConfigurationData.GrammarSpelling.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.GrammarSpelling.PreselectedProvider) : default, Components.ICON_FINDER_ASSISTANT => settingsManager.ConfigurationData.IconFinder.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.IconFinder.PreselectedProvider) : default,