From f49b5116ddd1a16a87deb3d5400de4126f6af117 Mon Sep 17 00:00:00 2001 From: Sky Blue <39080510+wangguo1230@users.noreply.github.com> Date: Wed, 9 Oct 2024 19:37:11 +0800 Subject: [PATCH] fix xinference add rerank model bug (#2758) ### What problem does this PR solve? Fix xinference add rerank model bug, https://github.com/infiniflow/ragflow/issues/2294#issue-2510788135 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/llm/rerank_model.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.py index 1d80fd0ec81..bf69211c398 100644 --- a/rag/llm/rerank_model.py +++ b/rag/llm/rerank_model.py @@ -15,6 +15,8 @@ # import re import threading +from urllib.parse import urljoin + import requests from huggingface_hub import snapshot_download import os @@ -154,8 +156,8 @@ def similarity(self, query: str, texts: list): class XInferenceRerank(Base): def __init__(self, key="xxxxxxx", model_name="", base_url=""): - if base_url.split("/")[-1] != "v1": - base_url = os.path.join(base_url, "v1") + if base_url.find("/v1") == -1: + base_url = urljoin(base_url, "/v1/rerank") self.model_name = model_name self.base_url = base_url self.headers = {