Sort citations by filename and page number

Updated the return statement in the `VectorSearchService` class to return citations sorted by `FileName` and `PageNumber`, improving the organization of the output.
This commit is contained in:
Marco Minerva
2025-07-03 09:31:06 +02:00
parent 0a2aaa9e6e
commit b849c78594
@@ -187,7 +187,7 @@ public partial class VectorSearchService(IServiceProvider serviceProvider, Appli
// Remove all content between 【 and 】.
var cleanText = RemoveCitationsRegEx.Replace(text, string.Empty).TrimEnd();
return (cleanText, citations);
return (cleanText, citations.OrderBy(c => c.FileName).ThenBy(c => c.PageNumber));
}
[GeneratedRegex(@"<citation\s+document-id=(?:""|'|)(?<documentId>[^""']*)(?:""|'|)\s+chunk-id=(?:""|'|)(?<chunkId>[^""']*)(?:""|'|)\s+filename=(?:""|'|)(?<filename>[^""']*)(?:""|'|)\s+page-number=(?:""|'|)(?<pageNumber>[^""']*)(?:""|'|)\s+index-on-page=(?:""|'|)(?<indexOnPage>[^""']*)(?:""|'|)>\s*(?<quote>.*?)\s*</citation>", RegexOptions.Singleline)]