Add default configuration for assistants (#52)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2024-07-28 11:20:00 +02:00
1 parent a1c4618796
commit b3b8bf23dc
42 files changed
+729 -138

No files matched your search

@@ -0,0 +1,86 @@
using AIStudio.Components.Pages.Coding;
using AIStudio.Components.Pages.IconFinder;
using AIStudio.Components.Pages.TextSummarizer;
using AIStudio.Settings.DataModel;
using AIStudio.Tools;
namespace AIStudio.Settings;
/// <summary>
/// A data structure to map a name to a value.
/// </summary>
/// <param name="Name">The name of the value, to be displayed in the UI.</param>
/// <param name="Value">The value to be stored.</param>
/// <typeparam name="T">The type of the value to store.</typeparam>
public readonly record struct ConfigurationSelectData<T>(string Name, T Value);
/// <summary>
/// A static factory class to get the lists of selectable values.
/// </summary>
public static class ConfigurationSelectDataFactory
{
public static IEnumerable<ConfigurationSelectData<SendBehavior>> GetSendBehaviorData()
{
yield return new("No key is sending the input", SendBehavior.NO_KEY_IS_SENDING);
yield return new("Modifier key + enter is sending the input", SendBehavior.MODIFER_ENTER_IS_SENDING);
yield return new("Enter is sending the input", SendBehavior.ENTER_IS_SENDING);
}
public static IEnumerable<ConfigurationSelectData<UpdateBehavior>> GetUpdateBehaviorData()
{
yield return new("No automatic update checks", UpdateBehavior.NO_CHECK);
yield return new("Once at startup", UpdateBehavior.ONCE_STARTUP);
yield return new("Check every hour", UpdateBehavior.HOURLY);
yield return new("Check every day", UpdateBehavior.DAILY);
yield return new ("Check every week", UpdateBehavior.WEEKLY);
}
public static IEnumerable<ConfigurationSelectData<WorkspaceStorageBehavior>> GetWorkspaceStorageBehaviorData()
{
yield return new("Disable workspaces", WorkspaceStorageBehavior.DISABLE_WORKSPACES);
yield return new("Store chats automatically", WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY);
yield return new("Store chats manually", WorkspaceStorageBehavior.STORE_CHATS_MANUALLY);
}
public static IEnumerable<ConfigurationSelectData<WorkspaceStorageTemporaryMaintenancePolicy>> GetWorkspaceStorageTemporaryMaintenancePolicyData()
{
yield return new("No automatic maintenance for temporary chats", WorkspaceStorageTemporaryMaintenancePolicy.NO_AUTOMATIC_MAINTENANCE);
yield return new("Delete temporary chats older than 7 days", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_7_DAYS);
yield return new("Delete temporary chats older than 30 days", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_30_DAYS);
yield return new("Delete temporary chats older than 90 days", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_90_DAYS);
yield return new("Delete temporary chats older than 180 days", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_180_DAYS);
yield return new("Delete temporary chats older than 1 year", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_365_DAYS);
}
public static IEnumerable<ConfigurationSelectData<NavBehavior>> GetNavBehaviorData()
{
yield return new("Navigation expands on mouse hover", NavBehavior.EXPAND_ON_HOVER);
yield return new("Navigation never expands, but there are tooltips", NavBehavior.NEVER_EXPAND_USE_TOOLTIPS);
yield return new("Navigation never expands, no tooltips", NavBehavior.NEVER_EXPAND_NO_TOOLTIPS);
yield return new("Always expand navigation", NavBehavior.ALWAYS_EXPAND);
}
public static IEnumerable<ConfigurationSelectData<IconSources>> GetIconSourcesData()
{
foreach (var source in Enum.GetValues<IconSources>())
yield return new(source.Name(), source);
}
public static IEnumerable<ConfigurationSelectData<CommonLanguages>> GetCommonLanguagesData()
{
foreach (var language in Enum.GetValues<CommonLanguages>())
yield return new(language.Name(), language);
}
public static IEnumerable<ConfigurationSelectData<CommonCodingLanguages>> GetCommonCodingLanguagesData()
{
foreach (var language in Enum.GetValues<CommonCodingLanguages>())
yield return new(language.Name(), language);
}
public static IEnumerable<ConfigurationSelectData<Complexity>> GetComplexityData()
{
foreach (var complexity in Enum.GetValues<Complexity>())
yield return new(complexity.Name(), complexity);
}
}
-59
View File
@@ -1,59 +0,0 @@
namespace AIStudio.Settings;
/// <summary>
/// The data model for the settings file.
/// </summary>
public sealed class Data
{
/// <summary>
/// The version of the settings file. Allows us to upgrade the settings
/// when a new version is available.
/// </summary>
public Version Version { get; init; } = Version.V3;
/// <summary>
/// List of configured providers.
/// </summary>
public List<Provider> Providers { get; init; } = [];
/// <summary>
/// The next provider number to use.
/// </summary>
public uint NextProviderNum { get; set; } = 1;
/// <summary>
/// Should we save energy? When true, we will update content streamed
/// from the server, i.e., AI, less frequently.
/// </summary>
public bool IsSavingEnergy { get; set; }
/// <summary>
/// Shortcuts to send the input to the AI.
/// </summary>
public SendBehavior ShortcutSendBehavior { get; set; } = SendBehavior.MODIFER_ENTER_IS_SENDING;
/// <summary>
/// Should we enable spellchecking for all input fields?
/// </summary>
public bool EnableSpellchecking { get; set; }
/// <summary>
/// If and when we should look for updates.
/// </summary>
public UpdateBehavior UpdateBehavior { get; set; } = UpdateBehavior.ONCE_STARTUP;
/// <summary>
/// The chat storage behavior.
/// </summary>
public WorkspaceStorageBehavior WorkspaceStorageBehavior { get; set; } = WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY;
/// <summary>
/// The chat storage maintenance behavior.
/// </summary>
public WorkspaceStorageTemporaryMaintenancePolicy WorkspaceStorageTemporaryMaintenancePolicy { get; set; } = WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_90_DAYS;
/// <summary>
/// The navigation behavior.
/// </summary>
public NavBehavior NavigationBehavior { get; set; } = NavBehavior.EXPAND_ON_HOVER;
}
@@ -0,0 +1,192 @@
using AIStudio.Components.Pages.Coding;
using AIStudio.Components.Pages.IconFinder;
using AIStudio.Components.Pages.TextSummarizer;
using AIStudio.Tools;
namespace AIStudio.Settings.DataModel;
/// <summary>
/// The data model for the settings file.
/// </summary>
public sealed class Data
{
/// <summary>
/// The version of the settings file. Allows us to upgrade the settings
/// when a new version is available.
/// </summary>
public Version Version { get; init; } = Version.V3;
/// <summary>
/// List of configured providers.
/// </summary>
public List<Provider> Providers { get; init; } = [];
/// <summary>
/// The next provider number to use.
/// </summary>
public uint NextProviderNum { get; set; } = 1;
#region App Settings
/// <summary>
/// Should we save energy? When true, we will update content streamed
/// from the server, i.e., AI, less frequently.
/// </summary>
public bool IsSavingEnergy { get; set; }
/// <summary>
/// Should we enable spellchecking for all input fields?
/// </summary>
public bool EnableSpellchecking { get; set; }
/// <summary>
/// If and when we should look for updates.
/// </summary>
public UpdateBehavior UpdateBehavior { get; set; } = UpdateBehavior.ONCE_STARTUP;
/// <summary>
/// The navigation behavior.
/// </summary>
public NavBehavior NavigationBehavior { get; set; } = NavBehavior.EXPAND_ON_HOVER;
#endregion
#region Chat Settings
/// <summary>
/// Shortcuts to send the input to the AI.
/// </summary>
public SendBehavior ShortcutSendBehavior { get; set; } = SendBehavior.MODIFER_ENTER_IS_SENDING;
#endregion
#region Workspace Settings
/// <summary>
/// The chat storage behavior.
/// </summary>
public WorkspaceStorageBehavior WorkspaceStorageBehavior { get; set; } = WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY;
/// <summary>
/// The chat storage maintenance behavior.
/// </summary>
public WorkspaceStorageTemporaryMaintenancePolicy WorkspaceStorageTemporaryMaintenancePolicy { get; set; } = WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_90_DAYS;
#endregion
#region Assiatant: Icon Finder Settings
/// <summary>
/// Do we want to preselect any icon options?
/// </summary>
public bool PreselectIconOptions { get; set; }
/// <summary>
/// The preselected icon source.
/// </summary>
public IconSources PreselectedIconSource { get; set; }
/// <summary>
/// The preselected icon provider.
/// </summary>
public string PreselectedIconProvider { get; set; } = string.Empty;
#endregion
#region Assistant: Translation Settings
/// <summary>
/// The live translation interval for debouncing in milliseconds.
/// </summary>
public int LiveTranslationDebounceIntervalMilliseconds { get; set; } = 1_000;
/// <summary>
/// Do we want to preselect any translator options?
/// </summary>
public bool PreselectTranslationOptions { get; set; }
/// <summary>
/// Preselect the live translation?
/// </summary>
public bool PreselectLiveTranslation { get; set; }
/// <summary>
/// Preselect the target language?
/// </summary>
public CommonLanguages PreselectedTranslationTargetLanguage { get; set; } = CommonLanguages.EN_US;
/// <summary>
/// Preselect any other language?
/// </summary>
public string PreselectTranslationOtherLanguage { get; set; } = string.Empty;
/// <summary>
/// The preselected translator provider.
/// </summary>
public string PreselectedTranslationProvider { get; set; } = string.Empty;
#endregion
#region Assistant: Coding Settings
/// <summary>
/// Preselect any coding options?
/// </summary>
public bool PreselectCodingOptions { get; set; }
/// <summary>
/// Preselect the compiler messages?
/// </summary>
public bool PreselectCodingCompilerMessages { get; set; }
/// <summary>
/// Preselect the coding language for new contexts?
/// </summary>
public CommonCodingLanguages PreselectedCodingLanguage { get; set; }
/// <summary>
/// Do you want to preselect any other language?
/// </summary>
public string PreselectedCodingOtherLanguage { get; set; } = string.Empty;
/// <summary>
/// Which coding provider should be preselected?
/// </summary>
public string PreselectedCodingProvider { get; set; } = string.Empty;
#endregion
#region Assistant: Text Summarizer Settings
/// <summary>
/// Preselect any text summarizer options?
/// </summary>
public bool PreselectTextSummarizerOptions { get; set; }
/// <summary>
/// Preselect the target language?
/// </summary>
public CommonLanguages PreselectedTextSummarizerTargetLanguage { get; set; }
/// <summary>
/// Preselect any other language?
/// </summary>
public string PreselectedTextSummarizerOtherLanguage { get; set; } = string.Empty;
/// <summary>
/// Preselect the complexity?
/// </summary>
public Complexity PreselectedTextSummarizerComplexity { get; set; }
/// <summary>
/// Preselect any expertise in a field?
/// </summary>
public string PreselectedTextSummarizerExpertInField { get; set; } = string.Empty;
/// <summary>
/// Preselect a text summarizer provider?
/// </summary>
public string PreselectedTextSummarizerProvider { get; set; } = string.Empty;
#endregion
}
@@ -1,4 +1,4 @@
namespace AIStudio.Settings;
namespace AIStudio.Settings.DataModel;
public enum NavBehavior
{
@@ -1,4 +1,4 @@
namespace AIStudio.Settings;
namespace AIStudio.Settings.DataModel;
/// <summary>
/// Possible behaviors for sending the input to the AI.
@@ -1,4 +1,4 @@
namespace AIStudio.Settings;
namespace AIStudio.Settings.DataModel;
public enum UpdateBehavior
{
@@ -1,4 +1,4 @@
namespace AIStudio.Settings;
namespace AIStudio.Settings.DataModel;
public enum WorkspaceStorageBehavior
{
@@ -1,4 +1,4 @@
namespace AIStudio.Settings;
namespace AIStudio.Settings.DataModel;
public enum WorkspaceStorageTemporaryMaintenancePolicy
{
@@ -1,5 +1,6 @@
using System.Text.Json;
using AIStudio.Provider;
using AIStudio.Settings.DataModel;
// ReSharper disable NotAccessedPositionalProperty.Local
@@ -1,3 +1,5 @@
using AIStudio.Settings.DataModel;
using Host = AIStudio.Provider.SelfHosted.Host;
namespace AIStudio.Settings;