Skip to content

Feat: add gbrain compile template for session/memory data - #16613

Merged
yingfeng merged 3 commits into
infiniflow:mainfrom
yingfeng:gbrain
Jul 3, 2026
Merged

yingfeng merged 3 commits into
infiniflow:mainfrom
yingfeng:gbrain

Conversation

@yingfeng

@yingfeng yingfeng commented Jul 3, 2026

Copy link
Copy Markdown
Member

No description provided.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Jul 3, 2026
@yingfeng yingfeng added the ci Continue Integration label Jul 3, 2026
@yingfeng
yingfeng marked this pull request as draft July 3, 2026 09:34
@yingfeng
yingfeng marked this pull request as ready for review July 3, 2026 09:34
@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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1430ec28-9f83-4ff1-b8fa-59843fc42cdb

📥 Commits

Reviewing files that changed from the base of the PR and between 1f0d7c8 and 721ea9f.

📒 Files selected for processing (3)
  • api/db/init_data/compilation_templates/session_essence.yaml
  • api/db/init_data/compilation_templates/session_graph.yaml
  • rag/svr/task_executor_refactor/chunk_post_processor.py
💤 Files with no reviewable changes (2)
  • api/db/init_data/compilation_templates/session_essence.yaml
  • api/db/init_data/compilation_templates/session_graph.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • rag/svr/task_executor_refactor/chunk_post_processor.py

📝 Walkthrough

Walkthrough

Two new session templates define knowledge-graph extraction and synthesis settings, and the document-structure executor adds a gated post-merge synthesis pass that plans and refines output pages from that config.

Changes

Synthesis templates and executor integration

Layer / File(s) Summary
Knowledge-graph templates
api/db/init_data/compilation_templates/session_essence.yaml, api/db/init_data/compilation_templates/session_graph.yaml
Defines entity and relation extraction for people, organizations, topics, facts, and mention/other relation types, plus synthesis examples and compile_kwd settings.
Executor synthesis phase
rag/svr/task_executor_refactor/chunk_post_processor.py
Adds a cancellation check, per-template flush/progress handling, and a conditional synthesis pass that calls wiki_plan_from_reduction and wiki_refine_from_plan, then rewrites page compile_kwd and logs synthesis errors.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant run_document_structure_compile
  participant TemplateConfig
  participant wiki_plan_from_reduction
  participant wiki_refine_from_plan

  run_document_structure_compile->>TemplateConfig: read synthesis.enabled, example, compile_kwd
  alt synthesis enabled and example present
    run_document_structure_compile->>wiki_plan_from_reduction: build plan
    wiki_plan_from_reduction-->>run_document_structure_compile: plan
    run_document_structure_compile->>wiki_refine_from_plan: refine with example
    wiki_refine_from_plan-->>run_document_structure_compile: refined pages
  end
Loading

Possibly related PRs

Suggested labels: 🌈 python

Poem

A rabbit hopped through facts at dawn,
With graph and essence newly drawn.
Plan, refine, then pages bloom,
From config seeds in cozy room.
Hop hop — synthesis is on! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning No PR summary was provided, so the required Summary section and background context are missing. Add a Summary section that briefly explains the goal, context, and the main changes in this PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and describes the added session/memory compile template, though it omits the synthesis refactor.
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.

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.

@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: 2

🤖 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 `@rag/svr/task_executor_refactor/chunk_post_processor.py`:
- Line 1099: The synthesis path in chunk_post_processor.py only checks
cancellation once before entering the loop, so long-running PLAN/REFINE work can
continue after a task is cancelled. Update the synthesis flow around
wiki_plan_from_reduction and wiki_refine_from_plan to consult
ctx.has_canceled_func(ctx.id) again immediately before starting PLAN and again
before starting REFINE, or pass an equivalent cancel_check through those calls
like merge_compiled_structures does. Keep the check tied to the existing
synthesis_cfg["enabled"] branch so the task stops promptly during synthesis.
- Around line 1098-1126: The synthesis planner currently ignores the configured
plan filters, so the `synthesis.plan.*` knobs are dead config; update
`chunk_post_processor.py` in the synthesis block around
`wiki_plan_from_reduction` to read `plan_cfg` from `synthesis_cfg` and pass the
supported filter values into the planner call. If `wiki_plan_from_reduction`
does not yet accept `entity_type_filter` and `mention_count_threshold`, either
extend that function to take them or remove the unused comment/template
references so the config and code stay aligned.
🪄 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: 866e52a3-b522-45bb-91ce-32bb2682eaf7

