Added an option to preselect data sources and options for new chats

This commit is contained in:
Thorsten Sommer 2025-02-15 15:26:13 +01:00
parent 96b61487ee
commit 3414286afa
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
7 changed files with 108 additions and 0 deletions

View File

@ -1,4 +1,5 @@
@using AIStudio.Settings
@using AIStudio.Settings.DataModel
@inherits SettingsPanelBase
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Chat" HeaderText="Chat Options">
@ -12,4 +13,10 @@
<ConfigurationProviderSelection Component="Components.CHAT" Data="@this.AvailableLLMProvidersFunc()" Disabled="@(() => !this.SettingsManager.ConfigurationData.Chat.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.Chat.PreselectedProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.Chat.PreselectedProvider = selectedValue)"/>
<ConfigurationSelect OptionDescription="Preselect one of your profiles?" Disabled="@(() => !this.SettingsManager.ConfigurationData.Chat.PreselectOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.Chat.PreselectedProfile)" Data="@ConfigurationSelectDataFactory.GetProfilesData(this.SettingsManager.ConfigurationData.Profiles)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.Chat.PreselectedProfile = selectedValue)" OptionHelp="Would you like to set one of your profiles as the default for chats?"/>
</MudPaper>
@if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager))
{
<DataSourceSelection SelectionMode="DataSourceSelectionMode.CONFIGURATION_MODE" AutoSaveAppSettings="@true" @bind-DataSourceOptions="@this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions" ConfigurationHeaderMessage="You can set default data sources and options for new chats. You can change these settings later for each individual chat."/>
<ConfigurationSelect OptionDescription="Apply default data source option when sending assistant results to chat" SelectedValue="@(() => this.SettingsManager.ConfigurationData.Chat.SendToChatDataSourceBehavior)" Data="@ConfigurationSelectDataFactory.GetSendToChatDataSourceBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.Chat.SendToChatDataSourceBehavior = selectedValue)" OptionHelp="Do you want to apply the default data source options when sending assistant results to chat?"/>
}
</ExpansionPanel>

View File

@ -94,6 +94,12 @@ public static class ConfigurationSelectDataFactory
yield return new(source.GetPreviewDescription(), source);
}
public static IEnumerable<ConfigurationSelectData<SendToChatDataSourceBehavior>> GetSendToChatDataSourceBehaviorData()
{
foreach (var behavior in Enum.GetValues<SendToChatDataSourceBehavior>())
yield return new(behavior.Description(), behavior);
}
public static IEnumerable<ConfigurationSelectData<NavBehavior>> GetNavBehaviorData()
{
yield return new("Navigation expands on mouse hover", NavBehavior.EXPAND_ON_HOVER);

View File

@ -17,6 +17,11 @@ public sealed class DataChat
/// </summary>
public AddChatProviderBehavior AddChatProviderBehavior { get; set; } = AddChatProviderBehavior.ADDED_CHATS_USE_LATEST_PROVIDER;
/// <summary>
/// Defines the data source behavior when sending assistant results to a chat.
/// </summary>
public SendToChatDataSourceBehavior SendToChatDataSourceBehavior { get; set; } = SendToChatDataSourceBehavior.NO_DATA_SOURCES;
/// <summary>
/// Preselect any chat options?
/// </summary>
@ -32,6 +37,11 @@ public sealed class DataChat
/// </summary>
public string PreselectedProfile { get; set; } = string.Empty;
/// <summary>
/// Should we preselect data sources options for a created chat?
/// </summary>
public DataSourceOptions PreselectedDataSourceOptions { get; set; } = new();
/// <summary>
/// Should we show the latest message after loading? When false, we show the first (aka oldest) message.
/// </summary>

View File

@ -0,0 +1,65 @@
namespace AIStudio.Settings.DataModel;
public sealed class DataSourceOptions
{
/// <summary>
/// Whether data sources are disabled in this context.
/// </summary>
public bool DisableDataSources { get; set; } = true;
/// <summary>
/// Whether the data sources should be selected automatically.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
public bool AutomaticDataSourceSelection { get; set; }
/// <summary>
/// Whether the retrieved data should be validated for the current prompt.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
public bool AutomaticValidation { get; set; }
/// <summary>
/// The preselected data source IDs. When these data sources are available
/// for the selected provider, they are pre-selected.
/// </summary>
public List<string> PreselectedDataSourceIds { get; set; } = [];
/// <summary>
/// Returns true when data sources are enabled.
/// </summary>
/// <returns>True when data sources are enabled.</returns>
public bool IsEnabled()
{
if(this.DisableDataSources)
return false;
if(this.AutomaticDataSourceSelection)
return true;
return this.PreselectedDataSourceIds.Count > 0;
}
/// <summary>
/// Creates a copy of the current data source options.
/// </summary>
/// <returns>A copy of the current data source options.</returns>
public DataSourceOptions CreateCopy() => new()
{
DisableDataSources = this.DisableDataSources,
AutomaticDataSourceSelection = this.AutomaticDataSourceSelection,
AutomaticValidation = this.AutomaticValidation,
PreselectedDataSourceIds = [..this.PreselectedDataSourceIds],
};
}

View File

@ -0,0 +1,7 @@
namespace AIStudio.Settings.DataModel;
public enum SendToChatDataSourceBehavior
{
NO_DATA_SOURCES,
APPLY_STANDARD_CHAT_DATA_SOURCE_OPTIONS,
}

View File

@ -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",
};
}

View File

@ -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.