Repository navigation
Feat: Add graph keyword search and fix dataset synthesizing issue. - #17342
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe pull request adds shared structure-graph sampling and keyword retrieval for document and dataset APIs, extends artifact graph query controls, corrects description-field handling across graph pipelines, and changes fallback or eligibility behavior in several components. ChangesStructure graph retrieval
Description field corrections
Independent behavior fixes
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant StructureAPI
participant DatasetService
participant GraphCommon
participant DocumentStore
Client->>StructureAPI: Request structure graph with keywords
StructureAPI->>DatasetService: Forward keywords and graph options
DatasetService->>GraphCommon: Request keyword_subgraph or build_bucket
GraphCommon->>DocumentStore: Search entities and relations
DocumentStore-->>GraphCommon: Return projected graph rows
GraphCommon-->>DatasetService: Return focused or sampled subgraph
DatasetService-->>StructureAPI: Assemble graph buckets
StructureAPI-->>Client: Return structure graph
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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: 4
🧹 Nitpick comments (2)
rag/advanced_rag/harness/tools/navigation.py (1)
540-540: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSimplify the duplicated description lookups.
Both expressions repeat the corrected field access and provide no fallback:
rag/advanced_rag/harness/tools/navigation.py#L540-L540: replace the duplicated lookup withpayload.get("description").rag/advanced_rag/knowlege_compile/runner.py#L170-L170: replace the duplicated lookup withentity.get("description").As per coding guidelines, prefer deletion of duplicate code and compatibility-only surfaces.
🤖 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/advanced_rag/harness/tools/navigation.py` at line 540, Remove the duplicated description lookups: in rag/advanced_rag/harness/tools/navigation.py at line 540, use a single payload.get("description") access; apply the corresponding change in rag/advanced_rag/knowlege_compile/runner.py at line 170 using entity.get("description").Source: Coding guidelines
rag/advanced_rag/knowlege_compile/structure.py (1)
448-448: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant duplicate lookup on Line 448.
payload.get("description") or payload.get("description")evaluates the same key twice. This is a leftover from thediscription→descriptionrename; confirm no second fallback field was intended, then collapse to a single term.♻️ Proposed cleanup
- description = payload.get("description") or payload.get("description") or payload.get("definition_excerpt") or "" + description = payload.get("description") or payload.get("definition_excerpt") or ""🤖 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/advanced_rag/knowlege_compile/structure.py` at line 448, Update the description fallback assignment in the payload-processing logic to look up the "description" key only once, then preserve the existing fallback to "definition_excerpt" and the empty-string default; confirm no alternate field is required before removing the duplicate lookup.
🤖 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 `@agent/component/llm.py`:
- Around line 91-98: Update the model-resolution flow that initializes
self.chat_mdl so failures use the component’s established error/default-output
path and return immediately instead of leaving chat_mdl as None. Ensure
_prepare_prompt_variables() cannot proceed to access chat_mdl.max_length or
bundle methods after resolution failure. Narrow the exception handling to only
expected model/configuration errors, allowing programming errors to propagate.
In `@api/apps/restful_apis/dataset_api.py`:
- Around line 667-673: Update the top_n_arg assignment in the request parameter
parsing to remove the fallback value 6, preserving only the top_n and topN
lookups so omitted input remains None. Keep the existing top_n conversion and
guard unchanged, allowing dataset_api_service.get_wiki_graph to apply its
documented default budget of 128.
In `@rag/svr/task_executor_refactor/dataset_structure_merger.py`:
- Around line 166-167: Remove the stale commented-out config assignment and
trailing commented expression beside dataset_merge in the dataset merge
eligibility logic, leaving only the active dataset_merge behavior.
- Around line 166-167: Update the structure-merge eligibility in
run_structure_merge() to read the persisted template config and set
dataset_merge from config["dataset_merge"], defaulting to false when config is
missing, non-dict, or the key is absent. Ensure templates without an enabled
dataset_merge flag are not treated as dataset-wide artifact graphs.
---
Nitpick comments:
In `@rag/advanced_rag/harness/tools/navigation.py`:
- Line 540: Remove the duplicated description lookups: in
rag/advanced_rag/harness/tools/navigation.py at line 540, use a single
payload.get("description") access; apply the corresponding change in
rag/advanced_rag/knowlege_compile/runner.py at line 170 using
entity.get("description").
In `@rag/advanced_rag/knowlege_compile/structure.py`:
- Line 448: Update the description fallback assignment in the payload-processing
logic to look up the "description" key only once, then preserve the existing
fallback to "definition_excerpt" and the empty-string default; confirm no
alternate field is required before removing the duplicate lookup.
🪄 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 Plus
Run ID: 15e9c44f-8e42-4b8f-a447-57447fe0c2fb
📒 Files selected for processing (12)
agent/component/llm.pyapi/apps/restful_apis/chunk_api.pyapi/apps/restful_apis/dataset_api.pyapi/apps/services/dataset_api_service.pyapi/apps/services/structure_graph_common.pyconf/infinity_mapping.jsonrag/advanced_rag/harness/tools/navigation.pyrag/advanced_rag/knowlege_compile/runner.pyrag/advanced_rag/knowlege_compile/structure.pyrag/advanced_rag/knowlege_compile/wiki.pyrag/flow/compiler/compiler.pyrag/svr/task_executor_refactor/dataset_structure_merger.py
💤 Files with no reviewable changes (1)
- rag/flow/compiler/compiler.py
| try: | ||
| model_types = resolve_model_type(self._canvas.get_tenant_id(), self._param.llm_id) | ||
| model_type = "chat" if "chat" in model_types else model_types[0] | ||
| chat_model_config = resolve_model_config(self._canvas.get_tenant_id(), model_type, self._param.llm_id) | ||
| self.chat_mdl = LLMBundle(self._canvas.get_tenant_id(), chat_model_config, max_retries=self._param.max_retries, retry_interval=self._param.delay_after_error) | ||
| except Exception as e: | ||
| logging.warning(f"Fail to load LLM configuration for component. {e}") | ||
| self.chat_mdl = None |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== candidate files =="
git ls-files | rg '(^|/)agent/component/llm\.py$|api/db/services/dialog_service\.py$' || true
echo
echo "== agent/component/llm.py outline =="
ast-grep outline agent/component/llm.py || true
echo
echo "== relevant llm.py sections =="
wc -l agent/component/llm.py
sed -n '1,240p' agent/component/llm.py
echo
echo "== dialog_service relevant lines =="
wc -l api/db/services/dialog_service.py
sed -n '1880,1960p' api/db/services/dialog_service.py
Repository: infiniflow/ragflow
Length of output: 13645
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== rest of relevant llm.py sections =="
sed -n '240,528p' agent/component/llm.py
echo
echo "== direct chat_mdl usages in agent/component/llm.py =="
rg -n "self\.chat_mdl|chat_mdl" agent/component/llm.py
echo
echo "== inspect llm_service LLMBundle definition =="
fd -a 'llm_service\.py$' . | while read -r f; do
echo "--- $f"
wc -l "$f"
rg -n "class LLMBundle|def (bind_tools|async_chat_streamly_delta|chat|__init__|_.*chat|chat_with_retrieval)" "$f" -C 4
done
sed -n '1,340p' api/db/services/llm_service.py
Repository: infiniflow/ragflow
Length of output: 31619
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== api/db/services/tenant_llm_service.py relevant section =="
sed -n '500,535p' api/db/services/tenant_llm_service.py
wc -l api/db/services/tenant_llm_service.py
echo
echo "== broader dialog_service chat_mdl usages =="
rg -n "chat_mdl|bind_tools\(|\.bind_tools\(" api/db/services/dialog_service.py -C 3
Repository: infiniflow/ragflow
Length of output: 14565
Do not continue with chat_mdl=None.
When model resolution fails, _prepare_prompt_variables() keeps self.chat_mdl as None for text-only requests, but the component later reads self.chat_mdl.max_length and calls bundle methods directly. Set the output via the component’s normal error/default-output path before returning, and narrow the bare except Exception so programming errors are not swallowed.
🧰 Tools
🪛 Ruff (0.15.21)
[warning] 96-96: Do not catch blind exception: Exception
(BLE001)
🤖 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 `@agent/component/llm.py` around lines 91 - 98, Update the model-resolution
flow that initializes self.chat_mdl so failures use the component’s established
error/default-output path and return immediately instead of leaving chat_mdl as
None. Ensure _prepare_prompt_variables() cannot proceed to access
chat_mdl.max_length or bundle methods after resolution failure. Narrow the
exception handling to only expected model/configuration errors, allowing
programming errors to propagate.
Source: Linters/SAST tools
| # config = saved.get("config") or {} | ||
| dataset_merge = True # bool(config.get("dataset_merge")) if isinstance(config, dict) else False |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the commented-out implementation.
Delete the stale config assignment and trailing commented expression once the eligibility contract is decided.
As per coding guidelines, **/*: Remove dead tests, commented-out code, stale documentation, and “move later” notes.
🤖 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/dataset_structure_merger.py` around lines 166
- 167, Remove the stale commented-out config assignment and trailing commented
expression beside dataset_merge in the dataset merge eligibility logic, leaving
only the active dataset_merge behavior.
Source: Coding guidelines
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
rg -n -C 3 '\bdataset_merge\b' --glob '*.py' .Repository: infiniflow/ragflow
Length of output: 3426
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)dataset_structure_merger\.py$|(^|/)runner\.py$|(^|/)dataset_api\.py$' || true
echo
echo "== dataset_structure_merger.py outline =="
ast-grep outline rag/svr/task_executor_refactor/dataset_structure_merger.py --view expanded || true
echo
echo "== relevant dataset_structure_merger.py lines =="
sed -n '1,230p' rag/svr/task_executor_refactor/dataset_structure_merger.py | cat -n
echo
echo "== relevant runner.py lines =="
sed -n '240,330p' rag/advanced_rag/knowlege_compile/runner.py | cat -n
echo
echo "== dataset_api references =="
sed -n '660,720p' api/apps/restful_apis/dataset_api.py | cat -n
echo
echo "== dataset_merge occurrences =="
rg -n -C 2 '\bdataset_merge\b' --glob '*.py' .Repository: infiniflow/ragflow
Length of output: 21298
Use config["dataset_merge"] for structure-merge eligibility.
run_structure_merge() now accepts every matching template, so templates whose persisted config["dataset_merge"] is false or absent are still rebuilt as dataset-wide artifact graphs. Restore the persisted flag from the template config, or update the per-document compile path to the same rule if dataset-wide merge is intentional.
🤖 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/dataset_structure_merger.py` around lines 166
- 167, Update the structure-merge eligibility in run_structure_merge() to read
the persisted template config and set dataset_merge from
config["dataset_merge"], defaulting to false when config is missing, non-dict,
or the key is absent. Ensure templates without an enabled dataset_merge flag are
not treated as dataset-wide artifact graphs.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/apps/services/dataset_api_service.py (1)
1798-1939: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd observability for the new retrieval flows.
Please log branch selection, template-discovery counts, keyword no-match/fallback outcomes, legacy-row recovery, and
top_noverrides without logging raw keyword values. As per coding guidelines:**/*.py: Add logging for new flows.Also applies to: 2960-3002, 3084-3351
🤖 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 `@api/apps/services/dataset_api_service.py` around lines 1798 - 1939, Add structured logging to the get_dataset_structure retrieval flow covering branch selection, discovered template counts, keyword no-match and fallback outcomes, legacy-row recovery, and any top_n overrides. Place logs around the keyword and normal branches plus template-less recovery, and include dataset/context identifiers and counts without logging raw keyword values. Apply the same observability to the related retrieval flows in the additional ranges.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@api/apps/services/dataset_api_service.py`:
- Around line 1798-1939: Add structured logging to the get_dataset_structure
retrieval flow covering branch selection, discovered template counts, keyword
no-match and fallback outcomes, legacy-row recovery, and any top_n overrides.
Place logs around the keyword and normal branches plus template-less recovery,
and include dataset/context identifiers and counts without logging raw keyword
values. Apply the same observability to the related retrieval flows in the
additional ranges.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b692a0bf-64b3-432b-8251-52c27aab72c2
📒 Files selected for processing (2)
api/apps/services/dataset_api_service.pyconf/infinity_mapping.json
🚧 Files skipped from review as they are similar to previous changes (1)
- conf/infinity_mapping.json
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17342 +/- ##
=======================================
Coverage 90.65% 90.65%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 650 650
Misses 39 39
Partials 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
infiniflow#17342 remapped public index types to structure_* merge tasks, so GraphRAG finished instantly with no entities. Keep structure_graph/structure_mindmap as separate merge entrypoints. Co-authored-by: Cursor <[email protected]>
Summary
Add graph keyword search and fix dataset synthesizing issue.