Repository navigation
Revert frontend changes from PR #16873 and add Go/Python runtime detection - #16948
Conversation
PR infiniflow#16873 introduced dynamic parser-list fetching from the backend (useQuery + kbService.listPipelines), replacing the hardcoded parser list and removing the ParserListMap/useFetchParserListOnMount hook. This revert restores the original frontend code: - web/src/hooks/use-user-setting-request.tsx — hardcoded parser list - web/src/locales/en.ts — 'general' parser label removed - web/src/services/knowledge-service.ts — listPipelines method removed - web/src/utils/api.ts — listPipelines endpoint removed - web/src/components/chunk-method-dialog/hooks.ts — ParserListMap and useFetchParserListOnMount restored Co-Authored-By: Claude <[email protected]>
📝 WalkthroughWalkthroughParser selection now uses local defaults or tenant-configured parser IDs instead of the builtin pipeline catalog. A new hook filters available parsers by document extension, and the obsolete pipeline-list API and translation entry are removed. ChangesParser list flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ChunkMethodDialog
participant useFetchParserListOnMount
participant useSelectParserList
ChunkMethodDialog->>useFetchParserListOnMount: documentExtension
useFetchParserListOnMount->>useSelectParserList: request parserList
useSelectParserList-->>useFetchParserListOnMount: default or tenant parser entries
useFetchParserListOnMount-->>ChunkMethodDialog: filtered parserList
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 1
🧹 Nitpick comments (2)
web/src/components/chunk-method-dialog/hooks.ts (1)
76-84: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify array identity checks. Both of these locations implement an identity search using
Array.prototype.some. PreferArray.prototype.includesfor improved readability when performing strict equality containment checks.
web/src/components/chunk-method-dialog/hooks.ts#L76-L84: replacevalues?.some((y) => y === x.value)withvalues.includes(x.value)(note: the optional chaining is safe to remove becausevaluesdefaults to[]at the call site).web/src/components/chunk-method-dialog/hooks.ts#L89-L93: replacex.some((y) => y === documentExtension)withx.includes(documentExtension).🤖 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 `@web/src/components/chunk-method-dialog/hooks.ts` around lines 76 - 84, In web/src/components/chunk-method-dialog/hooks.ts at lines 76-84, update getParserList to use values.includes(x.value) instead of the identity-based some check, removing optional chaining because values defaults to an empty array. At lines 89-93 in the related document-extension filter, replace x.some((y) => y === documentExtension) with x.includes(documentExtension).web/src/hooks/use-user-setting-request.tsx (1)
145-148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a fallback for unlabelled tenant parsers.
If
tenantInfo.parser_idscontains raw values without a colon (e.g.,'naive,qa'instead of'naive:Naive,qa:QA'),arr[1]will be undefined. This can result in blank labels in the UI. Consider falling back to the corresponding label fromdefaultParsersor using the raw value as a last resort.💡 Proposed refactor
- return filteredArray.map((x) => { - const arr = x.split(':'); - return { value: arr[0], label: arr[1] }; - }); + return filteredArray.map((x) => { + const arr = x.split(':'); + const value = arr[0]; + const label = arr[1] || defaultParsers.find((p) => p.value === value)?.label || value; + return { value, label }; + });🤖 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 `@web/src/hooks/use-user-setting-request.tsx` around lines 145 - 148, Update the parser mapping in the hook’s filteredArray flow to handle entries without a colon: use the matching label from defaultParsers when available, and fall back to the raw parser value otherwise. Preserve the existing value mapping and labels for entries that already include an explicit label.
🤖 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 `@web/src/components/chunk-method-dialog/hooks.ts`:
- Around line 72-74: Update the extension-to-parser mapping near the existing
json, naive/knowledge_graph, and eml/email entries to map mp3, wav, and m4a
extensions to audio. Ensure audio uploads resolve to the audio parser instead of
the fallback list.
---
Nitpick comments:
In `@web/src/components/chunk-method-dialog/hooks.ts`:
- Around line 76-84: In web/src/components/chunk-method-dialog/hooks.ts at lines
76-84, update getParserList to use values.includes(x.value) instead of the
identity-based some check, removing optional chaining because values defaults to
an empty array. At lines 89-93 in the related document-extension filter, replace
x.some((y) => y === documentExtension) with x.includes(documentExtension).
In `@web/src/hooks/use-user-setting-request.tsx`:
- Around line 145-148: Update the parser mapping in the hook’s filteredArray
flow to handle entries without a colon: use the matching label from
defaultParsers when available, and fall back to the raw parser value otherwise.
Preserve the existing value mapping and labels for entries that already include
an explicit label.
🪄 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: 5b07eaa4-0879-4197-8fe4-3ecc89e197ac
📒 Files selected for processing (5)
web/src/components/chunk-method-dialog/hooks.tsweb/src/hooks/use-user-setting-request.tsxweb/src/locales/en.tsweb/src/services/knowledge-service.tsweb/src/utils/api.ts
💤 Files with no reviewable changes (3)
- web/src/locales/en.ts
- web/src/services/knowledge-service.ts
- web/src/utils/api.ts
| [['json'], ['naive', 'knowledge_graph']], | ||
| [['eml'], ['email']], | ||
| ]); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for frontend usage of `audio` and `knowledge_graph` parsers to confirm their intended scopes.
rg -n "'audio'|'knowledge_graph'" web/src/Repository: infiniflow/ragflow
Length of output: 1376
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== chunk-method-dialog/hooks.ts ==\n'
sed -n '1,140p' web/src/components/chunk-method-dialog/hooks.ts | cat -n
printf '\n== use-user-setting-request.tsx ==\n'
sed -n '100,170p' web/src/hooks/use-user-setting-request.tsx | cat -nRepository: infiniflow/ragflow
Length of output: 6187
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== ParserListMap references ==\n'
rg -n "ParserListMap|mp3|m4a|wav|flac|ogg" web/src/components web/src/hooks web/src/pages -g '!**/*.map'
printf '\n== useSelectParserList definition ==\n'
rg -n "export const useSelectParserList|const useSelectParserList|function useSelectParserList" web/src -g '!**/*.map'Repository: infiniflow/ragflow
Length of output: 27398
Map audio extensions to audio (web/src/components/chunk-method-dialog/hooks.ts:72-74). mp3/wav/m4a files fall through to the fallback list, which omits audio, so the parser never appears for those uploads.
🤖 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 `@web/src/components/chunk-method-dialog/hooks.ts` around lines 72 - 74, Update
the extension-to-parser mapping near the existing json, naive/knowledge_graph,
and eml/email entries to map mp3, wav, and m4a extensions to audio. Ensure audio
uploads resolve to the audio parser instead of the fallback list.
#16873 引入了前端改动(动态从
/api/v1/pipelines获取解析器列表),但这个接口只存在于 Go 后端,Python 后端没有。当前端连接到 Python 后端时请求会失败。解决方案
Go 和 Python 后端都提供
GET /api/v1/language接口,前端根据返回值选择代码路径。改动文件
Go 后端
internal/handler/system.go— 新增Languagehandler,返回{"language": "go"}internal/router/router.go— 注册GET /api/v1/language路由Python 后端
api/apps/restful_apis/system_api.py— 新增/language路由,返回{"language": "python"}前端
web/src/utils/backend-runtime.ts(新)— 参照billingStatus.ts模式的运行时检测模块web/src/hooks/use-user-setting-request.tsx—useSelectParserList根据 backend language 分支:/api/v1/pipelinesdefaultParsersweb/src/utils/api.ts— 恢复listPipelinesendpointweb/src/services/knowledge-service.ts— 恢复listPipelines方法web/src/locales/en.ts— 恢复generalparser label