AI-Studio/app/MindWork AI Studio/Settings/DataModel/DataSourceOptions.cs

79 lines
2.9 KiB
C#
Raw Normal View History

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; }
2026-09-27 14:26:52 +00:00
/// <summary>
/// How the data sources should be searched.
/// </summary>
/// <remarks>
/// This is a preference. The model can search the data sources itself only when the tool
/// semantic_search can be offered to it: the model has to be able to call tools, and neither
/// the tools nor this one may be switched off. Otherwise, AI Studio searches them with every
/// message.<br/><br/>
/// Chats and settings saved before this choice existed get semantic search, since it is the
/// new default.
/// </remarks>
public DataSourceRetrievalMode RetrievalMode { get; set; } = DataSourceRetrievalMode.SEMANTIC_SEARCH;
/// <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,
2026-09-27 14:26:52 +00:00
RetrievalMode = this.RetrievalMode,
PreselectedDataSourceIds = [..this.PreselectedDataSourceIds],
};
}