mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 23:18:00 +00:00
Added preview feature configuration (#227)
This commit is contained in:
1 parent
e2859b3d76
commit
55d7895f58
26 files changed
+270
-41
No files matched your search
@@ -88,6 +88,12 @@ public static class ConfigurationSelectDataFactory
|
||||
yield return new("Show also experimental features: these are experimental; expect bugs, missing features, many changes", PreviewVisibility.EXPERIMENTAL);
|
||||
}
|
||||
|
||||
public static IEnumerable<ConfigurationSelectData<PreviewFeatures>> GetPreviewFeaturesData(SettingsManager settingsManager)
|
||||
{
|
||||
foreach (var source in settingsManager.ConfigurationData.App.PreviewVisibility.GetPreviewFeatures())
|
||||
yield return new(source.GetPreviewDescription(), source);
|
||||
}
|
||||
|
||||
public static IEnumerable<ConfigurationSelectData<NavBehavior>> GetNavBehaviorData()
|
||||
{
|
||||
yield return new("Navigation expands on mouse hover", NavBehavior.EXPAND_ON_HOVER);
|
||||
|
||||
@@ -32,6 +32,11 @@ public sealed class DataApp
|
||||
/// The visibility setting for previews features.
|
||||
/// </summary>
|
||||
public PreviewVisibility PreviewVisibility { get; set; } = PreviewVisibility.NONE;
|
||||
|
||||
/// <summary>
|
||||
/// The enabled preview features.
|
||||
/// </summary>
|
||||
public HashSet<PreviewFeatures> EnabledPreviewFeatures { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Should we preselect a provider for the entire app?
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public static class PreviewFeatureExtensions
|
||||
{
|
||||
public static string GetPreviewDescription(this PreviewFeatures feature) => feature switch
|
||||
{
|
||||
PreviewFeatures.PRE_WRITER_MODE_2024 => "Writer Mode: Experiments about how to write long texts using AI",
|
||||
PreviewFeatures.PRE_RAG_2024 => "RAG: Preview of our RAG implementation where you can refer your files or integrate enterprise data within your company",
|
||||
|
||||
_ => "Unknown preview feature"
|
||||
};
|
||||
|
||||
public static bool IsEnabled(this PreviewFeatures feature, SettingsManager settingsManager) => settingsManager.ConfigurationData.App.EnabledPreviewFeatures.Contains(feature);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public enum PreviewFeatures
|
||||
{
|
||||
//
|
||||
// Important: Never delete any enum value from this list.
|
||||
// We must be able to deserialize old settings files that may contain these values.
|
||||
//
|
||||
PRE_WRITER_MODE_2024,
|
||||
PRE_RAG_2024,
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public static class PreviewVisibilityExtensions
|
||||
{
|
||||
public static IList<PreviewFeatures> GetPreviewFeatures(this PreviewVisibility visibility)
|
||||
{
|
||||
var features = new List<PreviewFeatures>();
|
||||
if (visibility >= PreviewVisibility.RELEASE_CANDIDATE)
|
||||
{
|
||||
}
|
||||
|
||||
if (visibility >= PreviewVisibility.BETA)
|
||||
{
|
||||
}
|
||||
|
||||
if (visibility >= PreviewVisibility.ALPHA)
|
||||
{
|
||||
}
|
||||
|
||||
if (visibility >= PreviewVisibility.PROTOTYPE)
|
||||
{
|
||||
features.Add(PreviewFeatures.PRE_RAG_2024);
|
||||
}
|
||||
|
||||
if (visibility >= PreviewVisibility.EXPERIMENTAL)
|
||||
{
|
||||
features.Add(PreviewFeatures.PRE_WRITER_MODE_2024);
|
||||
}
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
public static HashSet<PreviewFeatures> FilterPreviewFeatures(this PreviewVisibility visibility, HashSet<PreviewFeatures> enabledFeatures)
|
||||
{
|
||||
var filteredFeatures = new HashSet<PreviewFeatures>();
|
||||
var previewFeatures = visibility.GetPreviewFeatures();
|
||||
foreach (var feature in enabledFeatures)
|
||||
{
|
||||
if (previewFeatures.Contains(feature))
|
||||
filteredFeatures.Add(feature);
|
||||
}
|
||||
|
||||
return filteredFeatures;
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,14 @@ public sealed class SettingsManager(ILogger<SettingsManager> logger)
|
||||
}
|
||||
|
||||
this.ConfigurationData = SettingsMigrations.Migrate(this.logger, settingsVersion, await File.ReadAllTextAsync(settingsPath), JSON_OPTIONS);
|
||||
|
||||
//
|
||||
// We filter the enabled preview features based on the preview visibility.
|
||||
// This is necessary when the app starts up: some preview features may have
|
||||
// been disabled or released from the last time the app was started.
|
||||
//
|
||||
this.ConfigurationData.App.EnabledPreviewFeatures = this.ConfigurationData.App.PreviewVisibility.FilterPreviewFeatures(this.ConfigurationData.App.EnabledPreviewFeatures);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user