Skip to content

Commit

Permalink
fix: nvidia special embedding model payload close langgenius#11193 (l…
Browse files Browse the repository at this point in the history
…anggenius#11239)

Signed-off-by: yihong0618 <[email protected]>
  • Loading branch information
yihong0618 authored Dec 2, 2024
1 parent 858db2f commit 239bf97
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,17 @@ def validate_credentials(self, model: str, credentials: dict) -> None:
if 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("/"):
endpoint_url += "/"

endpoint_url = urljoin(endpoint_url, "embeddings")

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))

Expand Down

0 comments on commit 239bf97

Please sign in to comment.