@danhachuel/thunderbolt 0.5.50 → 0.5.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -266,31 +266,23 @@ def validate_paligemma_api_key(
|
|
|
266
266
|
*,
|
|
267
267
|
timeout: float = DEFAULT_TIMEOUT_SECONDS,
|
|
268
268
|
) -> None:
|
|
269
|
-
"""Validate the
|
|
269
|
+
"""Validate the NIM credential through its authenticated model catalog."""
|
|
270
270
|
token = str(api_key or "").strip()
|
|
271
271
|
if not token:
|
|
272
272
|
raise OpenAICompatibleAPIError("Informe a API key antes do teste.")
|
|
273
273
|
configured = str(base_url or DEFAULT_NVIDIA_NIM_BASE_URL).rstrip("/")
|
|
274
274
|
if configured.endswith("/chat/completions"):
|
|
275
275
|
configured = configured.removesuffix("/chat/completions")
|
|
276
|
-
if
|
|
277
|
-
configured = configured.replace("integrate.api.nvidia.com", "ai.api.nvidia.com")
|
|
278
|
-
endpoint = configured if "/vlm/google/paligemma" in configured else f"{configured}/vlm/google/paligemma"
|
|
279
|
-
payload = {
|
|
280
|
-
"messages": [{"role": "user", "content": "Describe this image in one word."}],
|
|
281
|
-
"max_tokens": 8,
|
|
282
|
-
"temperature": 0,
|
|
283
|
-
}
|
|
276
|
+
endpoint = configured if configured.endswith("/models") else f"{configured}/models"
|
|
284
277
|
try:
|
|
285
|
-
response = requests.
|
|
278
|
+
response = requests.get(
|
|
286
279
|
endpoint,
|
|
287
|
-
headers={"Accept": "application/json", "Authorization": f"Bearer {token}"
|
|
288
|
-
json=payload,
|
|
280
|
+
headers={"Accept": "application/json", "Authorization": f"Bearer {token}"},
|
|
289
281
|
timeout=timeout,
|
|
290
282
|
)
|
|
291
283
|
except requests.RequestException as exc:
|
|
292
|
-
raise OpenAICompatibleAPIError(f"Não foi possível testar o
|
|
284
|
+
raise OpenAICompatibleAPIError(f"Não foi possível testar o catálogo NVIDIA NIM: {exc}") from exc
|
|
293
285
|
if response.status_code >= 400:
|
|
294
286
|
if response.status_code in (401, 403):
|
|
295
|
-
raise OpenAICompatibleAPIError(f"O
|
|
296
|
-
raise OpenAICompatibleAPIError(f"O
|
|
287
|
+
raise OpenAICompatibleAPIError(f"O catálogo NVIDIA NIM recusou a API key (HTTP {response.status_code}).")
|
|
288
|
+
raise OpenAICompatibleAPIError(f"O catálogo NVIDIA NIM devolveu HTTP {response.status_code}.")
|
package/package.json
CHANGED