mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-07-04 05:35:13 +08:00
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
parent
858db2f239
commit
239bf97b47
@ -139,13 +139,17 @@ class OAICompatEmbeddingModel(_CommonOaiApiCompat, TextEmbeddingModel):
|
|||||||
if api_key:
|
if api_key:
|
||||||
headers["Authorization"] = f"Bearer {api_key}"
|
headers["Authorization"] = f"Bearer {api_key}"
|
||||||
|
|
||||||
endpoint_url = credentials.get("endpoint_url")
|
endpoint_url = credentials.get("endpoint_url", "")
|
||||||
if not endpoint_url.endswith("/"):
|
if not endpoint_url.endswith("/"):
|
||||||
endpoint_url += "/"
|
endpoint_url += "/"
|
||||||
|
|
||||||
endpoint_url = urljoin(endpoint_url, "embeddings")
|
endpoint_url = urljoin(endpoint_url, "embeddings")
|
||||||
|
|
||||||
payload = {"input": "ping", "model": model}
|
payload = {"input": "ping", "model": model}
|
||||||
|
# For nvidia models, the "input_type":"query" need in the payload
|
||||||
|
# more to check issue #11193 or NvidiaTextEmbeddingModel
|
||||||
|
if model.startswith("nvidia/"):
|
||||||
|
payload["input_type"] = "query"
|
||||||
|
|
||||||
response = requests.post(url=endpoint_url, headers=headers, data=json.dumps(payload), timeout=(10, 300))
|
response = requests.post(url=endpoint_url, headers=headers, data=json.dumps(payload), timeout=(10, 300))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user