AI-Studio/app/MindWork AI Studio/Settings/DataModel/DataSourceOptions.cs
Thorsten Sommer 1eaca9b12f
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Added a semantic search tool (#1005)
2026-09-27 16:26:52 +02:00

79 lines
2.9 KiB
C#

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>
/// 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,
RetrievalMode = this.RetrievalMode,
PreselectedDataSourceIds = [..this.PreselectedDataSourceIds],
};
}