Repository navigation
Feat: optimize title chunk - #14325
Conversation
📝 WalkthroughWalkthroughThis pull request introduces a new configurable Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rag/flow/chunker/title_chunker/common.py (1)
243-267:⚠️ Potential issue | 🟡 MinorKeep the simple-input branch from falling through.
Line 244 builds plain
{text}chunks formarkdown/text/html, but Line 250 immediately overwrites them with the PDF-style chunk shape. Use anelseso simple upstream formats preserve the intended output schema before the shared root-heading post-processing.Proposed fix
if self.from_upstream.output_format in ["markdown", "text", "html"]: chunks = [ {"text": "".join(record["text"] + "\n" for record in records)} for records in record_groups if records ] - - chunks = [ - ( - { - "text": RAGFlowPdfParser.remove_tag("".join(record["text"] + "\n" for record in records)), - "doc_type_kwd": "text", - PDF_POSITIONS_KEY: merge_pdf_positions(records), - } - if records[0]["doc_type_kwd"] == "text" - else { - "text": records[0]["text"], - "doc_type_kwd": records[0]["doc_type_kwd"], - "img_id": records[0]["img_id"], - PDF_POSITIONS_KEY: records[0][PDF_POSITIONS_KEY], - } - ) - for records in record_groups - if records - ] + else: + chunks = [ + ( + { + "text": RAGFlowPdfParser.remove_tag("".join(record["text"] + "\n" for record in records)), + "doc_type_kwd": "text", + PDF_POSITIONS_KEY: merge_pdf_positions(records), + } + if records[0]["doc_type_kwd"] == "text" + else { + "text": records[0]["text"], + "doc_type_kwd": records[0]["doc_type_kwd"], + "img_id": records[0]["img_id"], + PDF_POSITIONS_KEY: records[0][PDF_POSITIONS_KEY], + } + ) + for records in record_groups + if records + ]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rag/flow/chunker/title_chunker/common.py` around lines 243 - 267, The first comprehension that builds simple "{text}" chunks for self.from_upstream.output_format in ["markdown","text","html"] is being overwritten by the subsequent PDF-style comprehension; change the second comprehension into an else branch (or use elif) so that when self.from_upstream.output_format is one of the simple formats you keep the initial chunks and only run the PDF-style construction (using RAGFlowPdfParser.remove_tag, merge_pdf_positions, PDF_POSITIONS_KEY, records[0]["doc_type_kwd"], img_id) for the other formats/paths; in short, ensure the PDF-style list comprehension is executed only when the simple-input branch did not run.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@agent/templates/ingestion_pipeline_Resume.json`:
- Line 552: The template currently persists the editor selection by setting the
Title Chunker node's "selected": true; remove this property or set it to false
on the Title Chunker node object in the ingestion pipeline template so new
pipelines don't open with a preselected node (look for the node entry containing
"Title Chunker" and the "selected" key and delete or change it to false).
---
Outside diff comments:
In `@rag/flow/chunker/title_chunker/common.py`:
- Around line 243-267: The first comprehension that builds simple "{text}"
chunks for self.from_upstream.output_format in ["markdown","text","html"] is
being overwritten by the subsequent PDF-style comprehension; change the second
comprehension into an else branch (or use elif) so that when
self.from_upstream.output_format is one of the simple formats you keep the
initial chunks and only run the PDF-style construction (using
RAGFlowPdfParser.remove_tag, merge_pdf_positions, PDF_POSITIONS_KEY,
records[0]["doc_type_kwd"], img_id) for the other formats/paths; in short,
ensure the PDF-style list comprehension is executed only when the simple-input
branch did not run.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 44c3b7ad-d982-41d2-a51f-234fc09c5032
📒 Files selected for processing (7)
agent/templates/ingestion_pipeline_Resume.jsonrag/flow/chunker/title_chunker/common.pyweb/src/locales/en.tsweb/src/pages/agent/constant/pipeline.tsxweb/src/pages/agent/form/title-chunker-form/hook.tsweb/src/pages/agent/form/title-chunker-form/index.tsxweb/src/pages/agent/utils.ts
| "width": 200 | ||
| }, | ||
| "position": { | ||
| "x": 572.7908769627791, | ||
| "y": 141.55515313482098 | ||
| }, | ||
| "selected": false, | ||
| "selected": true, |
There was a problem hiding this comment.
Do not persist editor selection in the template.
Line 552 stores the Title Chunker node as selected, so new pipelines created from this template may open with an unintended preselected/highlighted node.
Proposed fix
- "selected": true,
+ "selected": false,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "selected": true, | |
| "selected": false, |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@agent/templates/ingestion_pipeline_Resume.json` at line 552, The template
currently persists the editor selection by setting the Title Chunker node's
"selected": true; remove this property or set it to false on the Title Chunker
node object in the ingestion pipeline template so new pipelines don't open with
a preselected node (look for the node entry containing "Title Chunker" and the
"selected" key and delete or change it to false).
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@agent/templates/ingestion_pipeline_resume.json`:
- Line 552: The template JSON currently leaves a transient selection flag set
(e.g., "selected": true on the résumé pipeline template entry such as the
TitleChunker:FlatMiceFix template), causing every new pipeline to start with
that step preselected; update the template by resetting that transient state to
neutral — either remove the "selected" property or set it to false on the
TitleChunker:FlatMiceFix entry (and any other pipeline-step objects that include
"selected": true) so new instances do not inherit a preselected step before user
choice.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7d493793-9b35-4923-ba14-ae23449f51f7
📒 Files selected for processing (7)
agent/templates/ingestion_pipeline_book.jsonagent/templates/ingestion_pipeline_general.jsonagent/templates/ingestion_pipeline_laws.jsonagent/templates/ingestion_pipeline_manual.jsonagent/templates/ingestion_pipeline_one.jsonagent/templates/ingestion_pipeline_paper.jsonagent/templates/ingestion_pipeline_resume.json
| "y": 141.55515313482098 | ||
| }, | ||
| "selected": false, | ||
| "selected": true, |
There was a problem hiding this comment.
Reset transient selection state before committing the template.
Leaving selected: true makes every new résumé pipeline instantiate with TitleChunker:FlatMiceFix preselected. Template state should usually be neutral.
Proposed fix
- "selected": true,
+ "selected": false,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@agent/templates/ingestion_pipeline_resume.json` at line 552, The template
JSON currently leaves a transient selection flag set (e.g., "selected": true on
the résumé pipeline template entry such as the TitleChunker:FlatMiceFix
template), causing every new pipeline to start with that step preselected;
update the template by resetting that transient state to neutral — either remove
the "selected" property or set it to false on the TitleChunker:FlatMiceFix entry
(and any other pipeline-step objects that include "selected": true) so new
instances do not inherit a preselected step before user choice.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14325 +/- ##
==========================================
+ Coverage 95.10% 95.97% +0.86%
==========================================
Files 10 10
Lines 695 695
Branches 111 111
==========================================
+ Hits 661 667 +6
+ Misses 17 11 -6
Partials 17 17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
同步 infiniflow/ragflow main(v0.25.0 tag + 后续 commits)。 上游主要变更: - REST API 大重构:user/tenant/stats/plugin/chunk/document/file2document/ connector/langfuse/mcp/system/chat/search 全部迁到 api/apps/restful_apis/ - feat: Agent API (infiniflow#14157) / deepseek v4 (infiniflow#14346) / docling native chunking (infiniflow#14218) / Astraflow provider (infiniflow#14270) / title chunk 优化 (infiniflow#14325) - refactor: doc metadata update / agent webhook → REST / 移除 legacy MCP web API - Go 侧:retrieval_test in GO / stream think chat / zhipu thinking / minimax provider / balance command - 若干 fix:think tags normalization / upload truncation / audio-video pipeline - 7 个 ingestion_pipeline templates 重命名(Book→book 等) 冲突解决(2 处): - CLAUDE.md:保留 fork 专属整块(Fork 信息/端口/macOS 本地/活跃文档/首次运行 记录/Task Executor),追加上游新增的 Working Style 8 条作为独立段 - web/src/pages/dataset/testing/testing-result.tsx:保留 HEAD 版本 (P1.7-C4 设计对齐版已内含 upstream 要加的 RAGFlowPagination + isRuned 空态 文案,upstream 版被 HEAD 超集) 验证: - `pytest test/agent_v2/` → 301 passed / 8 skipped(RAGFLOW_TEST_DB gate) - 其它冲突文件 auto-merge 成功:dialog_service.py / docker/.env / pyproject.toml / uv.lock / locales/en.ts / dataset-table.tsx / testing-form.tsx Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
What problem does this PR solve?
Feat: optimize title chunk
Type of change