Fix keys of Xinference deployed models, especially has the same model name with public hosted models. (#2832)

### What problem does this PR solve?

Fix keys of Xinference deployed models, especially has the same model
name with public hosted models.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Co-authored-by: 0000sir <0000sir@gmail.com>
Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
0000sir
2024-10-16 10:21:08 +08:00
committed by GitHub
parent 51ecda0ff5
commit 4991107822
7 changed files with 22 additions and 15 deletions

View File

@ -453,7 +453,7 @@ class XinferenceCV(Base):
def __init__(self, key, model_name="", lang="Chinese", base_url=""):
if base_url.split("/")[-1] != "v1":
base_url = os.path.join(base_url, "v1")
self.client = OpenAI(api_key="xxx", base_url=base_url)
self.client = OpenAI(api_key=key, base_url=base_url)
self.model_name = model_name
self.lang = lang

View File

@ -274,7 +274,7 @@ class XinferenceEmbed(Base):
def __init__(self, key, model_name="", base_url=""):
if base_url.split("/")[-1] != "v1":
base_url = os.path.join(base_url, "v1")
self.client = OpenAI(api_key="xxx", base_url=base_url)
self.client = OpenAI(api_key=key, base_url=base_url)
self.model_name = model_name
def encode(self, texts: list, batch_size=32):

View File

@ -162,7 +162,8 @@ class XInferenceRerank(Base):
self.base_url = base_url
self.headers = {
"Content-Type": "application/json",
"accept": "application/json"
"accept": "application/json",
"Authorization": f"Bearer {key}"
}
def similarity(self, query: str, texts: list):

View File

@ -90,6 +90,7 @@ class XinferenceSeq2txt(Base):
def __init__(self,key,model_name="whisper-small",**kwargs):
self.base_url = kwargs.get('base_url', None)
self.model_name = model_name
self.key = key
def transcription(self, audio, language="zh", prompt=None, response_format="json", temperature=0.7):
if isinstance(audio, str):