@danhachuel/thunderbolt 0.5.47 → 0.5.49
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.
package/app/main.py
CHANGED
|
@@ -7043,7 +7043,7 @@ def _render_llm_card(settings: dict[str, Any], cards: list[dict[str, Any]], inde
|
|
|
7043
7043
|
"meta/llama-3.1-70b-instruct",
|
|
7044
7044
|
"meta/llama-3.3-70b-instruct",
|
|
7045
7045
|
"nvidia/llama-3.1-nemotron-70b-instruct",
|
|
7046
|
-
] if definition.code == "openai" else []
|
|
7046
|
+
] if definition.code == "openai" else (["google/paligemma"] if definition.code == "nvidia_nim_paligemma" else [])
|
|
7047
7047
|
options = ["__select_model__", *list(dict.fromkeys([*discovered_models, *default_models]))]
|
|
7048
7048
|
# Mantém modelos guardados mesmo quando a descoberta ainda não foi
|
|
7049
7049
|
# executada ou quando o provider deixou de os devolver temporariamente.
|
|
@@ -7128,11 +7128,17 @@ def _render_llm_card(settings: dict[str, Any], cards: list[dict[str, Any]], inde
|
|
|
7128
7128
|
try:
|
|
7129
7129
|
from integrations.openai_model_discovery import fetch_openai_compatible_models
|
|
7130
7130
|
discovered = fetch_openai_compatible_models(edited.get("api_key", ""), edited.get("base_url", ""))
|
|
7131
|
+
if definition.code == "nvidia_nim_paligemma" and "google/paligemma" not in discovered:
|
|
7132
|
+
discovered.insert(0, "google/paligemma")
|
|
7131
7133
|
st.session_state[f"llm_model_catalog_{card_id}"] = discovered
|
|
7132
7134
|
_persist_llm_cards(settings, cards)
|
|
7133
7135
|
st.success(f"{len(discovered)} modelo(s) disponíveis neste endpoint.")
|
|
7134
7136
|
except Exception:
|
|
7135
|
-
|
|
7137
|
+
if definition.code == "nvidia_nim_paligemma" and str(edited.get("api_key") or "").strip():
|
|
7138
|
+
st.session_state[f"llm_model_catalog_{card_id}"] = ["google/paligemma"]
|
|
7139
|
+
st.warning("O catálogo NIM não expôs modelos, mas o modelo Paligemma foi disponibilizado para este provider.")
|
|
7140
|
+
else:
|
|
7141
|
+
st.error("Não foi possível consultar os modelos deste endpoint.")
|
|
7136
7142
|
elif save_clicked:
|
|
7137
7143
|
_persist_llm_cards(settings, cards)
|
|
7138
7144
|
st.success("Cartão LLM guardado.")
|
|
@@ -161,7 +161,9 @@ def _vision_prompt(video: Mapping[str, Any]) -> str:
|
|
|
161
161
|
def analyse_thumbnail_with_paligemma(path: str, card: Mapping[str, Any]) -> dict[str, Any]:
|
|
162
162
|
key = str(card.get("api_key") or "").strip()
|
|
163
163
|
base = str(card.get("base_url") or "https://integrate.api.nvidia.com/v1").rstrip("/")
|
|
164
|
-
|
|
164
|
+
if "integrate.api.nvidia.com" in base:
|
|
165
|
+
base = base.replace("integrate.api.nvidia.com", "ai.api.nvidia.com")
|
|
166
|
+
endpoint = base if "/vlm/google/paligemma" in base else f"{base}/vlm/google/paligemma"
|
|
165
167
|
model = str(card.get("model") or "google/paligemma").strip()
|
|
166
168
|
if not key:
|
|
167
169
|
return {"score": 50, "diagnosis": "API key NVIDIA NIM Paligemma não configurada.", "status": "sem_dados"}
|
|
@@ -13,6 +13,7 @@ from integrations.openai_model_discovery import (
|
|
|
13
13
|
DEFAULT_NVIDIA_NIM_BASE_URL,
|
|
14
14
|
OpenAICompatibleAPIError,
|
|
15
15
|
fetch_openai_compatible_models,
|
|
16
|
+
validate_paligemma_api_key,
|
|
16
17
|
validate_openai_compatible_api_key,
|
|
17
18
|
validate_openrouter_api_key,
|
|
18
19
|
)
|
|
@@ -431,7 +432,9 @@ def test_llm_provider_card(card: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
431
432
|
if not model:
|
|
432
433
|
return {"ok": False, "status": "error", "message": "Missing configuration — introduza o modelo antes do teste."}
|
|
433
434
|
try:
|
|
434
|
-
if normalized["provider"] == "
|
|
435
|
+
if normalized["provider"] == "nvidia_nim_paligemma":
|
|
436
|
+
validate_paligemma_api_key(api_key, base_url)
|
|
437
|
+
elif normalized["provider"] == "openrouter":
|
|
435
438
|
validate_openrouter_api_key(api_key, base_url, model)
|
|
436
439
|
else:
|
|
437
440
|
validate_openai_compatible_api_key(api_key, base_url, model)
|
|
@@ -258,3 +258,39 @@ def fetch_replicate_models(
|
|
|
258
258
|
if not models:
|
|
259
259
|
raise ModelDiscoveryError("O endpoint Replicate não devolveu modelos com versão disponível.")
|
|
260
260
|
return sorted(models, key=str.casefold)[:MAX_MODEL_IDS]
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def validate_paligemma_api_key(
|
|
264
|
+
api_key: str,
|
|
265
|
+
base_url: str,
|
|
266
|
+
*,
|
|
267
|
+
timeout: float = DEFAULT_TIMEOUT_SECONDS,
|
|
268
|
+
) -> None:
|
|
269
|
+
"""Validate the Paligemma VLM route instead of the text-only chat route."""
|
|
270
|
+
token = str(api_key or "").strip()
|
|
271
|
+
if not token:
|
|
272
|
+
raise OpenAICompatibleAPIError("Informe a API key antes do teste.")
|
|
273
|
+
configured = str(base_url or DEFAULT_NVIDIA_NIM_BASE_URL).rstrip("/")
|
|
274
|
+
if configured.endswith("/chat/completions"):
|
|
275
|
+
configured = configured.removesuffix("/chat/completions")
|
|
276
|
+
if "integrate.api.nvidia.com" in configured:
|
|
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
|
+
}
|
|
284
|
+
try:
|
|
285
|
+
response = requests.post(
|
|
286
|
+
endpoint,
|
|
287
|
+
headers={"Accept": "application/json", "Authorization": f"Bearer {token}", "Content-Type": "application/json"},
|
|
288
|
+
json=payload,
|
|
289
|
+
timeout=timeout,
|
|
290
|
+
)
|
|
291
|
+
except requests.RequestException as exc:
|
|
292
|
+
raise OpenAICompatibleAPIError(f"Não foi possível testar o endpoint Paligemma: {exc}") from exc
|
|
293
|
+
if response.status_code >= 400:
|
|
294
|
+
if response.status_code in (401, 403):
|
|
295
|
+
raise OpenAICompatibleAPIError(f"O endpoint Paligemma recusou a API key (HTTP {response.status_code}).")
|
|
296
|
+
raise OpenAICompatibleAPIError(f"O endpoint Paligemma devolveu HTTP {response.status_code}.")
|
package/package.json
CHANGED