feat(provider/vllm_rerank): add configurable rerank_api_suffix option (#7278)

* feat(provider/vllm_rerank): add configurable rerank_api_suffix option

Add rerank_api_suffix config option to the VLLM Rerank provider so
users can control the API URL path suffix instead of having /v1/rerank
hardcoded.

- Default value is /v1/rerank (preserves existing behavior)
- Users can set it to empty string to disable auto-append
- Handles suffix without leading slash by auto-adding one
- Schema, default config, and i18n metadata all updated

Issue: Fixes #7238

* fix(provider/vllm_rerank): handle null suffix and improve hint descriptions

- Add explicit None check for rerank_api_suffix (fixes HIGH from Gemini)
- Update rerank_api_base hint to describe actual behavior without
  mentioning specific provider options (fixes 3x MEDIUM from Gemini)
- Add ru-RU i18n for rerank_api_suffix (fixes P2 from Codex)

Co-authored-by: gemini-code-assist[bot]
Co-authored-by: chatgpt-codex-connector[bot]

---------

Co-authored-by: LehaoLin <linlehao@cuhk.edu.cn>
This commit is contained in:
Rico0919x
2026-04-05 00:15:27 +08:00
committed by GitHub
parent dc9c17c195
commit 70872cd44b
5 changed files with 29 additions and 5 deletions

View File

@@ -1761,6 +1761,7 @@ CONFIG_METADATA_2 = {
"enable": True,
"rerank_api_key": "",
"rerank_api_base": "http://127.0.0.1:8000",
"rerank_api_suffix": "/v1/rerank",
"rerank_model": "BAAI/bge-reranker-base",
"timeout": 20,
},
@@ -1826,7 +1827,12 @@ CONFIG_METADATA_2 = {
"rerank_api_base": {
"description": "重排序模型 API Base URL",
"type": "string",
"hint": "AstrBot 会在请求时在末尾加上 /v1/rerank。",
"hint": "最终请求路径由 Base URL 和路径后缀拼接而成(默认为 /v1/rerank",
},
"rerank_api_suffix": {
"description": "API URL 路径后缀",
"type": "string",
"hint": "追加到 base_url 后的路径,如 /v1/rerank。留空则不追加。",
},
"rerank_api_key": {
"description": "API Key",

View File

@@ -20,6 +20,11 @@ class VLLMRerankProvider(RerankProvider):
self.auth_key = provider_config.get("rerank_api_key", "")
self.base_url = provider_config.get("rerank_api_base", "http://127.0.0.1:8000")
self.base_url = self.base_url.rstrip("/")
self.api_suffix = provider_config.get("rerank_api_suffix", "/v1/rerank")
if self.api_suffix is None:
self.api_suffix = "/v1/rerank"
if self.api_suffix and not self.api_suffix.startswith("/"):
self.api_suffix = "/" + self.api_suffix
self.timeout = provider_config.get("timeout", 20)
self.model = provider_config.get("rerank_model", "BAAI/bge-reranker-base")
@@ -45,8 +50,9 @@ class VLLMRerankProvider(RerankProvider):
if top_n is not None:
payload["top_n"] = top_n
assert self.client is not None
rerank_url = f"{self.base_url}{self.api_suffix}"
async with self.client.post(
f"{self.base_url}/v1/rerank",
rerank_url,
json=payload,
) as response:
response_data = await response.json()

View File

@@ -1075,7 +1075,11 @@
},
"rerank_api_base": {
"description": "Rerank Model API Base URL",
"hint": "AstrBot appends /v1/rerank to the request URL."
"hint": "The full request URL is formed by combining the Base URL and a path suffix (defaults to /v1/rerank)."
},
"rerank_api_suffix": {
"description": "API URL path suffix",
"hint": "Path appended to base_url, e.g. /v1/rerank. Leave empty to disable auto-append."
},
"rerank_api_key": {
"description": "API Key",

View File

@@ -1076,7 +1076,11 @@
},
"rerank_api_base": {
"description": "Base URL API модели Rerank",
"hint": "AstrBot добавляет /v1/rerank к URL запроса."
"hint": "Полный URL запроса формируется путём добавления суффикса к Base URL (по умолчанию /v1/rerank)."
},
"rerank_api_suffix": {
"description": "Суффикс пути API",
"hint": "Суффикс пути, добавляемый к base_url, например /v1/rerank. Оставьте пустым, чтобы не добавлять."
},
"rerank_api_key": {
"description": "API Key",

View File

@@ -1077,7 +1077,11 @@
},
"rerank_api_base": {
"description": "重排序模型 API Base URL",
"hint": "AstrBot 会在请求时在末尾加上 /v1/rerank。"
"hint": "最终请求路径由 Base URL 和路径后缀拼接而成(默认为 /v1/rerank。"
},
"rerank_api_suffix": {
"description": "API URL 路径后缀",
"hint": "追加到 base_url 后的路径后缀,如 /v1/rerank。留空则不追加。"
},
"rerank_api_key": {
"description": "API Key",