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

+29 -1
View File
@@ -1,3 +1,5 @@
using AIStudio.Settings;
using AIStudio.Settings.DataModel;
using AIStudio.Tools.RAG;
namespace AIStudio.Tests.Tools;
@@ -138,10 +140,36 @@ public sealed class RetrievalPagingTests
Assert.That(secondPage.Matches, Is.EqualTo(new[] { "c", "d" }));
Assert.That(secondPage.HasMore, Is.True);
Assert.That(thirdPage.Matches, Is.EqualTo(new[] { "e" }));
Assert.That(thirdPage.HasMore, Is.False, "An ERI server which found fewer than asked for ends the paging.");
Assert.That(thirdPage.HasMore, Is.False, "A channel which found fewer than asked for ends the paging.");
});
}
[TestCase((ushort)1)]
[TestCase((ushort)10)]
[TestCase((ushort)500)]
public void AnERIDataSourceHasASinglePage(ushort maxMatches)
{
IDataSource source = new DataSourceERI_V1 { Id = "33333333-3333-3333-3333-333333333333", Name = "Intranet", MaxMatches = maxMatches };
Assert.That(source.GetLastPage(), Is.EqualTo(1), "ERI v1 knows no offset, and a server which allows only the configured number of matches would refuse every further page.");
}
[Test]
public void ALocalDataSourcePagesAsItsPageSizeAllows()
{
IDataSource source = new DataSourceLocalDirectory { Id = "11111111-1111-1111-1111-111111111111", Name = "Handbook", MaxMatches = 10 };
Assert.That(source.GetLastPage(), Is.EqualTo(RetrievalPaging.GetLastPage(10)));
}
[Test]
public void AnERIDataSourceRefusesAFurtherPage()
{
var source = new DataSourceERI_V1 { Id = "33333333-3333-3333-3333-333333333333", Name = "Intranet", MaxMatches = 10 };
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await source.RetrieveDataAsync("query", 2, new AIStudio.Chat.ChatThread()));
}
private static (IReadOnlyList<string> Matches, bool HasMore) Merge(string[] first, string[] second, int page)
{
// A channel never returns more than it is asked for: