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>
This commit is contained in:
Yufeng He
2026-04-01 11:55:54 +08:00
committed by GitHub
co-authored by gemini-code-assist[bot] Ruochen Pan
parent 3dd7799f27
commit 4d2791aa9a
@@ -142,7 +142,8 @@ class BailianRerankProvider(RerankProvider):
f"百炼 API 错误: {data.get('code')} – {data.get('message', '')}"
)
results = data.get("output", {}).get("results", [])
# 兼容旧版 API (output.results) 和新版 compatible API (results)
results = (data.get("output") or {}).get("results") or data.get("results") or []
if not results:
logger.warning(f"百炼 Rerank 返回空结果: {data}")
return []