Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix xinference add rerank model bug #2758

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rag/llm/rerank_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#
import re
import threading
from urllib.parse import urljoin

import requests
from huggingface_hub import snapshot_download
import os
Expand Down Expand Up @@ -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":
Copy link

@Halfknow Halfknow Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommand the code changed as follows to fix xinference rerank model add failure:
if base_url.split("/")[-1] != "v1" and base_url.split("/")[-1] != "rerank":

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the end is / easy to have problems, so I used find

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 = {
Expand Down
Loading