mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-10 15:13:49 +00:00
Added the page of a passage to what the AI is told about it
This commit is contained in:
4 files changed
+135
-13
No files matched your search
@@ -395,6 +395,7 @@ public sealed class DataSourceLocalRetrievalService(
|
||||
SurroundingContent = [],
|
||||
ReferenceTitle = BuildReferenceTitle(hit),
|
||||
ReferenceLink = referenceLink,
|
||||
PageNumber = hit.PageNumber is > 0 ? hit.PageNumber : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -413,11 +414,19 @@ public sealed class DataSourceLocalRetrievalService(
|
||||
return $"{sourceName} ({location})";
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// A known page is written as the fragment `#page=N`, which is what the PDF open parameters
|
||||
/// call for: a program which understands them opens the document where the passage is. Without
|
||||
/// a page there is nothing to send a program to, and the chunk stays in the link so the
|
||||
/// reference still points at something.
|
||||
/// </remarks>
|
||||
private static string BuildReferenceLink(string path, LocalRetrievalHit hit)
|
||||
{
|
||||
var link = NormalizeLocalReferencePath(path);
|
||||
var separator = link.Contains('#', StringComparison.Ordinal) ? "&" : "#";
|
||||
return $"{link}{separator}chunk={hit.ChunkIndex}";
|
||||
return hit.PageNumber is > 0
|
||||
? $"{link}{separator}page={hit.PageNumber}"
|
||||
: $"{link}{separator}chunk={hit.ChunkIndex}";
|
||||
}
|
||||
|
||||
private static string NormalizeLocalReferencePath(string path)
|
||||
|
||||
Reference in new issue
Block a user