@danhachuel/thunderbolt 0.6.84 → 0.6.86
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/influencers_ui.py +28 -5
- package/app/main.py +38 -1
- package/hermes_ui/domain.py +49 -0
- package/package.json +1 -1
package/app/influencers_ui.py
CHANGED
|
@@ -115,6 +115,19 @@ def _provider_label(card: Mapping[str, Any]) -> str:
|
|
|
115
115
|
return f"{definition.label} · {model}"
|
|
116
116
|
|
|
117
117
|
|
|
118
|
+
def _ugc_duration_seconds(value: str) -> int:
|
|
119
|
+
"""Parse the UGC duration field as minutes:seconds with a safe default."""
|
|
120
|
+
try:
|
|
121
|
+
minutes_text, seconds_text = str(value or "1:20").strip().split(":", 1)
|
|
122
|
+
minutes = max(0, int(minutes_text))
|
|
123
|
+
seconds = int(seconds_text)
|
|
124
|
+
if 0 <= seconds < 60:
|
|
125
|
+
return max(1, min(3600, minutes * 60 + seconds))
|
|
126
|
+
except (TypeError, ValueError):
|
|
127
|
+
pass
|
|
128
|
+
return 80
|
|
129
|
+
|
|
130
|
+
|
|
118
131
|
def _content_metadata(item: Mapping[str, Any]) -> dict[str, Any]:
|
|
119
132
|
raw = item.get("metadata") if isinstance(item.get("metadata"), Mapping) else item.get("metadata_json")
|
|
120
133
|
if isinstance(raw, Mapping):
|
|
@@ -486,16 +499,26 @@ def render_ugc_products(settings: dict[str, Any]) -> None:
|
|
|
486
499
|
key="ugc_products_inputs",
|
|
487
500
|
help="Anexe uma ou mais referências do produto. Para geração, a primeira imagem será usada como referência visual principal.",
|
|
488
501
|
)
|
|
489
|
-
|
|
490
|
-
|
|
502
|
+
generation_col, duration_col = st.columns([2, 1])
|
|
503
|
+
with generation_col:
|
|
504
|
+
generation_mode = st.selectbox("Tipo de geração", ["Gerar Foto", "Gerar Video"], key="ugc_products_generation_mode")
|
|
505
|
+
duration_text = "1:20"
|
|
506
|
+
if generation_mode == "Gerar Video":
|
|
507
|
+
with duration_col:
|
|
508
|
+
duration_text = st.text_input("Duração de cada clip (MM:SS)", value="1:20", max_chars=5, key="ugc_products_duration_text", width=120)
|
|
509
|
+
duration = _ugc_duration_seconds(duration_text)
|
|
491
510
|
image_cards, image_options = _provider_options(settings, "image")
|
|
492
511
|
video_cards = _workflow_provider_cards(settings, provider=None)
|
|
493
512
|
video_options = [str(card.get("id") or "") for card in video_cards]
|
|
494
|
-
image_provider_id =
|
|
495
|
-
video_provider_id =
|
|
513
|
+
image_provider_id = ""
|
|
514
|
+
video_provider_id = ""
|
|
515
|
+
if generation_mode == "Gerar Foto":
|
|
516
|
+
image_provider_id = st.selectbox("Provider / modelo de imagem", image_options, format_func=lambda value: _provider_label(next(card for card in image_cards if str(card.get("id")) == value)), key="ugc_products_image_provider") if image_cards else ""
|
|
517
|
+
else:
|
|
518
|
+
video_provider_id = st.selectbox("Provider / modelo de vídeo", video_options, format_func=lambda value: _provider_label(next(card for card in video_cards if str(card.get("id")) == value)), key="ugc_products_video_provider") if video_cards else ""
|
|
496
519
|
script = st.text_area("Roteiro de vídeo (UGC)", height=150, key="ugc_products_script", placeholder="O roteiro gerado pela IA aparecerá aqui; também pode editá-lo antes de gerar.")
|
|
497
520
|
generate_script = st.button("Gerar roteiro com IA", use_container_width=True, key="ugc_products_generate_script")
|
|
498
|
-
generate = st.button("Gerar
|
|
521
|
+
generate = st.button("Gerar Mídia (Foto/Vídeo)", type="primary", use_container_width=True, key="ugc_products_generate")
|
|
499
522
|
if generate_script:
|
|
500
523
|
context = "\n".join(
|
|
501
524
|
item for item in [
|
package/app/main.py
CHANGED
|
@@ -77,7 +77,7 @@ def display_version(version: str) -> str:
|
|
|
77
77
|
|
|
78
78
|
APP_VERSION_LABEL = display_version(APP_VERSION)
|
|
79
79
|
|
|
80
|
-
from hermes_ui.domain import STAGES, create_batch, create_channel, create_tasks_for_batch, delete_channel, delete_task, pipeline_summary, retry_task_with_current_settings, set_channel_defaults, stop_task_by_user, transition_task, update_channel, update_channel_video
|
|
80
|
+
from hermes_ui.domain import STAGES, create_batch, create_channel, create_tasks_for_batch, delete_channel, delete_task, pipeline_summary, remake_video_task, retry_task_with_current_settings, set_channel_defaults, stop_task_by_user, transition_task, update_channel, update_channel_video
|
|
81
81
|
from hermes_ui.channel_import import build_channel_template_xlsx, channel_is_duplicate, find_duplicate_channel, parse_channel_workbook, resolve_blueprint, resolve_google_account, resolve_voice
|
|
82
82
|
from hermes_ui.drafts import list_drafts, save_draft
|
|
83
83
|
from hermes_ui.automation_worker import load_worker_status
|
|
@@ -5057,6 +5057,21 @@ def _start_pipeline_task(task_id: str, state: str) -> bool:
|
|
|
5057
5057
|
return True
|
|
5058
5058
|
|
|
5059
5059
|
|
|
5060
|
+
def _remake_video_from_card(task: dict[str, Any]) -> bool:
|
|
5061
|
+
"""Queue a new render while keeping the script and all creative artefacts."""
|
|
5062
|
+
task_id = str(task.get("id") or "")
|
|
5063
|
+
try:
|
|
5064
|
+
updated = remake_video_task(task_id)
|
|
5065
|
+
except ValueError as exc:
|
|
5066
|
+
st.error(str(exc))
|
|
5067
|
+
return False
|
|
5068
|
+
if not updated:
|
|
5069
|
+
st.error("Não foi possível refazer este vídeo: a tarefa já não existe na fila.")
|
|
5070
|
+
return False
|
|
5071
|
+
st.success("Vídeo colocado na fila para remontagem. Roteiro, tags, voz, thumbnail e artefactos existentes foram preservados.")
|
|
5072
|
+
return True
|
|
5073
|
+
|
|
5074
|
+
|
|
5060
5075
|
def render_videos():
|
|
5061
5076
|
st.subheader("Backlog Videos")
|
|
5062
5077
|
st.caption("Acompanhamento dos vídeos criados, estados da pipeline e controlos de execução.")
|
|
@@ -5597,6 +5612,17 @@ def _render_tiktok_automation_cards():
|
|
|
5597
5612
|
use_container_width=True,
|
|
5598
5613
|
disabled=video_path is None,
|
|
5599
5614
|
)
|
|
5615
|
+
if st.button(
|
|
5616
|
+
"Refazer Vídeo",
|
|
5617
|
+
key=f"tiktok_automation_remake_video_{task_id}",
|
|
5618
|
+
icon=":material/refresh:",
|
|
5619
|
+
type="primary",
|
|
5620
|
+
use_container_width=True,
|
|
5621
|
+
disabled=state == "doing",
|
|
5622
|
+
help="Remonta apenas o vídeo, mantendo o mesmo roteiro, Blueprint/Prompt Master, tags, thumbnail, voz e artefactos já baixados.",
|
|
5623
|
+
):
|
|
5624
|
+
if _remake_video_from_card(task):
|
|
5625
|
+
st.rerun()
|
|
5600
5626
|
with delete_col:
|
|
5601
5627
|
confirm_delete_key = f"tiktok_automation_confirm_delete_{task_id}"
|
|
5602
5628
|
if st.button("Apagar", key=f"tiktok_automation_delete_{task_id}", use_container_width=True, disabled=state == "doing"):
|
|
@@ -5769,6 +5795,17 @@ def _render_youtube_automation_cards():
|
|
|
5769
5795
|
use_container_width=True,
|
|
5770
5796
|
disabled=video_path is None,
|
|
5771
5797
|
)
|
|
5798
|
+
if st.button(
|
|
5799
|
+
"Refazer Vídeo",
|
|
5800
|
+
key=f"automation_remake_video_{task['id']}",
|
|
5801
|
+
icon=":material/refresh:",
|
|
5802
|
+
type="primary",
|
|
5803
|
+
use_container_width=True,
|
|
5804
|
+
disabled=state == "doing",
|
|
5805
|
+
help="Remonta apenas o vídeo, mantendo o mesmo roteiro, Blueprint/Prompt Master, tags, thumbnail, voz e artefactos já baixados.",
|
|
5806
|
+
):
|
|
5807
|
+
if _remake_video_from_card(task):
|
|
5808
|
+
st.rerun()
|
|
5772
5809
|
with delete_col:
|
|
5773
5810
|
confirm_delete_key = f"automation_confirm_delete_{task['id']}"
|
|
5774
5811
|
if st.button("Apagar", key=f"automation_delete_{task['id']}", use_container_width=True, disabled=state == "doing"):
|
package/hermes_ui/domain.py
CHANGED
|
@@ -470,6 +470,55 @@ def retry_task_with_current_settings(task_id: str) -> dict[str, Any] | None:
|
|
|
470
470
|
return update_json("tasks.json", [], mutate)
|
|
471
471
|
|
|
472
472
|
|
|
473
|
+
def remake_video_task(task_id: str) -> dict[str, Any] | None:
|
|
474
|
+
"""Queue a fresh video render while retaining the task's creative inputs.
|
|
475
|
+
|
|
476
|
+
The persisted script, blueprint, keywords/tags, voice, thumbnail prompt/image,
|
|
477
|
+
generation settings and any non-video media artefacts are intentionally kept.
|
|
478
|
+
Only the rendered video and publication result are invalidated so the worker
|
|
479
|
+
rebuilds the video instead of regenerating the creative brief.
|
|
480
|
+
"""
|
|
481
|
+
normalized_id = str(task_id or "").strip()
|
|
482
|
+
|
|
483
|
+
def mutate(tasks: Any) -> dict[str, Any] | None:
|
|
484
|
+
if not isinstance(tasks, list):
|
|
485
|
+
raise StorageIntegrityError("O ficheiro tasks.json não contém uma lista válida.")
|
|
486
|
+
for task in tasks:
|
|
487
|
+
if not isinstance(task, dict) or str(task.get("id") or "") != normalized_id:
|
|
488
|
+
continue
|
|
489
|
+
if str(task.get("state") or "") == "doing":
|
|
490
|
+
raise ValueError("Pare a tarefa antes de refazer o vídeo.")
|
|
491
|
+
artifacts = dict(task.get("artifacts") or {})
|
|
492
|
+
artifacts.pop("video", None)
|
|
493
|
+
artifacts.pop("upload", None)
|
|
494
|
+
try:
|
|
495
|
+
remake_count = int(task.get("remake_count") or 0)
|
|
496
|
+
except (TypeError, ValueError):
|
|
497
|
+
remake_count = 0
|
|
498
|
+
for field in ("video_log", "video_result", "video_helper_status", "video_elapsed_seconds", "error"):
|
|
499
|
+
task.pop(field, None)
|
|
500
|
+
task.update({
|
|
501
|
+
"artifacts": artifacts,
|
|
502
|
+
"stage": "video",
|
|
503
|
+
"state": "to_do",
|
|
504
|
+
"progress": 50,
|
|
505
|
+
"video_ready": False,
|
|
506
|
+
"remake_requested_at": now(),
|
|
507
|
+
"remake_count": remake_count + 1,
|
|
508
|
+
"error": None,
|
|
509
|
+
"updated_at": now(),
|
|
510
|
+
})
|
|
511
|
+
orchestration = dict(task.get("orchestration") or {})
|
|
512
|
+
orchestration["current_stage"] = "video"
|
|
513
|
+
orchestration["resumable"] = True
|
|
514
|
+
orchestration["last_transition_at"] = now()
|
|
515
|
+
task["orchestration"] = orchestration
|
|
516
|
+
return task
|
|
517
|
+
return None
|
|
518
|
+
|
|
519
|
+
return update_json("tasks.json", [], mutate)
|
|
520
|
+
|
|
521
|
+
|
|
473
522
|
def pipeline_summary() -> dict[str, Any]:
|
|
474
523
|
tasks = read_json("tasks.json", [])
|
|
475
524
|
channels = read_json("channels.json", [])
|
package/package.json
CHANGED