Fixed Semantic Search with external data sources (ERI servers) (#1090)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-10-20 16:24:55 +02:00
1 parent 0f5b041729
commit f6e48e95f3
30 files changed
+1370 -141

No files matched your search

@@ -1,4 +1,5 @@
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
namespace AIStudio.Tools;
@@ -17,9 +18,33 @@ namespace AIStudio.Tools;
/// The same holds for the ones waiting for a repair, and they are a list of their own because the
/// two reasons call for different words: one passes by itself, the other one waits for the user.
/// A data source is in at most one of the two lists.
///
/// The ERI data sources whose server could not be reached are a list of their own, too: they are
/// neither allowed nor refused, because their server's requirements are unknown. They must never be
/// searched, but Semantic Search and the classic RAG process both name them to the model, so that it
/// can tell the user what is missing instead of answering as though there were nothing.
/// </remarks>
/// <param name="AllowedDataSources">The allowed data sources.</param>
/// <param name="SelectedDataSources">The selected data sources, which are a subset of the allowed data sources.</param>
/// <param name="DataSourcesAwaitingReindex">The data sources which passed every check but cannot be searched until their index has been rebuilt.</param>
/// <param name="DataSourcesNeedingRepair">The data sources which passed every check but whose index cannot be read anymore, so that only the user can get them back.</param>
public readonly record struct AllowedSelectedDataSources(IReadOnlyList<IDataSource> AllowedDataSources, IReadOnlyList<IDataSource> SelectedDataSources, IReadOnlyList<IDataSource> DataSourcesAwaitingReindex, IReadOnlyList<IDataSource> DataSourcesNeedingRepair);
/// <param name="UnreachableDataSources">The ERI data sources whose server could not be reached or signed in to right now, and whose configured security policy allows them for this provider. Selected or not.</param>
public readonly record struct AllowedSelectedDataSources(IReadOnlyList<IDataSource> AllowedDataSources, IReadOnlyList<IDataSource> SelectedDataSources, IReadOnlyList<IDataSource> DataSourcesAwaitingReindex, IReadOnlyList<IDataSource> DataSourcesNeedingRepair, IReadOnlyList<IDataSource> UnreachableDataSources)
{
/// <summary>
/// The data sources whose server could not be reached, which the model learns about in this chat.
/// </summary>
/// <remarks>
/// Only those the chat would have searched count: with the automatic selection all of them, since
/// any data source may be picked, otherwise only those the user selected. A data source configured
/// to return no matches is left out, because it would add nothing even when its server answers.
/// Semantic Search and the classic RAG process both ask here, so that the model hears the same in
/// either way.
/// </remarks>
/// <param name="options">The data source options of the chat.</param>
/// <returns>The unreachable data sources of the chat, in the order they were checked.</returns>
public IReadOnlyList<IDataSource> GetUnreachableOfTheChat(DataSourceOptions options) => this.UnreachableDataSources
.Where(dataSource => dataSource.MaxMatches > 0)
.Where(dataSource => options.AutomaticDataSourceSelection || options.PreselectedDataSourceIds.Contains(dataSource.Id))
.ToList();
}