@danhachuel/thunderbolt 0.4.40 → 0.4.42

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.
@@ -44,6 +44,14 @@ from .thumbnail_generation import _compose_thumbnail_prompt, generate_thumbnail_
44
44
  class MediaGenerationError(RuntimeError):
45
45
  """Raised when an image/video adapter cannot produce a usable artifact."""
46
46
 
47
+ def __init__(self, message: str, *, provider_errors: list[str] | None = None) -> None:
48
+ super().__init__(message)
49
+ self.provider_errors = list(provider_errors or [])
50
+
51
+
52
+ AGNES_IMAGE_MODEL = "agnes-image-2.1-flash"
53
+ AGNES_IMAGE_TIMEOUT_SECONDS = 120
54
+
47
55
 
48
56
  def _api_key(card: Mapping[str, Any]) -> str:
49
57
  return str(card.get("api_key") or "").strip()
@@ -259,6 +267,16 @@ def _image_request(card: dict[str, Any], prompt: str, *, topic: str = "", letter
259
267
  if style == "replicate":
260
268
  body = {"version": _model(card), "input": {"prompt": constrained_prompt}}
261
269
  return requests.post(endpoint, headers=_headers(card), json=body, timeout=180)
270
+ if provider == "agnes":
271
+ body = {
272
+ "model": _model(card) or AGNES_IMAGE_MODEL,
273
+ "prompt": constrained_prompt,
274
+ "size": "1K",
275
+ "ratio": "16:9",
276
+ "return_base64": True,
277
+ "extra_body": {"response_format": "b64_json"},
278
+ }
279
+ return requests.post(endpoint, headers=_headers(card), json=body, timeout=AGNES_IMAGE_TIMEOUT_SECONDS)
262
280
  body = {"model": _model(card), "prompt": constrained_prompt, "n": 1, "response_format": "b64_json"}
263
281
  if provider == "pollinations":
264
282
  body["size"] = "1792x1024"
@@ -360,7 +378,11 @@ def generate_image_from_pool(
360
378
  errors.append(f"{card.get('provider')}: {str(exc)[:180]}")
361
379
  if not _is_retryable_media_error(exc):
362
380
  raise
363
- raise MediaGenerationError("Todos os providers do pool de imagem falharam: " + " | ".join(errors))
381
+ details = "\n".join(f"- {item}" for item in errors) if errors else "- Nenhum detalhe foi devolvido pelos providers."
382
+ raise MediaGenerationError(
383
+ "Todos os providers do pool de imagem falharam. Tentativas realizadas:\n" + details,
384
+ provider_errors=errors,
385
+ )
364
386
 
365
387
 
366
388
  def _video_endpoint(card: Mapping[str, Any]) -> str:
@@ -228,7 +228,7 @@ def new_media_card(provider: Any, *, card_id: str | None = None) -> dict[str, An
228
228
  {
229
229
  "id": card_id or f"media-{code}-1",
230
230
  "provider": code,
231
- "model": "gemini-3.1-flash-image" if code == "nano_banana" else "",
231
+ "model": "gemini-3.1-flash-image" if code == "nano_banana" else ("agnes-image-2.1-flash" if code == "agnes" else ""),
232
232
  "base_url": definition.default_base_url,
233
233
  "enabled": True,
234
234
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.4.40",
3
+ "version": "0.4.42",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",