diff --git a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs index 6bc70335..c63659f3 100644 --- a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs +++ b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs @@ -82,6 +82,7 @@ public abstract partial class AssistantBase : ComponentBase { this.MightPreselectValues(); this.providerSettings = this.SettingsManager.GetPreselectedProvider(this.Component); + this.currentProfile = this.SettingsManager.GetPreselectedProfile(this.Component); await base.OnInitializedAsync(); } diff --git a/app/MindWork AI Studio/Components/ProfileSelection.razor b/app/MindWork AI Studio/Components/ProfileSelection.razor index 48f93a68..a832ec60 100644 --- a/app/MindWork AI Studio/Components/ProfileSelection.razor +++ b/app/MindWork AI Studio/Components/ProfileSelection.razor @@ -1,8 +1,10 @@ - - @foreach (var profile in this.Profiles()) - { - - @profile.Name - - } - \ No newline at end of file + + + @foreach (var profile in this.SettingsManager.ConfigurationData.Profiles.GetAllProfiles()) + { + + @profile.Name + + } + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ProfileSelection.razor.cs b/app/MindWork AI Studio/Components/ProfileSelection.razor.cs index d7403020..55f2fa99 100644 --- a/app/MindWork AI Studio/Components/ProfileSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ProfileSelection.razor.cs @@ -25,11 +25,4 @@ public partial class ProfileSelection : ComponentBase this.CurrentProfile = profile; await this.CurrentProfileChanged.InvokeAsync(profile); } - - private IEnumerable Profiles() - { - yield return Profile.NO_PROFILE; - foreach (var profile in this.SettingsManager.ConfigurationData.Profiles) - yield return profile; - } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Pages/Chat.razor.cs b/app/MindWork AI Studio/Pages/Chat.razor.cs index 1dbecd0c..e94a9cad 100644 --- a/app/MindWork AI Studio/Pages/Chat.razor.cs +++ b/app/MindWork AI Studio/Pages/Chat.razor.cs @@ -62,6 +62,7 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES); this.providerSettings = this.SettingsManager.GetPreselectedProvider(Tools.Components.CHAT); + this.currentProfile = this.SettingsManager.GetPreselectedProfile(Tools.Components.CHAT); var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages(Event.SEND_TO_CHAT).FirstOrDefault(); if (deferredContent is not null) { diff --git a/app/MindWork AI Studio/Pages/Settings.razor b/app/MindWork AI Studio/Pages/Settings.razor index 509813c8..32f979cf 100644 --- a/app/MindWork AI Studio/Pages/Settings.razor +++ b/app/MindWork AI Studio/Pages/Settings.razor @@ -129,6 +129,7 @@ + @@ -137,6 +138,7 @@ + @@ -180,6 +182,7 @@ } + @@ -222,13 +225,13 @@ - @if (this.SettingsManager.ConfigurationData.Agenda.PreselectedTargetLanguage is CommonLanguages.OTHER) { } + @@ -270,6 +273,7 @@ } + @@ -280,6 +284,7 @@ + diff --git a/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs b/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs index 2266b6ae..c8dfd39f 100644 --- a/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs +++ b/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs @@ -130,4 +130,10 @@ public static class ConfigurationSelectDataFactory foreach (var voice in Enum.GetValues()) yield return new(voice.Name(), voice); } + + public static IEnumerable> GetProfilesData(IEnumerable profiles) + { + foreach (var profile in profiles.GetAllProfiles()) + yield return new(profile.Name, profile.Id); + } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/DataAgenda.cs b/app/MindWork AI Studio/Settings/DataModel/DataAgenda.cs index 46ef668f..39602747 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataAgenda.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataAgenda.cs @@ -55,4 +55,9 @@ public sealed class DataAgenda /// Preselect a agenda provider? /// public string PreselectedProvider { get; set; } = string.Empty; + + /// + /// Preselect a profile? + /// + public string PreselectedProfile { get; set; } = string.Empty; } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/DataApp.cs b/app/MindWork AI Studio/Settings/DataModel/DataApp.cs index 55b9e93f..ce1f475f 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataApp.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataApp.cs @@ -27,4 +27,9 @@ public sealed class DataApp /// Should we preselect a provider for the entire app? /// public string PreselectedProvider { get; set; } = string.Empty; + + /// + /// Should we preselect a profile for the entire app? + /// + public string PreselectedProfile { get; set; } = string.Empty; } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/DataChat.cs b/app/MindWork AI Studio/Settings/DataModel/DataChat.cs index eca85695..f68865f5 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataChat.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataChat.cs @@ -16,6 +16,11 @@ public sealed class DataChat /// Should we preselect a provider for the chat? /// public string PreselectedProvider { get; set; } = string.Empty; + + /// + /// Preselect a profile? + /// + public string PreselectedProfile { get; set; } = string.Empty; /// /// Should we show the latest message after loading? When false, we show the first (aka oldest) message. diff --git a/app/MindWork AI Studio/Settings/DataModel/DataCoding.cs b/app/MindWork AI Studio/Settings/DataModel/DataCoding.cs index 7608f616..f83c6165 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataCoding.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataCoding.cs @@ -28,4 +28,9 @@ public sealed class DataCoding /// Which coding provider should be preselected? /// public string PreselectedProvider { get; set; } = string.Empty; + + /// + /// Preselect a profile? + /// + public string PreselectedProfile { get; set; } = string.Empty; } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/DataEMail.cs b/app/MindWork AI Studio/Settings/DataModel/DataEMail.cs index ab659fcf..a913c7f3 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataEMail.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataEMail.cs @@ -28,6 +28,11 @@ public sealed class DataEMail /// Preselect a provider? /// public string PreselectedProvider { get; set; } = string.Empty; + + /// + /// Preselect a profile? + /// + public string PreselectedProfile { get; set; } = string.Empty; /// /// Preselect a greeting phrase? diff --git a/app/MindWork AI Studio/Settings/DataModel/DataLegalCheck.cs b/app/MindWork AI Studio/Settings/DataModel/DataLegalCheck.cs index 80dc53f6..c72b157f 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataLegalCheck.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataLegalCheck.cs @@ -26,4 +26,9 @@ public class DataLegalCheck /// The preselected translator provider. /// public string PreselectedProvider { get; set; } = string.Empty; + + /// + /// Preselect a profile? + /// + public string PreselectedProfile { get; set; } = string.Empty; } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/Profile.cs b/app/MindWork AI Studio/Settings/Profile.cs index fd1da079..b7a7da6e 100644 --- a/app/MindWork AI Studio/Settings/Profile.cs +++ b/app/MindWork AI Studio/Settings/Profile.cs @@ -20,7 +20,7 @@ public readonly record struct Profile(uint Num, string Id, string Name, string N public override string ToString() => this.Name; #endregion - + public string ToSystemPrompt() { if(this.Num == uint.MaxValue) diff --git a/app/MindWork AI Studio/Settings/SettingsManager.cs b/app/MindWork AI Studio/Settings/SettingsManager.cs index 36441bcc..428c5184 100644 --- a/app/MindWork AI Studio/Settings/SettingsManager.cs +++ b/app/MindWork AI Studio/Settings/SettingsManager.cs @@ -138,4 +138,24 @@ public sealed class SettingsManager(ILogger logger) return this.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.ConfigurationData.App.PreselectedProvider); } + + public Profile GetPreselectedProfile(Tools.Components component) + { + var preselection = component switch + { + Tools.Components.CHAT => this.ConfigurationData.Chat.PreselectOptions ? this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == this.ConfigurationData.Chat.PreselectedProfile) : default, + Tools.Components.AGENDA_ASSISTANT => this.ConfigurationData.Agenda.PreselectOptions ? this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == this.ConfigurationData.Agenda.PreselectedProfile) : default, + Tools.Components.CODING_ASSISTANT => this.ConfigurationData.Coding.PreselectOptions ? this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == this.ConfigurationData.Coding.PreselectedProfile) : default, + Tools.Components.EMAIL_ASSISTANT => this.ConfigurationData.EMail.PreselectOptions ? this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == this.ConfigurationData.EMail.PreselectedProfile) : default, + Tools.Components.LEGAL_CHECK_ASSISTANT => this.ConfigurationData.LegalCheck.PreselectOptions ? this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == this.ConfigurationData.LegalCheck.PreselectedProfile) : default, + + _ => default, + }; + + if (preselection != default) + return preselection; + + preselection = this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == this.ConfigurationData.App.PreselectedProfile); + return preselection != default ? preselection : Profile.NO_PROFILE; + } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/ProfileExtensions.cs b/app/MindWork AI Studio/Tools/ProfileExtensions.cs new file mode 100644 index 00000000..53cb2562 --- /dev/null +++ b/app/MindWork AI Studio/Tools/ProfileExtensions.cs @@ -0,0 +1,13 @@ +using AIStudio.Settings; + +namespace AIStudio.Tools; + +public static class ProfileExtensions +{ + public static IEnumerable GetAllProfiles(this IEnumerable profiles) + { + yield return Profile.NO_PROFILE; + foreach (var profile in profiles) + yield return profile; + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md index 79a4ae85..14276366 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md @@ -2,6 +2,7 @@ - Added the possibility to define multiple profiles in the settings. Use profiles to share some information about you with the AI. - Added profiles to the chat interface. You can now select a profile for each chat or even change the profile during a chat. - Added profiles to some assistants. It makes no sense to have profiles for, e.g., translation, etc. +- Added the possibility to preselect any of your profiles as the default profile for the entire app or configure individual profiles for assistants and chats. - Added an introductory description to the provider settings. - Added an indicator for the current and maximal length of the provider instance name. - Fixed the bug that the model name for Fireworks was not loaded when editing the provider settings.