Skip to content

[Go] Add /api/v1/searchbots/mindmap and /api/v1/chat/mindmap - #16443

Merged
wangq8 merged 7 commits into
infiniflow:mainfrom
wangq8:feature/go-add-api-v1-searchbots-mindmap
Jun 30, 2026
Merged

wangq8 merged 7 commits into
infiniflow:mainfrom
wangq8:feature/go-add-api-v1-searchbots-mindmap

Conversation

@wangq8

@wangq8 wangq8 commented Jun 29, 2026 •

Copy link
Copy Markdown
Collaborator

/chat/mindmap
image
/searchbots/mindmap
image

@coderabbitai

coderabbitai Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a POST /api/v1/searchbots/mindmap endpoint that validates input, retrieves relevant sections, calls the LLM with a mind-map prompt, and returns the parsed markdown response as a hierarchical JSON tree.

Changes

SearchBot MindMap Endpoint

Layer / File(s) Summary
Request DTO and route registration
internal/handler/searchbot.go, internal/router/router.go, internal/router/router_test.go
Defines SearchBotMindMapRequest, updates the handler doc comment, registers POST /searchbots/mindmap in the beta-authenticated router group, and verifies the route and middleware wiring.
MindMap handler implementation
internal/handler/searchbot.go
Implements SearchBotHandler.MindMap: validates input, optionally loads search_config from search_id, runs chunk retrieval, selects the chat model, calls llm.Chat, and returns an empty or parsed mind-map tree.
Retrieval helpers and markdown parser
internal/handler/searchbot.go
Adds searchConfigFromDetail, mindMapRetrievalRequest, mindMapSections, prompt formatting, and markdown-to-tree parsing helpers.
MindMap handler tests
internal/handler/searchbot_test.go
Extends fakeSearchbotLLM, adds TestMindMapHandlerSuccess, and adds TestParseMindMapMarkdown_ListUnderHeading.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SearchBotHandler.MindMap
  participant chunkSvc
  participant llm

  Client->>SearchBotHandler.MindMap: POST /api/v1/searchbots/mindmap
  SearchBotHandler.MindMap->>chunkSvc: RetrievalTest(question, kb_ids, config)
  chunkSvc-->>SearchBotHandler.MindMap: chunks / sections
  SearchBotHandler.MindMap->>llm: Chat(mindMapPrompt + sections + "Output:")
  llm-->>SearchBotHandler.MindMap: markdown answer
  SearchBotHandler.MindMap-->>Client: mindMapNode tree JSON
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐇 I hop from question into tree,
Sections bloom where chunks should be.
The LLM hums, the mind map sings,
Roots and branches, tidy things.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description lacks the required Summary section and background context, and only contains screenshot references. Add a brief Summary explaining what the new /api/v1/searchbots/mindmap endpoint does and why it is needed, plus any relevant implementation notes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is mostly aligned with the main change, but it mentions an extra /api/v1/chat/mindmap endpoint not shown in the changeset.
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 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@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 `@internal/handler/searchbot.go`:
- Around line 456-461: The search_id lookup in handler.Searchbot currently hides
GetDetail failures and falls back to defaults, which can return a response with
the wrong configuration. Update the logic around h.searchSvc.GetDetail in
searchbot.go so that when req.SearchID is set and GetDetail returns an error,
the handler returns that error instead of continuing with searchConfigFromDetail
defaults. Keep the existing searchConfigFromDetail path for successful lookups,
but make the req.SearchID branch in the search handling flow fail fast on lookup
errors.
- Around line 849-861: The mind-map parsing in searchbot.go is treating
zero-indented bullet items as top-level siblings instead of children of the
current heading, which causes list content like “- Features” under “# Product”
to detach from the generated title. Update the parsing logic in the block that
builds `mindMapNode`/uses `mindMapListRe` so list nesting is offset relative to
the current heading or list block, not always anchored at the root. Make sure
`title`, `level`, `stack`, and the append-to-parent logic keep bullet lists
nested under the preceding heading when no extra indentation is present.
🪄 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: 23297ec3-394f-4e90-b519-24ae41e39169

📥 Commits

Reviewing files that changed from the base of the PR and between 6e82e27 and 993e759.

📒 Files selected for processing (3)
  • internal/handler/searchbot.go
  • internal/handler/searchbot_test.go
  • internal/router/router.go

Comment thread internal/handler/searchbot.go Resolved
Comment thread internal/handler/searchbot.go Resolved
@wangq8 wangq8 changed the title [go] Add /api/v1/searchbots/mindmap [Go] Add /api/v1/searchbots/mindmap Jun 29, 2026
@wangq8
wangq8 force-pushed the feature/go-add-api-v1-searchbots-mindmap branch from 993e759 to 2aeb2ea Compare June 29, 2026 11:29
@wangq8
wangq8 marked this pull request as ready for review June 30, 2026 04:54
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 30, 2026
@wangq8
wangq8 marked this pull request as draft June 30, 2026 04:56
@wangq8 wangq8 added the ci Continue Integration label Jun 30, 2026
@wangq8
wangq8 marked this pull request as ready for review June 30, 2026 04:56
@dosubot dosubot Bot added the 💞 feature Feature request, pull request that fullfill a new feature. label Jun 30, 2026
@wangq8 wangq8 changed the title [Go] Add /api/v1/searchbots/mindmap [Go] Add /api/v1/searchbots/mindmap and /api/v1/chat/mindmap Jun 30, 2026
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (540acb4) to head (ae0b7ec).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16443   +/-   ##
=======================================
  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.

@wangq8
wangq8 merged commit 3bb976b into infiniflow:main Jun 30, 2026
3 checks passed
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 1, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 14, 2026
1 task done
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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant