diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 45412bdccb..7cd4ff6862 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -1761,6 +1761,7 @@ class ChatProviderTemplate(TypedDict): "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 @@ class ChatProviderTemplate(TypedDict): "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", diff --git a/astrbot/core/provider/sources/vllm_rerank_source.py b/astrbot/core/provider/sources/vllm_rerank_source.py index edd8a54913..e5ed791160 100644 --- a/astrbot/core/provider/sources/vllm_rerank_source.py +++ b/astrbot/core/provider/sources/vllm_rerank_source.py @@ -20,6 +20,11 @@ def __init__(self, provider_config: dict, provider_settings: dict) -> None: 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 @@ async def rerank( 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() diff --git a/dashboard/src/i18n/locales/en-US/features/config-metadata.json b/dashboard/src/i18n/locales/en-US/features/config-metadata.json index 9ae8672826..92927cebd7 100644 --- a/dashboard/src/i18n/locales/en-US/features/config-metadata.json +++ b/dashboard/src/i18n/locales/en-US/features/config-metadata.json @@ -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", diff --git a/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json b/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json index 0aa5c791ac..afb608b4ab 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json +++ b/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json @@ -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", diff --git a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json index c04138402e..8ce6d575f6 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json +++ b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json @@ -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",