From 889aba6a32b326d7f10ce74c9f1919c36d338236 Mon Sep 17 00:00:00 2001 From: Igor Ilinskii <56535464+Qwerrty574@users.noreply.github.com> Date: Mon, 11 May 2026 05:04:40 +0300 Subject: [PATCH] fix base_url handling in HuggingfaceRerank (#14555) ### What problem does this PR solve? HuggingfaceRerank.post() unconditionally prepends `http://` to base_url, which already contains a protocol. This creates invalid URLs like http://http://127.0.0.1:8080/rerank, breaking all requests. The fix normalizes URL handling to match the rest of the codebase, removing redunant `http://`. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) ### Related Issues - #7318 - #7796 --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- rag/llm/rerank_model.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.py index ed569d6bdc..5f1ef3ef24 100644 --- a/rag/llm/rerank_model.py +++ b/rag/llm/rerank_model.py @@ -407,16 +407,21 @@ class HuggingfaceRerank(Base): _FACTORY_NAME = "HuggingFace" @staticmethod - def post(query: str, texts: list, url="127.0.0.1"): + def post(query: str, texts: list, url: str = "http://127.0.0.1"): exc = None scores = [0 for _ in range(len(texts))] batch_size = 8 for i in range(0, len(texts), batch_size): try: - res = requests.post( - f"http://{url}/rerank", headers={"Content-Type": "application/json"}, json={"query": query, "texts": texts[i : i + batch_size], "raw_scores": False, "truncate": True} - ) + endpoint = (url or "").rstrip("/") + if not endpoint.endswith("/rerank"): + endpoint = f"{endpoint}/rerank" + res = requests.post( + endpoint, + headers = {"Content-Type": "application/json"}, + json = {"query": query, "texts": texts[i: i + batch_size], "raw_scores": False, "truncate": True}, + ) for o in res.json(): scores[o["index"] + i] = o["score"] except Exception as e: