Skip to content

feat: add chunk level page source#2015

Merged
lucaseduoli merged 7 commits into
mainfrom
feat/chunk_level_source
Jul 3, 2026
Merged

feat: add chunk level page source#2015
lucaseduoli merged 7 commits into
mainfrom
feat/chunk_level_source

Conversation

@lucaseduoli

@lucaseduoli lucaseduoli commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces several improvements related to exporting Docling documents and enhances the display of source information in both the frontend and SDKs. The main changes include more granular export capabilities for Docling documents, improved metadata handling, and clearer display of page numbers in source references.

Docling export improvements:

  • The ExportDoclingDocumentComponent in export_docling_document.py now supports per-page Markdown export, outputting one data chunk per page with accurate page numbers in metadata. This allows downstream consumers to reference specific pages, improving chat citation UI and other features. Helper methods for metadata extraction and per-page export were added.
  • Metadata extraction was refactored into a dedicated _base_metadata method, ensuring consistent and reusable metadata handling for all export formats.

Frontend and SDK display enhancements:

  • The chat frontend (result.tsx) now displays both the filename and page number (if present) for each source, making it easier for users to identify where a result came from. The display logic was unified and simplified.
  • The Python SDK (README.md) and TypeScript SDK (README.md) were updated to include the page number when printing source references, improving clarity for developers using these SDKs. [1] [2]

Flow configuration:

  • The ingestion_flow.json was updated to reflect the new export logic and was locked to prevent further edits, ensuring stability. [1] [2]

Summary by CodeRabbit

  • New Features
    • Added document export support in multiple formats (Markdown, HTML, plaintext, DocTags), with configurable document selection and image embedding options.
    • For Markdown, enabled page-level chunking with page metadata and improved placeholders for page breaks.
  • Bug Fixes
    • Ensured Markdown export falls back to whole-document output when page-level export produces no content.
    • Updated chat tool-result headers to avoid showing unknown filenames and to display page numbers only when valid.
  • Documentation
    • Updated Python and TypeScript streaming examples to optionally include page numbers in displayed source info.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1363b8d3-8f87-4311-8093-7bb5399011f7

📥 Commits

Reviewing files that changed from the base of the PR and between 4320d59 and 6d547ff.

📒 Files selected for processing (2)
  • flows/components/export_docling_document.py
  • flows/ingestion_flow.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • flows/components/export_docling_document.py
  • flows/ingestion_flow.json

Walkthrough

Adds a new DoclingDocument export component with per-page Markdown fallback, syncs the same logic into the ingestion flow JSON and locks that flow, updates frontend function-call result rendering for page display, and adjusts SDK README streaming examples to print optional page info.

Changes

Docling Document Export Component

Layer / File(s) Summary
Component definition, inputs/outputs, and UI wiring
flows/components/export_docling_document.py
Adds the ExportDoclingDocumentComponent class with display metadata, inputs, outputs, and update_build_config for dynamic field visibility based on export_format.
Metadata and export implementation
flows/components/export_docling_document.py
Adds _base_metadata, _export_per_page_markdown, export_document, and as_dataframe, implementing per-page Markdown export with whole-document fallback and format-specific routing for HTML, Plaintext, and DocTags.
Ingestion flow JSON sync and lock
flows/ingestion_flow.json
Mirrors the per-page Markdown export logic in the embedded flow component code and sets the flow's locked property to true.

Page Number Display Updates

Layer / File(s) Summary
Function call result header rendering
frontend/app/chat/_components/function-calls/result.tsx
Consolidates filename, page, and score rendering into one header block, derives displayFilename, suppresses the header when no filename, and shows page only when numeric and greater than 0.
SDK streaming example page info
sdks/python/README.md, sdks/typescript/README.md
Updates streaming examples to compute and print an optional page-number suffix alongside the source filename.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ExportDoclingDocumentComponent
  participant DoclingDocument

  ExportDoclingDocumentComponent->>DoclingDocument: export_to_markdown() per page
  DoclingDocument-->>ExportDoclingDocumentComponent: page content or empty
  alt no page content
    ExportDoclingDocumentComponent->>DoclingDocument: export_to_markdown(page_break_placeholder)
  end
  ExportDoclingDocumentComponent->>DoclingDocument: export_to_html()/export_to_text()/export_to_doctags()
Loading

Suggested reviewers: ricofurtado, Wallgau

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding chunk-level page source support and page metadata for exports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/chunk_level_source

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the enhancement 🔵 New feature or request label Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 6d547ff.

