Skip to content

fix(reranker): 修正直接回答分段列表 - #7368

Open
Aling33 wants to merge 1 commit into
1Panel-dev:v2from
Aling33:codex/fix-reranker-direct-answer-segments
Open

Aling33 wants to merge 1 commit into
1Panel-dev:v2from
Aling33:codex/fix-reranker-direct-answer-segments

Conversation

@Aling33

@Aling33 Aling33 commented Oct 18, 2026

Copy link
Copy Markdown

What this PR does / why we need it?

重排节点的 is_hit_handling_method_list 当前会为每一个满足直接回答条件的分段,加入整个重排结果列表,形成嵌套列表,并携带不满足条件的分段。下游工作流引用该字段时无法按单个分段读取内容和元数据。

例如重排结果为 [A, B, C],仅 A、C 满足条件时,当前输出为 [[A, B, C], [A, B, C]];修复后输出为 [A, C]。

Summary of your change

  • 在列表推导式中返回当前匹配的 row,保留重排顺序与元数据。
  • 添加一个独立可运行的回归测试,覆盖多条命中、单条命中、无命中;确认完整 result_list 和 result 保持原值。
  • 未新增依赖、接口或配置。

验证方案与实测结果

uv run --no-project --python 3.11 --with 'langchain-core==1.4.8' --with 'ruff==0.15.12' python apps/application/test_reranker_node.py -v
uv run --no-project --python 3.11 --with 'langchain-core==1.4.8' --with 'ruff==0.15.12' ruff check apps/application/flow/step_node/reranker_node/impl/base_reranker_node.py apps/application/test_reranker_node.py
git diff --check
  • 修改前:回归测试的多条命中、单条命中用例失败,证明返回元素为列表而非分段字典。
  • 修改后:1 个测试方法内的 3 个子用例全部通过;Ruff 和 diff 空白检查通过。
  • 测试执行真实重排节点的 execute 方法和真实 LangChain Document;Django 节点基类、结果容器和模型服务在导入边界使用替身。未运行完整 Django、数据库或真实模型端到端测试。

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

文档影响:修复已有字段的数据结构,无新增操作步骤或配置。

AI 辅助说明:使用 Codex 协助定位、编写修复和运行回归验证。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant