Spaces:
Sleeping
Sleeping
File size: 2,278 Bytes
eda316b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | """Load Jinja2 prompt templates (editable; override dir via HUMEO_PROMPTS_DIR)."""
from __future__ import annotations
import os
from pathlib import Path
import jinja2
def _prompt_loader() -> jinja2.BaseLoader:
override = (os.environ.get("HUMEO_PROMPTS_DIR") or "").strip()
if override:
return jinja2.FileSystemLoader(str(Path(override).expanduser()))
return jinja2.PackageLoader("humeo", "prompts")
def clip_selection_prompts(
*,
transcript_text: str,
min_dur: float,
max_dur: float,
count: int,
steering_notes: list[str] | None = None,
hook_examples: str = "",
) -> tuple[str, str]:
"""Return ``(system_instruction, user_message)`` for Gemini clip selection."""
env = jinja2.Environment(loader=_prompt_loader(), autoescape=False, trim_blocks=True)
ctx = {
"min_dur": min_dur,
"max_dur": max_dur,
"count": count,
"transcript_text": transcript_text,
"steering_notes": steering_notes or [],
"hook_examples": hook_examples,
}
system = env.get_template("clip_selection_system.jinja2").render(**ctx)
user = env.get_template("clip_selection_user.jinja2").render(**ctx)
return system, user
def hook_detection_system_prompt(*, hook_examples: str = "") -> str:
"""Return the system prompt for Stage 2.25 hook detection.
The user message is built in :mod:`humeo.hook_detector` because the
segment listing is dynamic per-clip.
"""
env = jinja2.Environment(loader=_prompt_loader(), autoescape=False, trim_blocks=True)
return env.get_template("hook_detection_system.jinja2").render(hook_examples=hook_examples)
def content_pruning_system_prompt(
*,
min_dur: float,
max_dur: float,
level: str,
) -> str:
"""Return the system prompt for Stage 2.5 content pruning.
The user message is built in ``humeo.content_pruning`` from the list of
candidate clips (clip-relative segment lines) since it is not static text.
"""
env = jinja2.Environment(loader=_prompt_loader(), autoescape=False, trim_blocks=True)
return env.get_template("content_pruning_system.jinja2").render(
min_dur=min_dur, max_dur=max_dur, level=level
)
|