@lucaseduoli lucaseduoli requested a review from Wallgau July 3, 2026 15:58
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Jul 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@flows/components/export_docling_document.py`:
- Around line 176-178: The exception handling in ExportDoclingDocumentComponent
is using a copy-pasted message from SplitTextComponent, so update the error text
in the relevant try/except block to describe document export instead of
splitting text. Use the existing exception variable in the export path and make
the message clearly identify export failures so users can debug the correct
component.
- Line 54: The UI info text in the export document flow contains a typo
(“betweek”); update the placeholder description in the relevant string near
export_docling_document to say “between” instead, keeping the rest of the
message unchanged.
- Around line 102-138: The per-page export fallback in _export_per_page_markdown
only catches TypeError, so other Docling export failures still abort
export_document() instead of falling back cleanly. Update the page export block
around doc.export_to_markdown to treat any page-level export exception as a
recoverable failure by returning [] and letting the caller use whole-document
export for that document, while keeping the existing page_no/from_page/to_page
compatibility handling.

In `@frontend/app/chat/_components/function-calls/result.tsx`:
- Around line 55-59: The score display in the result rendering is using a truthy
check, so a valid zero value is hidden. Update the conditional in the result
component (the block that renders item.score and its toFixed output) to
explicitly allow 0 while still skipping only null/undefined values. Keep the
existing label and formatting logic, but change the guard so a score of 0 still
renders.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aaab52c1-bfbc-434a-9f7a-2190ab155fa7

📥 Commits

Reviewing files that changed from the base of the PR and between 6d75923 and 9e371d0.

📒 Files selected for processing (5)
  • flows/components/export_docling_document.py
  • flows/ingestion_flow.json
  • frontend/app/chat/_components/function-calls/result.tsx
  • sdks/python/README.md
  • sdks/typescript/README.md

Comment thread flows/components/export_docling_document.py Outdated
Comment thread flows/components/export_docling_document.py
Comment thread flows/components/export_docling_document.py
Comment thread frontend/app/chat/_components/function-calls/result.tsx
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Jul 3, 2026
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Jul 3, 2026
@lucaseduoli lucaseduoli requested a review from ricofurtado July 3, 2026 17:08

@ricofurtado ricofurtado left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Need to fix the coderabbit flag.

@github-actions github-actions Bot added the lgtm label Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • flows/components/export_docling_document.py

Commit: 9b8adfa66f398a5e7581abf35ce4157fce8d3ad8

The changes have been pushed to the feat/chunk_level_source branch.

Time taken: 2m 59s

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <[email protected]>
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Jul 3, 2026
@github-actions github-actions Bot added enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels Jul 3, 2026
@lucaseduoli lucaseduoli merged commit ea47033 into main Jul 3, 2026
24 checks passed
@github-actions github-actions Bot deleted the feat/chunk_level_source branch July 3, 2026 19:21
lucaseduoli added a commit that referenced this pull request Jul 7, 2026
…model option (#2031)

* fix: remediate image_scan CVEs in backend, frontend, and langflow images (#2000)

* fix light color text catergory chips in light mode (#2013)

Co-authored-by: Olfa Maslah <[email protected]>

* fix: upgraded version of docling (#1995)

* changed version of docling

* fix logs not being the correct ones

* go back to sequential building to save space

* add cache to builds

* remove single use results from docling manager

* revert single use results

* change the ray tenant id header

* added env

* changed cache to hit if no changes were made

* fix hash for cache

* style: ruff autofix (auto)

* fixed coderabbit

* style: ruff autofix (auto)

* added comment on docling manager

* style: ruff autofix (auto)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* feat: add chunk level page source (#2015)

* Changed export docling document to append page number

* update result on frontend to append page number

* document how to get page number in readmes

* Update flows/components/export_docling_document.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update flows/components/export_docling_document.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: apply CodeRabbit auto-fixes

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <[email protected]>

* update component code

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <[email protected]>

* fix: error in skip duplicates functionality for folder ingest for connectors (backport of #1941) (#2018)

* fix: error in skip duplicates functionality for folder ingest for connectors 75616(#1842) (#1941)

* fix: enhance duplicate handling and indexing for connector file uploads

* style: ruff autofix (auto)

* fix: improve duplicate handling in connector sync functionality

* chore: trigger CodeRabbit

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
(cherry picked from commit effaf02)

* style: ruff autofix (auto)

* fix: remove duplicate test definitions from main merge

The automated merge-from-main on this branch concatenated two tests
(test_connector_processor_indexes_cleaned_filename,
test_langflow_connector_processor_uses_cleaned_filename) that already
existed under both names, tripping ruff F811. Keep one copy of each,
preferring the version wired with connector_id_exists=True to match
current check_document_exists behavior.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* fix: Ingestion of buckets not working right after connection is tested - CPD #75506 (#1942) (#2019)

* fix: update bucket ingestion messages for clarity and consistency

* fix: guard bucket pre-selection against connection ID mismatch

The defaults query returns the first S3/COS connection regardless of active
status. Only pre-select saved bucket_names when the defaults connection_id
matches the current connector.connectionId to avoid seeding the wrong
buckets if a stale connection exists alongside the active one.



* fix: prevent defaults from overwriting user bucket selections

Two issues in the initial-selection effect:
1. hasAppliedInitial was only set when valid buckets were found, leaving the
   effect live across bucket refreshes and allowing stale defaults to overwrite
   selections made after a refetch.
2. No guard against the async race where buckets loads before initialSelectedBuckets:
   user clicks buckets, defaults arrive later and silently overwrite them.

Fix: mark hasAppliedInitial unconditionally on first evaluation, and only apply
defaults when selectedBuckets is still empty (user hasn't acted yet).



---------


(cherry picked from commit f3823b8)

Co-authored-by: Claude Sonnet 4.6 <[email protected]>

* fix: handle orphan files and return appropriate responses when syncing connectors (#1785) (#2016)

* feat: handle orphan files and return appropriate responses when syncing connectors

* feat: refactor GoogleDriveOAuth to separate required scopes and add handling for missing optional group scopes in tests

* style: ruff autofix (auto)

* feat: add handling for skipped files and warnings in task processing and UI components

---------


(cherry picked from commit aca865a)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* fix: enhance error handling for document processing and add OCR requirement check for image files (#1859) (#2017)

* fix: enhance error handling for document processing and add OCR requirement check for image files

* style: ruff autofix (auto)

* remove clickhouse connect from langflow image (#1801)

* chore: fix ci (#1889)

* Update processors.py

* test fix

* fix ci

---------




(cherry picked from commit a286581)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Lucas Oliveira <[email protected]>
Co-authored-by: Edwin Jose <[email protected]>

* fix: bump golang.org/x/net to v0.55.0 to remediate CVE-2026-25680 and CVE-2026-39821 (#2014)

* feat: add new design for messages and add inline references (#2020)

* update opensearch multimodal and flows to support parser, chunk size and chunk overlap

* update backend to support citations and chunk metadata

* update frontend to support citations and metadata, implement new design for assistant message

* changed the prompt for the agent

* changed the prompt for the agent

* remove hallucinated chunk references

* adjust design of citations and where popover appears

* adjusted design for message, popover and cards

* fix React Doctor picks

* fix: apply CodeRabbit auto-fixes

Fixed 5 file(s) based on 4 unresolved review comments.

Co-authored-by: CodeRabbit <[email protected]>

* style: apply biome auto-fixes [skip ci]

* updated colors in ibm mode

* fixed react doctor picks

* added correct type and validation for function calls

* remove style for message when on onboarding

* fix message not being w full

* remove search query in end of the message

* change popup to use shadcn popover

* fix coderabbit's suggestion

* increase prompt limit

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* apply new settings on retry (#2010)

* fix: preserve HTTPException status in update_docling_preset (#1586) (#2004)

* fix: report actual synced connection count in connector_sync (#1547) (#2006)

* fix: restore LLM model values in reapply_all_settings fallback (#1587) (#2008)

* fix: prevent partial matches for exact token searches (#2003)

* fix: prevent partial matches for exact token searches (#1937)

* style: ruff autofix (auto)

* chore: remove unused json import

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* fix: target agent component when updating chat flow system prompt (#2001)

* fix: target langflow agent component for system prompt update instead of provider LLM component

Signed-off-by: vchen7629 <[email protected]>

* fix: removed unused llm_provider arg from _update_langflow_system_prompt

Signed-off-by: vchen7629 <[email protected]>

* test: add unit tests for update_chat_flow_system_prompt

Signed-off-by: vchen7629 <[email protected]>

* style: ruff autofix (auto)

* fix(test): resolve flow path relative to repo root in test_langflow_agent_system_prompt

Signed-off-by: vchen7629 <[email protected]>

* style: ruff autofix (auto)

---------

Signed-off-by: vchen7629 <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* fix: replaced hardcoded docker.io prefix with a env variable prefix for private repo compatibility (#2002)

Signed-off-by: vchen7629 <[email protected]>

* fix: resolve Pydantic delta serialization warnings in agent streaming (#2005)

* fix: updated agent model dump to exclude delta field

Signed-off-by: vchen7629 <[email protected]>

* test: added regression unit test to verify response field + no warnings

* style: ruff autofix (auto)

* test: added additional unit test to verify that model_dump without exclusion raises the warning

Signed-off-by: vchen7629 <[email protected]>

* style: ruff autofix (auto)

* test: tighten delta warning assertion to match specific Pydantic error

Signed-off-by: vchen7629 <[email protected]>

* style: ruff autofix (auto)

---------

Signed-off-by: vchen7629 <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* fix: prevent exception details from leaking in API error responses (#2007)

* fix: removed str(e) in exceptions to prevent internals from leaking

Signed-off-by: vchen7629 <[email protected]>

* style: ruff autofix (auto)

* fix: added missing status_code

Signed-off-by: vchen7629 <[email protected]>

* style: ruff autofix (auto)

---------

Signed-off-by: vchen7629 <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* Changed docling options to include local support and be shown in the Langflow tab

* style: ruff autofix (auto)

* enable ollama and delete unused file

* fix next lint

---------

Signed-off-by: vchen7629 <[email protected]>
Co-authored-by: Gautham N Pai <[email protected]>
Co-authored-by: Wallgau <[email protected]>
Co-authored-by: Olfa Maslah <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <[email protected]>
Co-authored-by: Rico Furtado <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Edwin Jose <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mike Fortman <[email protected]>
Co-authored-by: hunterxtang <[email protected]>
Co-authored-by: NishadA05 <[email protected]>
Co-authored-by: Zephyrus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement 🔵 New feature or request frontend 🟨 Issues related to the UI/UX lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants