mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 10:57:59 +00:00
Fixed page numbers being guessed from the text instead of read from the metadata
This commit is contained in:
9 files changed
+285
-49
No files matched your search
@@ -10,6 +10,7 @@ public sealed class DocumentManager
|
||||
{
|
||||
private StringBuilder? currentPageContent;
|
||||
private int? currentPageTokenCount;
|
||||
private int? currentPageNumber;
|
||||
|
||||
public ContentStreamPendingContent? AddPage(ContentStreamDocumentMetadata metadata, string? content, int? tokenCount, bool extractImages)
|
||||
{
|
||||
@@ -36,9 +37,12 @@ public sealed class DocumentManager
|
||||
|
||||
//
|
||||
// The count waits here together with the page it belongs to. Handing it out along with
|
||||
// the page we just completed would size that page by the text of this one.
|
||||
// the page we just completed would size that page by the text of this one. The page
|
||||
// number waits for the same reason: it belongs to the page being buffered, not to the
|
||||
// one leaving here.
|
||||
//
|
||||
this.currentPageTokenCount = tokenCount;
|
||||
this.currentPageNumber = pageNumber;
|
||||
return completedPage;
|
||||
}
|
||||
|
||||
@@ -72,8 +76,10 @@ public sealed class DocumentManager
|
||||
|
||||
var result = this.currentPageContent.ToString();
|
||||
var tokenCount = this.currentPageTokenCount;
|
||||
var pageNumber = this.currentPageNumber;
|
||||
this.currentPageContent = null;
|
||||
this.currentPageTokenCount = null;
|
||||
return string.IsNullOrWhiteSpace(result) ? null : new ContentStreamPendingContent(result, tokenCount);
|
||||
this.currentPageNumber = null;
|
||||
return string.IsNullOrWhiteSpace(result) ? null : new ContentStreamPendingContent(result, tokenCount, pageNumber);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user