Skip to content

Commit 4d2791a

Browse files
he-yufengRC-CHNgemini-code-assist[bot]
authored
fix: support both old and new Bailian Rerank API response formats (#7217)
* fix: support both old and new Bailian Rerank API response formats The new compatible API (compatible-api/v1/reranks) returns results at the top level as data.results, while the old API returns them nested under data.output.results. The parser only checked the old path, causing qwen3-rerank to always report empty results. Fixes #7161 * Update astrbot/core/provider/sources/bailian_rerank_source.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: Ruochen Pan <badbatch0x01@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 3dd7799 commit 4d2791a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

astrbot/core/provider/sources/bailian_rerank_source.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ def _parse_results(self, data: dict) -> list[RerankResult]:
142142
f"百炼 API 错误: {data.get('code')}{data.get('message', '')}"
143143
)
144144

145-
results = data.get("output", {}).get("results", [])
145+
# 兼容旧版 API (output.results) 和新版 compatible API (results)
146+
results = (data.get("output") or {}).get("results") or data.get("results") or []
146147
if not results:
147148
logger.warning(f"百炼 Rerank 返回空结果: {data}")
148149
return []

0 commit comments

Comments
 (0)