@danhachuel/thunderbolt 0.5.38 → 0.5.39

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.
@@ -83,6 +83,7 @@ def format_media_generation_error(exc: MediaGenerationError, *, operation: str =
83
83
 
84
84
  AGNES_IMAGE_MODEL = "agnes-image-2.1-flash"
85
85
  AGNES_IMAGE_TIMEOUT_SECONDS = 120
86
+ AGNES_MAX_PROMPT_CHARS = 9500
86
87
 
87
88
 
88
89
  def _api_key(card: Mapping[str, Any]) -> str:
@@ -109,6 +110,17 @@ def _headers(card: Mapping[str, Any], *, fal: bool = False) -> dict[str, str]:
109
110
  return headers
110
111
 
111
112
 
113
+ def _fit_provider_prompt(prompt: str, provider: str) -> str:
114
+ """Keep provider-specific prompt limits from turning a thumbnail into a 400."""
115
+ text = str(prompt or "").strip()
116
+ if provider != "agnes" or len(text) <= AGNES_MAX_PROMPT_CHARS:
117
+ return text
118
+ # Keep both the visual brief and the mandatory lettering layer at the end.
119
+ tail_size = min(1800, AGNES_MAX_PROMPT_CHARS // 4)
120
+ head_size = AGNES_MAX_PROMPT_CHARS - tail_size - 80
121
+ return f"{text[:head_size].rstrip()}\n\n[Prompt longo resumido para o limite Agnes AI.]\n\n{text[-tail_size:].lstrip()}"
122
+
123
+
112
124
  def _append_generation_constraints(
113
125
  prompt: str,
114
126
  *,
@@ -298,6 +310,7 @@ def _image_request(card: dict[str, Any], prompt: str, *, topic: str = "", letter
298
310
  aspect_ratio="16:9",
299
311
  size=requested_size,
300
312
  )
313
+ constrained_prompt = _fit_provider_prompt(constrained_prompt, provider)
301
314
  if style == "cloudflare":
302
315
  return requests.post(endpoint, headers=_headers(card), json={"prompt": constrained_prompt}, timeout=180)
303
316
  if style == "fal_queue":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.5.38",
3
+ "version": "0.5.39",
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",