mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 17:47:06 +08:00
* fix: support both Bailian Rerank API formats based on URL endpoint
阿里云百炼有两个不同的 rerank API 端点:
- /compatible-api/v1/reranks: 使用扁平请求格式 {model, query, documents}
- /api/v1/services/rerank/...: 需要 input 包装 {model, input: {...}}
之前代码只根据模型名判断格式,导致 qwen3-rerank + compatible-api 组合失败。
修复内容:
- _build_payload(): 根据 URL 是否含 'compatible-api' 决定请求格式
- _parse_results(): 根据 URL 判断响应中 results 的位置
Fixes #7161
* refactor: reduce duplication in bailian rerank payload and results handling
- Extract params building outside the if-else branch
- Add back empty results warning log
- Simplify error handling variable assignment
* fix: simplify bailian rerank payload to use model-based logic only
qwen3-rerank always uses flat format regardless of API endpoint.
Other models (gte-rerank-v2, etc.) use input wrapper format.
This simplifies the logic and correctly handles all model/URL combinations.
Tested: qwen3-rerank accepts both formats, gte-rerank-v2 only supports input wrapper.
---------
Co-authored-by: root <root@localhost.localdomain>
Co-authored-by: Fix Bot <fix@example.com>