📥 Commits

Reviewing files that changed from the base of the PR and between 3cba34d and 1f0d7c8.

📒 Files selected for processing (3)
  • api/db/init_data/compilation_templates/session_essence.yaml
  • api/db/init_data/compilation_templates/session_graph.yaml
  • rag/svr/task_executor_refactor/chunk_post_processor.py

Comment on lines +1098 to +1126
synthesis_cfg = (parser_cfg or {}).get("synthesis") or {}
if synthesis_cfg.get("enabled"):
example = synthesis_cfg.get("example")
compile_kwd = synthesis_cfg.get("compile_kwd", "artifact_page")

if not example:
logging.warning(
"synthesis: template %s has synthesis.enabled but no example; skipping",
template_id,
)
else:
try:
from rag.advanced_rag.knowlege_compile.wiki import (
wiki_plan_from_reduction,
wiki_refine_from_plan,
)

# PLAN — entity_type_filter and mention_count_threshold
# are read from plan_cfg.
progress_cb(
msg=f"Synthesis PLAN for template {template_id} (kind={compile_kwd}) ..."
)
plan = await wiki_plan_from_reduction(
chat_mdl=chat_mdl_by_tid[template_id],
embd_mdl=embedding_model,
tenant_id=ctx.tenant_id,
kb_id=ctx.kb_id,
callback=progress_cb,
)

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.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== chunk_post_processor synthesis block ==\n'
sed -n '1080,1165p' rag/svr/task_executor_refactor/chunk_post_processor.py

printf '\n== wiki_plan_from_reduction / wiki_refine_from_plan definitions ==\n'
rg -n "def (wiki_plan_from_reduction|wiki_refine_from_plan)\(" rag/advanced_rag/knowlege_compile/wiki.py
sed -n '2160,2215p' rag/advanced_rag/knowlege_compile/wiki.py
sed -n '3235,3305p' rag/advanced_rag/knowlege_compile/wiki.py

printf '\n== synthesis template configs ==\n'
rg -n "synthesis:|plan:|mention_count_threshold|top_n|compile_kwd|entity_type_filter" -n . -g '!*node_modules/*' -g '!*dist/*' -g '!*build/*'

Repository: infiniflow/ragflow

Length of output: 50374


Planner filters aren’t wired

plan_cfg is never read here, and wiki_plan_from_reduction(...) doesn’t accept the filter fields referenced in the comment. That makes synthesis.plan.* in session_essence.yaml and session_graph.yaml dead config. Wire those values into the planner, or remove the comment/template knobs if they aren’t supported yet.

🤖 Prompt for 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.

In `@rag/svr/task_executor_refactor/chunk_post_processor.py` around lines 1098 -
1126, The synthesis planner currently ignores the configured plan filters, so
the `synthesis.plan.*` knobs are dead config; update `chunk_post_processor.py`
in the synthesis block around `wiki_plan_from_reduction` to read `plan_cfg` from
`synthesis_cfg` and pass the supported filter values into the planner call. If
`wiki_plan_from_reduction` does not yet accept `entity_type_filter` and
`mention_count_threshold`, either extend that function to take them or remove
the unused comment/template references so the config and code stay aligned.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (9182296) to head (721ea9f).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16613   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yingfeng
yingfeng merged commit 706fa4e into infiniflow:main Jul 3, 2026
3 checks passed
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 3, 2026
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant