mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-14 01:53:48 +00:00
Added explicit profile behavior choices (#696)
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
This commit is contained in:
1 parent
24e72de9a2
commit
4a8348b9df
16 files changed
+155
-50
No files matched your search
@@ -204,6 +204,15 @@ public static class ConfigurationSelectDataFactory
|
||||
yield return new(profile.GetSafeName(), profile.Id);
|
||||
}
|
||||
|
||||
public static IEnumerable<ConfigurationSelectData<ProfilePreselection>> GetComponentProfilesData(IEnumerable<Profile> profiles)
|
||||
{
|
||||
yield return new(TB("Use app default profile"), ProfilePreselection.AppDefault);
|
||||
yield return new(Profile.NO_PROFILE.GetSafeName(), ProfilePreselection.NoProfile);
|
||||
|
||||
foreach (var profile in profiles)
|
||||
yield return new(profile.GetSafeName(), ProfilePreselection.Specific(profile.Id));
|
||||
}
|
||||
|
||||
public static IEnumerable<ConfigurationSelectData<string>> GetTranscriptionProvidersData(IEnumerable<TranscriptionProvider> transcriptionProviders)
|
||||
{
|
||||
foreach (var provider in transcriptionProviders)
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
namespace AIStudio.Settings;
|
||||
|
||||
public readonly record struct ProfilePreselection
|
||||
{
|
||||
public ProfilePreselectionMode Mode { get; }
|
||||
|
||||
public string SpecificProfileId { get; }
|
||||
|
||||
public bool UseAppDefault => this.Mode == ProfilePreselectionMode.USE_APP_DEFAULT;
|
||||
|
||||
public bool DoNotPreselectProfile => this.Mode == ProfilePreselectionMode.USE_NO_PROFILE;
|
||||
|
||||
public bool UseSpecificProfile => this.Mode == ProfilePreselectionMode.USE_SPECIFIC_PROFILE;
|
||||
|
||||
public static ProfilePreselection AppDefault => new(ProfilePreselectionMode.USE_APP_DEFAULT, string.Empty);
|
||||
|
||||
public static ProfilePreselection NoProfile => new(ProfilePreselectionMode.USE_NO_PROFILE, Profile.NO_PROFILE.Id);
|
||||
|
||||
private ProfilePreselection(ProfilePreselectionMode mode, string specificProfileId)
|
||||
{
|
||||
this.Mode = mode;
|
||||
this.SpecificProfileId = specificProfileId;
|
||||
}
|
||||
|
||||
public static ProfilePreselection Specific(string profileId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(profileId))
|
||||
throw new ArgumentException("A specific profile preselection requires a profile ID.", nameof(profileId));
|
||||
|
||||
if (profileId.Equals(Profile.NO_PROFILE.Id, StringComparison.OrdinalIgnoreCase))
|
||||
throw new ArgumentException("Use NoProfile for the NO_PROFILE selection.", nameof(profileId));
|
||||
|
||||
return new(ProfilePreselectionMode.USE_SPECIFIC_PROFILE, profileId);
|
||||
}
|
||||
|
||||
public static ProfilePreselection FromStoredValue(string? storedValue)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(storedValue))
|
||||
return AppDefault;
|
||||
|
||||
if (storedValue.Equals(Profile.NO_PROFILE.Id, StringComparison.OrdinalIgnoreCase))
|
||||
return NoProfile;
|
||||
|
||||
return new(ProfilePreselectionMode.USE_SPECIFIC_PROFILE, storedValue);
|
||||
}
|
||||
|
||||
public static implicit operator string(ProfilePreselection preselection) => preselection.Mode switch
|
||||
{
|
||||
ProfilePreselectionMode.USE_APP_DEFAULT => string.Empty,
|
||||
ProfilePreselectionMode.USE_NO_PROFILE => Profile.NO_PROFILE.Id,
|
||||
ProfilePreselectionMode.USE_SPECIFIC_PROFILE => preselection.SpecificProfileId,
|
||||
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace AIStudio.Settings;
|
||||
|
||||
public enum ProfilePreselectionMode
|
||||
{
|
||||
USE_APP_DEFAULT,
|
||||
USE_NO_PROFILE,
|
||||
USE_SPECIFIC_PROFILE,
|
||||
}
|
||||
@@ -294,12 +294,32 @@ public sealed class SettingsManager
|
||||
|
||||
public Profile GetPreselectedProfile(Tools.Components component)
|
||||
{
|
||||
var preselection = component.PreselectedProfile(this);
|
||||
if (preselection != Profile.NO_PROFILE)
|
||||
return preselection;
|
||||
|
||||
preselection = this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id.Equals(this.ConfigurationData.App.PreselectedProfile, StringComparison.OrdinalIgnoreCase));
|
||||
return preselection ?? Profile.NO_PROFILE;
|
||||
var preselection = component.GetProfilePreselection(this);
|
||||
if (preselection.DoNotPreselectProfile)
|
||||
return Profile.NO_PROFILE;
|
||||
|
||||
if (preselection.UseSpecificProfile)
|
||||
{
|
||||
var componentProfile = this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id.Equals(preselection.SpecificProfileId, StringComparison.OrdinalIgnoreCase));
|
||||
return componentProfile ?? Profile.NO_PROFILE;
|
||||
}
|
||||
|
||||
var appPreselection = ProfilePreselection.FromStoredValue(this.ConfigurationData.App.PreselectedProfile);
|
||||
if (appPreselection.DoNotPreselectProfile || !appPreselection.UseSpecificProfile)
|
||||
return Profile.NO_PROFILE;
|
||||
|
||||
var appProfile = this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id.Equals(appPreselection.SpecificProfileId, StringComparison.OrdinalIgnoreCase));
|
||||
return appProfile ?? Profile.NO_PROFILE;
|
||||
}
|
||||
|
||||
public Profile GetAppPreselectedProfile()
|
||||
{
|
||||
var appPreselection = ProfilePreselection.FromStoredValue(this.ConfigurationData.App.PreselectedProfile);
|
||||
if (appPreselection.DoNotPreselectProfile || !appPreselection.UseSpecificProfile)
|
||||
return Profile.NO_PROFILE;
|
||||
|
||||
var appProfile = this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id.Equals(appPreselection.SpecificProfileId, StringComparison.OrdinalIgnoreCase));
|
||||
return appProfile ?? Profile.NO_PROFILE;
|
||||
}
|
||||
|
||||
public ChatTemplate GetPreselectedChatTemplate(Tools.Components component)
|
||||
|
||||
Reference in new issue
Block a user