@danhachuel/thunderbolt 0.5.33 → 0.5.35
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
|
@@ -7103,6 +7103,9 @@ def _persist_media_cards(settings: dict[str, Any], cards: list[dict[str, Any]],
|
|
|
7103
7103
|
def _fetch_media_models(card: dict[str, Any]) -> list[str]:
|
|
7104
7104
|
"""Consultar modelos do provider, incluindo o catálogo nativo Gemini."""
|
|
7105
7105
|
provider = str(card.get("provider") or "").strip().lower()
|
|
7106
|
+
if provider == "replicate":
|
|
7107
|
+
from integrations.openai_model_discovery import fetch_replicate_models
|
|
7108
|
+
return fetch_replicate_models(str(card.get("api_key") or ""), str(card.get("base_url") or ""))
|
|
7106
7109
|
if provider == "kie_ai":
|
|
7107
7110
|
return list(KIE_MEDIA_MODEL_CATALOG)
|
|
7108
7111
|
if provider == "fal_ai":
|
|
@@ -8641,7 +8644,7 @@ def main():
|
|
|
8641
8644
|
"Início": render_dashboard,
|
|
8642
8645
|
"Pipeline Vídeos": render_pipeline,
|
|
8643
8646
|
"Criação de Vídeos": render_new_video,
|
|
8644
|
-
"Criação de Shorts": lambda: render_new_video("Criação de Shorts", "new_shorts", channel_platform="
|
|
8647
|
+
"Criação de Shorts": lambda: render_new_video("Criação de Shorts", "new_shorts", channel_platform="youtube", fixed_aspect_ratio="Portrait 9:16"),
|
|
8645
8648
|
"Backlog Vídeos": render_videos,
|
|
8646
8649
|
"Criação de Músicas": render_music_creation,
|
|
8647
8650
|
"Music Backlog": render_music_backlog,
|
|
@@ -208,3 +208,53 @@ def fetch_openai_compatible_models(
|
|
|
208
208
|
except ValueError as exc:
|
|
209
209
|
raise ModelDiscoveryError("O endpoint devolveu uma resposta que não é JSON.") from exc
|
|
210
210
|
return normalize_model_ids(payload)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def fetch_replicate_models(
|
|
214
|
+
api_key: str,
|
|
215
|
+
base_url: str,
|
|
216
|
+
*,
|
|
217
|
+
timeout: float = DEFAULT_TIMEOUT_SECONDS,
|
|
218
|
+
) -> list[str]:
|
|
219
|
+
"""Fetch Replicate model slugs with their latest version IDs.
|
|
220
|
+
|
|
221
|
+
Replicate is not OpenAI-compatible: its catalog uses ``results`` rather
|
|
222
|
+
than ``data`` and the latest version ID is required by predictions.
|
|
223
|
+
"""
|
|
224
|
+
token = str(api_key or "").strip()
|
|
225
|
+
if not token:
|
|
226
|
+
raise ModelDiscoveryError("Informe a API key Replicate antes de consultar os modelos.")
|
|
227
|
+
base = _normalise_http_base_url(base_url, error_type=ModelDiscoveryError)
|
|
228
|
+
endpoint = base if base.endswith("/models") else f"{base}/models"
|
|
229
|
+
try:
|
|
230
|
+
response = requests.get(
|
|
231
|
+
endpoint,
|
|
232
|
+
headers={"Accept": "application/json", "Authorization": f"Bearer {token}"},
|
|
233
|
+
timeout=timeout,
|
|
234
|
+
)
|
|
235
|
+
except requests.RequestException as exc:
|
|
236
|
+
raise ModelDiscoveryError(f"Não foi possível consultar {endpoint}: {exc}") from exc
|
|
237
|
+
if response.status_code >= 400:
|
|
238
|
+
if response.status_code in (401, 403):
|
|
239
|
+
raise ModelDiscoveryError(f"O endpoint Replicate recusou a API key (HTTP {response.status_code}).")
|
|
240
|
+
raise ModelDiscoveryError(f"O endpoint Replicate devolveu HTTP {response.status_code}.")
|
|
241
|
+
try:
|
|
242
|
+
payload = response.json()
|
|
243
|
+
except ValueError as exc:
|
|
244
|
+
raise ModelDiscoveryError("O endpoint Replicate devolveu uma resposta que não é JSON.") from exc
|
|
245
|
+
entries = payload.get("results") if isinstance(payload, dict) else None
|
|
246
|
+
if not isinstance(entries, list):
|
|
247
|
+
raise ModelDiscoveryError("A resposta Replicate não tem uma lista results válida.")
|
|
248
|
+
models: set[str] = set()
|
|
249
|
+
for item in entries:
|
|
250
|
+
if not isinstance(item, dict):
|
|
251
|
+
continue
|
|
252
|
+
owner = str(item.get("owner") or "").strip()
|
|
253
|
+
name = str(item.get("name") or "").strip()
|
|
254
|
+
latest = item.get("latest_version")
|
|
255
|
+
version = str(latest.get("id") or "").strip() if isinstance(latest, dict) else ""
|
|
256
|
+
if owner and name and version:
|
|
257
|
+
models.add(f"{owner}/{name}:{version}")
|
|
258
|
+
if not models:
|
|
259
|
+
raise ModelDiscoveryError("O endpoint Replicate não devolveu modelos com versão disponível.")
|
|
260
|
+
return sorted(models, key=str.casefold)[:MAX_MODEL_IDS]
|
package/package.json
CHANGED