fixx error
Browse files
app.py
CHANGED
|
@@ -228,6 +228,14 @@ def generate_caption_and_hashtags(niche: str, persona: str, trend_label: str) ->
|
|
| 228 |
"""
|
| 229 |
Generate a posting-ready caption, hashtags, and a tiny posting tip
|
| 230 |
based on niche + persona + trend theme.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
"""
|
| 232 |
persona_instruction = get_persona_instruction(persona)
|
| 233 |
|
|
@@ -287,12 +295,12 @@ def generate_quote_tool(niche: str, style: str, persona: str) -> str:
|
|
| 287 |
and persona-aware tone.
|
| 288 |
|
| 289 |
Args:
|
| 290 |
-
niche: High-level niche/category (e.g. Motivation, Fitness, Mindfulness).
|
| 291 |
-
style: Visual style (e.g. Cinematic, Nature, Urban, Minimal, Abstract).
|
| 292 |
-
persona: Voice persona
|
| 293 |
|
| 294 |
Returns:
|
| 295 |
-
A unique quote string generated by the hybrid Gemini/OpenAI system.
|
| 296 |
"""
|
| 297 |
persona_instruction = get_persona_instruction(persona)
|
| 298 |
combined_style = f"{style} | persona={persona} | tone={persona_instruction}"
|
|
@@ -325,6 +333,20 @@ def search_pexels_video_tool(style: str, niche: str, trend_label: str = "") -> d
|
|
| 325 |
"""
|
| 326 |
Search and fetch a matching vertical video from Pexels based on style, niche,
|
| 327 |
and the current trend label.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
"""
|
| 329 |
base_queries = {
|
| 330 |
"Motivation": {
|
|
@@ -446,7 +468,22 @@ def create_quote_video_tool(
|
|
| 446 |
text_style: str = "classic_center",
|
| 447 |
) -> dict:
|
| 448 |
"""
|
| 449 |
-
Create the final quote video via the Modal web endpoint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
"""
|
| 451 |
if not MODAL_ENDPOINT_URL:
|
| 452 |
return {
|
|
@@ -652,8 +689,18 @@ def mcp_agent_pipeline(
|
|
| 652 |
num_variations: int = 1,
|
| 653 |
) -> Tuple[str, List[str], str]:
|
| 654 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 655 |
Returns:
|
| 656 |
-
|
| 657 |
"""
|
| 658 |
status_log: List[str] = []
|
| 659 |
status_log.append("π€ **MCP-STYLE AGENT PIPELINE START**\n")
|
|
@@ -785,7 +832,6 @@ def mcp_agent_pipeline(
|
|
| 785 |
if mcp_enabled:
|
| 786 |
status_log.append(" β’ MCP server β available for extended tools")
|
| 787 |
|
| 788 |
-
# Step 6 β Caption + hashtags block (returned separately for the UI)
|
| 789 |
status_log.append(
|
| 790 |
"\nπ **Step 6 β Caption + Hashtags** (see the panel next to your videos to copy-paste)"
|
| 791 |
)
|
|
@@ -1021,4 +1067,4 @@ with gr.Blocks(
|
|
| 1021 |
)
|
| 1022 |
|
| 1023 |
if __name__ == "__main__":
|
| 1024 |
-
demo.launch(allowed_paths=["/data/gallery_videos"])
|
|
|
|
| 228 |
"""
|
| 229 |
Generate a posting-ready caption, hashtags, and a tiny posting tip
|
| 230 |
based on niche + persona + trend theme.
|
| 231 |
+
|
| 232 |
+
Args:
|
| 233 |
+
niche (str): Selected content niche (e.g. Motivation, Fitness).
|
| 234 |
+
persona (str): Selected persona (Coach, Philosopher, etc.).
|
| 235 |
+
trend_label (str): Short label describing the current trend theme.
|
| 236 |
+
|
| 237 |
+
Returns:
|
| 238 |
+
str: Formatted block containing caption, hashtags, and posting tip.
|
| 239 |
"""
|
| 240 |
persona_instruction = get_persona_instruction(persona)
|
| 241 |
|
|
|
|
| 295 |
and persona-aware tone.
|
| 296 |
|
| 297 |
Args:
|
| 298 |
+
niche (str): High-level niche/category (e.g. Motivation, Fitness, Mindfulness).
|
| 299 |
+
style (str): Visual style for the video (e.g. Cinematic, Nature, Urban, Minimal, Abstract).
|
| 300 |
+
persona (str): Voice persona that influences the quote tone (Coach, Philosopher, Poet, Mentor).
|
| 301 |
|
| 302 |
Returns:
|
| 303 |
+
str: A unique quote string generated by the hybrid Gemini/OpenAI system.
|
| 304 |
"""
|
| 305 |
persona_instruction = get_persona_instruction(persona)
|
| 306 |
combined_style = f"{style} | persona={persona} | tone={persona_instruction}"
|
|
|
|
| 333 |
"""
|
| 334 |
Search and fetch a matching vertical video from Pexels based on style, niche,
|
| 335 |
and the current trend label.
|
| 336 |
+
|
| 337 |
+
Args:
|
| 338 |
+
style (str): Visual style for the background footage (e.g. Cinematic, Nature).
|
| 339 |
+
niche (str): Selected niche (Motivation, Business/Entrepreneurship, etc.).
|
| 340 |
+
trend_label (str): Optional label describing the current trend theme, used
|
| 341 |
+
to slightly bias search queries (e.g. "soft life", "discipline era").
|
| 342 |
+
|
| 343 |
+
Returns:
|
| 344 |
+
dict: A dictionary with:
|
| 345 |
+
- success (bool): Whether a suitable video was found.
|
| 346 |
+
- video_url (str or None): Direct URL to the chosen video file.
|
| 347 |
+
- search_query (str): The Pexels search query used.
|
| 348 |
+
- pexels_url (str or None): Public Pexels page for the chosen video.
|
| 349 |
+
- error (str, optional): Error message if success is False.
|
| 350 |
"""
|
| 351 |
base_queries = {
|
| 352 |
"Motivation": {
|
|
|
|
| 468 |
text_style: str = "classic_center",
|
| 469 |
) -> dict:
|
| 470 |
"""
|
| 471 |
+
Create the final quote video via the Modal web endpoint, overlaying the quote
|
| 472 |
+
and optionally adding an audio track.
|
| 473 |
+
|
| 474 |
+
Args:
|
| 475 |
+
video_url (str): Direct URL to the background video file (from Pexels).
|
| 476 |
+
quote_text (str): The quote text to render as an overlay on the video.
|
| 477 |
+
output_path (str): Local filesystem path where the rendered video will be saved.
|
| 478 |
+
audio_b64 (str): Optional base64-encoded audio bytes for narration (ElevenLabs).
|
| 479 |
+
text_style (str): Text layout style identifier (e.g. 'classic_center',
|
| 480 |
+
'lower_third_serif', 'typewriter_top') that the Modal worker can interpret.
|
| 481 |
+
|
| 482 |
+
Returns:
|
| 483 |
+
dict: A dictionary with:
|
| 484 |
+
- success (bool): Whether the video was rendered successfully.
|
| 485 |
+
- output_path (str or None): Path to the saved MP4 file if successful.
|
| 486 |
+
- message (str): Human-readable status or error description.
|
| 487 |
"""
|
| 488 |
if not MODAL_ENDPOINT_URL:
|
| 489 |
return {
|
|
|
|
| 689 |
num_variations: int = 1,
|
| 690 |
) -> Tuple[str, List[str], str]:
|
| 691 |
"""
|
| 692 |
+
Run the full quote video pipeline: context fusion, quote, voice, video, caption.
|
| 693 |
+
|
| 694 |
+
Args:
|
| 695 |
+
niche (str): Selected content niche.
|
| 696 |
+
style (str): Visual style for video footage.
|
| 697 |
+
persona (str): Persona controlling tone.
|
| 698 |
+
text_style (str): Layout style for text overlay.
|
| 699 |
+
voice_profile (str): Chosen ElevenLabs voice profile.
|
| 700 |
+
num_variations (int): Number of video variants to generate.
|
| 701 |
+
|
| 702 |
Returns:
|
| 703 |
+
Tuple[str, List[str], str]: (status_log, list of video paths, caption_block).
|
| 704 |
"""
|
| 705 |
status_log: List[str] = []
|
| 706 |
status_log.append("π€ **MCP-STYLE AGENT PIPELINE START**\n")
|
|
|
|
| 832 |
if mcp_enabled:
|
| 833 |
status_log.append(" β’ MCP server β available for extended tools")
|
| 834 |
|
|
|
|
| 835 |
status_log.append(
|
| 836 |
"\nπ **Step 6 β Caption + Hashtags** (see the panel next to your videos to copy-paste)"
|
| 837 |
)
|
|
|
|
| 1067 |
)
|
| 1068 |
|
| 1069 |
if __name__ == "__main__":
|
| 1070 |
+
demo.launch(allowed_paths=["/data/gallery_videos"])
|