From 3414286afa57a7a0e594910ff28725877a45b8f8 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sat, 15 Feb 2025 15:26:13 +0100 Subject: [PATCH] Added an option to preselect data sources and options for new chats --- .../Settings/SettingsPanelChat.razor | 7 ++ .../Settings/ConfigurationSelectData.cs | 6 ++ .../Settings/DataModel/DataChat.cs | 10 +++ .../Settings/DataModel/DataSourceOptions.cs | 65 +++++++++++++++++++ .../DataModel/SendToChatDataSourceBehavior.cs | 7 ++ .../SendToChatDataSourceBehaviorExtensions.cs | 12 ++++ .../wwwroot/changelog/v0.9.29.md | 1 + 7 files changed, 108 insertions(+) create mode 100644 app/MindWork AI Studio/Settings/DataModel/DataSourceOptions.cs create mode 100644 app/MindWork AI Studio/Settings/DataModel/SendToChatDataSourceBehavior.cs create mode 100644 app/MindWork AI Studio/Settings/DataModel/SendToChatDataSourceBehaviorExtensions.cs diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor index 4f677ae3..8b274405 100644 --- a/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelChat.razor @@ -1,4 +1,5 @@ @using AIStudio.Settings +@using AIStudio.Settings.DataModel @inherits SettingsPanelBase @@ -12,4 +13,10 @@ + + @if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager)) + { + + + } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs b/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs index 3f6ec933..5a2b8f11 100644 --- a/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs +++ b/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs @@ -94,6 +94,12 @@ public static class ConfigurationSelectDataFactory yield return new(source.GetPreviewDescription(), source); } + public static IEnumerable> GetSendToChatDataSourceBehaviorData() + { + foreach (var behavior in Enum.GetValues()) + yield return new(behavior.Description(), behavior); + } + public static IEnumerable> GetNavBehaviorData() { yield return new("Navigation expands on mouse hover", NavBehavior.EXPAND_ON_HOVER); diff --git a/app/MindWork AI Studio/Settings/DataModel/DataChat.cs b/app/MindWork AI Studio/Settings/DataModel/DataChat.cs index 8283150b..baf995fd 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataChat.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataChat.cs @@ -17,6 +17,11 @@ public sealed class DataChat /// public AddChatProviderBehavior AddChatProviderBehavior { get; set; } = AddChatProviderBehavior.ADDED_CHATS_USE_LATEST_PROVIDER; + /// + /// Defines the data source behavior when sending assistant results to a chat. + /// + public SendToChatDataSourceBehavior SendToChatDataSourceBehavior { get; set; } = SendToChatDataSourceBehavior.NO_DATA_SOURCES; + /// /// Preselect any chat options? /// @@ -31,6 +36,11 @@ public sealed class DataChat /// Preselect a profile? /// public string PreselectedProfile { get; set; } = string.Empty; + + /// + /// Should we preselect data sources options for a created chat? + /// + public DataSourceOptions PreselectedDataSourceOptions { get; set; } = new(); /// /// 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/DataSourceOptions.cs b/app/MindWork AI Studio/Settings/DataModel/DataSourceOptions.cs new file mode 100644 index 00000000..1def9887 --- /dev/null +++ b/app/MindWork AI Studio/Settings/DataModel/DataSourceOptions.cs @@ -0,0 +1,65 @@ +namespace AIStudio.Settings.DataModel; + +public sealed class DataSourceOptions +{ + /// + /// Whether data sources are disabled in this context. + /// + public bool DisableDataSources { get; set; } = true; + + /// + /// Whether the data sources should be selected automatically. + /// + /// + /// When true, the appropriate data sources for the current prompt are + /// selected automatically. When false, the user has to select the + /// data sources manually. + /// + /// This setting does not affect the selection of the actual data + /// for augmentation. + /// + public bool AutomaticDataSourceSelection { get; set; } + + /// + /// Whether the retrieved data should be validated for the current prompt. + /// + /// + /// When true, the retrieved data is validated against the current prompt. + /// An AI will decide whether the data point is useful for answering the + /// prompt or not. + /// + public bool AutomaticValidation { get; set; } + + /// + /// The preselected data source IDs. When these data sources are available + /// for the selected provider, they are pre-selected. + /// + public List PreselectedDataSourceIds { get; set; } = []; + + /// + /// Returns true when data sources are enabled. + /// + /// True when data sources are enabled. + public bool IsEnabled() + { + if(this.DisableDataSources) + return false; + + if(this.AutomaticDataSourceSelection) + return true; + + return this.PreselectedDataSourceIds.Count > 0; + } + + /// + /// Creates a copy of the current data source options. + /// + /// A copy of the current data source options. + public DataSourceOptions CreateCopy() => new() + { + DisableDataSources = this.DisableDataSources, + AutomaticDataSourceSelection = this.AutomaticDataSourceSelection, + AutomaticValidation = this.AutomaticValidation, + PreselectedDataSourceIds = [..this.PreselectedDataSourceIds], + }; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/SendToChatDataSourceBehavior.cs b/app/MindWork AI Studio/Settings/DataModel/SendToChatDataSourceBehavior.cs new file mode 100644 index 00000000..fcbcaf4b --- /dev/null +++ b/app/MindWork AI Studio/Settings/DataModel/SendToChatDataSourceBehavior.cs @@ -0,0 +1,7 @@ +namespace AIStudio.Settings.DataModel; + +public enum SendToChatDataSourceBehavior +{ + NO_DATA_SOURCES, + APPLY_STANDARD_CHAT_DATA_SOURCE_OPTIONS, +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/SendToChatDataSourceBehaviorExtensions.cs b/app/MindWork AI Studio/Settings/DataModel/SendToChatDataSourceBehaviorExtensions.cs new file mode 100644 index 00000000..3894ba2b --- /dev/null +++ b/app/MindWork AI Studio/Settings/DataModel/SendToChatDataSourceBehaviorExtensions.cs @@ -0,0 +1,12 @@ +namespace AIStudio.Settings.DataModel; + +public static class SendToChatDataSourceBehaviorExtensions +{ + public static string Description(this SendToChatDataSourceBehavior behavior) => behavior switch + { + SendToChatDataSourceBehavior.NO_DATA_SOURCES => "Use no data sources, when sending an assistant result to a chat", + SendToChatDataSourceBehavior.APPLY_STANDARD_CHAT_DATA_SOURCE_OPTIONS => "Apply standard chat data source options, when sending an assistant result to a chat", + + _ => "Unknown behavior", + }; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.29.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.29.md index e68ae615..d13c7687 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.29.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.29.md @@ -1,4 +1,5 @@ # v0.9.29, build 204 (2025-02-xx xx:xx UTC) - Added the possibility to select data sources for chats. This preview feature is hidden behind the RAG feature flag, check your app options in case you want to enable it. - Added an option to all data sources to select a local security policy. This preview feature is hidden behind the RAG feature flag. +- Added an option to preselect data sources and options for new chats. This preview feature is hidden behind the RAG feature flag. - Improved confidence card for small spaces. \ No newline at end of file