Skip to content

Commit 70872cd

Browse files
richard950825-sysLehaoLin
andauthored
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>
1 parent dc9c17c commit 70872cd

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

astrbot/core/config/default.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,7 @@ class ChatProviderTemplate(TypedDict):
17611761
"enable": True,
17621762
"rerank_api_key": "",
17631763
"rerank_api_base": "http://127.0.0.1:8000",
1764+
"rerank_api_suffix": "/v1/rerank",
17641765
"rerank_model": "BAAI/bge-reranker-base",
17651766
"timeout": 20,
17661767
},
@@ -1826,7 +1827,12 @@ class ChatProviderTemplate(TypedDict):
18261827
"rerank_api_base": {
18271828
"description": "重排序模型 API Base URL",
18281829
"type": "string",
1829-
"hint": "AstrBot 会在请求时在末尾加上 /v1/rerank。",
1830+
"hint": "最终请求路径由 Base URL 和路径后缀拼接而成(默认为 /v1/rerank)。",
1831+
},
1832+
"rerank_api_suffix": {
1833+
"description": "API URL 路径后缀",
1834+
"type": "string",
1835+
"hint": "追加到 base_url 后的路径,如 /v1/rerank。留空则不追加。",
18301836
},
18311837
"rerank_api_key": {
18321838
"description": "API Key",

astrbot/core/provider/sources/vllm_rerank_source.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def __init__(self, provider_config: dict, provider_settings: dict) -> None:
2020
self.auth_key = provider_config.get("rerank_api_key", "")
2121
self.base_url = provider_config.get("rerank_api_base", "http://127.0.0.1:8000")
2222
self.base_url = self.base_url.rstrip("/")
23+
self.api_suffix = provider_config.get("rerank_api_suffix", "/v1/rerank")
24+
if self.api_suffix is None:
25+
self.api_suffix = "/v1/rerank"
26+
if self.api_suffix and not self.api_suffix.startswith("/"):
27+
self.api_suffix = "/" + self.api_suffix
2328
self.timeout = provider_config.get("timeout", 20)
2429
self.model = provider_config.get("rerank_model", "BAAI/bge-reranker-base")
2530

@@ -45,8 +50,9 @@ async def rerank(
4550
if top_n is not None:
4651
payload["top_n"] = top_n
4752
assert self.client is not None
53+
rerank_url = f"{self.base_url}{self.api_suffix}"
4854
async with self.client.post(
49-
f"{self.base_url}/v1/rerank",
55+
rerank_url,
5056
json=payload,
5157
) as response:
5258
response_data = await response.json()

dashboard/src/i18n/locales/en-US/features/config-metadata.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,11 @@
10751075
},
10761076
"rerank_api_base": {
10771077
"description": "Rerank Model API Base URL",
1078-
"hint": "AstrBot appends /v1/rerank to the request URL."
1078+
"hint": "The full request URL is formed by combining the Base URL and a path suffix (defaults to /v1/rerank)."
1079+
},
1080+
"rerank_api_suffix": {
1081+
"description": "API URL path suffix",
1082+
"hint": "Path appended to base_url, e.g. /v1/rerank. Leave empty to disable auto-append."
10791083
},
10801084
"rerank_api_key": {
10811085
"description": "API Key",

dashboard/src/i18n/locales/ru-RU/features/config-metadata.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,11 @@
10761076
},
10771077
"rerank_api_base": {
10781078
"description": "Base URL API модели Rerank",
1079-
"hint": "AstrBot добавляет /v1/rerank к URL запроса."
1079+
"hint": "Полный URL запроса формируется путём добавления суффикса к Base URL (по умолчанию /v1/rerank)."
1080+
},
1081+
"rerank_api_suffix": {
1082+
"description": "Суффикс пути API",
1083+
"hint": "Суффикс пути, добавляемый к base_url, например /v1/rerank. Оставьте пустым, чтобы не добавлять."
10801084
},
10811085
"rerank_api_key": {
10821086
"description": "API Key",

dashboard/src/i18n/locales/zh-CN/features/config-metadata.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,11 @@
10771077
},
10781078
"rerank_api_base": {
10791079
"description": "重排序模型 API Base URL",
1080-
"hint": "AstrBot 会在请求时在末尾加上 /v1/rerank。"
1080+
"hint": "最终请求路径由 Base URL 和路径后缀拼接而成(默认为 /v1/rerank)。"
1081+
},
1082+
"rerank_api_suffix": {
1083+
"description": "API URL 路径后缀",
1084+
"hint": "追加到 base_url 后的路径后缀,如 /v1/rerank。留空则不追加。"
10811085
},
10821086
"rerank_api_key": {
10831087
"description": "API Key",

0 commit comments

Comments
 (0)