mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-11 05:59:01 +08:00
Detect invalid response from api.siliconflow.cn (#3792)
### What problem does this PR solve? Detect invalid response from api.siliconflow.cn. Close #2643 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
deca6c1b72
commit
d19f059f34
@ -606,6 +606,8 @@ class SILICONFLOWEmbed(Base):
|
||||
"encoding_format": "float",
|
||||
}
|
||||
res = requests.post(self.base_url, json=payload, headers=self.headers).json()
|
||||
if "data" not in res or not isinstance(res["data"], list) or len(res["data"])!= len(texts):
|
||||
raise ValueError(f"SILICONFLOWEmbed.encode got invalid response from {self.base_url}")
|
||||
return (
|
||||
np.array([d["embedding"] for d in res["data"]]),
|
||||
res["usage"]["total_tokens"],
|
||||
@ -618,6 +620,8 @@ class SILICONFLOWEmbed(Base):
|
||||
"encoding_format": "float",
|
||||
}
|
||||
res = requests.post(self.base_url, json=payload, headers=self.headers).json()
|
||||
if "data" not in res or not isinstance(res["data"], list) or len(res["data"])!= 1:
|
||||
raise ValueError(f"SILICONFLOWEmbed.encode_queries got invalid response from {self.base_url}")
|
||||
return np.array(res["data"][0]["embedding"]), res["usage"]["total_tokens"]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user