Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,6 +100,35 @@ HOOK_OPTIONS = [
|
|
| 100 |
|
| 101 |
DEFAULT_HOOK_OPTION = "Auto β choose the strongest opening"
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
# The three minimum values add up to exactly 2,900 words.
|
| 104 |
# The maximum values add up to exactly 3,200 words.
|
| 105 |
CHUNK_SPECS = [
|
|
@@ -230,6 +259,124 @@ def resolve_news_balance(option: str) -> dict:
|
|
| 230 |
)
|
| 231 |
|
| 232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
def build_hook_requirements(hook_option: str) -> str:
|
| 234 |
if hook_option == "Topography / geography opening":
|
| 235 |
return """
|
|
@@ -369,6 +516,7 @@ def story_requirement_warnings(
|
|
| 369 |
cutoff_date: date,
|
| 370 |
current_date: date,
|
| 371 |
news_balance_option: str,
|
|
|
|
| 372 |
) -> list[str]:
|
| 373 |
warnings = []
|
| 374 |
|
|
@@ -403,6 +551,22 @@ def story_requirement_warnings(
|
|
| 403 |
f"subscribe appears {subscribe_mentions}x instead of 2x"
|
| 404 |
)
|
| 405 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
if len(old_years) > MAX_OLD_YEAR_MENTIONS:
|
| 407 |
unique_old_years = sorted(set(old_years))
|
| 408 |
|
|
@@ -437,21 +601,38 @@ def build_global_writing_requirements(
|
|
| 437 |
current_date: date,
|
| 438 |
news_balance_option: str,
|
| 439 |
hook_option: str,
|
|
|
|
| 440 |
) -> str:
|
| 441 |
balance = resolve_news_balance(news_balance_option)
|
| 442 |
hook_requirements = build_hook_requirements(hook_option)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
|
| 444 |
return f"""
|
| 445 |
Write for a high-retention science and geography documentary with a selective current-news
|
| 446 |
layer. The narration must feel human-written, purposeful, conversational, and factual.
|
| 447 |
-
Preserve the existing direct Discover Tube writing style; change the balance of
|
| 448 |
-
not the voice.
|
|
|
|
|
|
|
| 449 |
|
| 450 |
NEWS BALANCE β {news_balance_option}
|
| 451 |
|
| 452 |
- {balance['description']}
|
| 453 |
- Use recent news as the true narrative anchor in approximately
|
| 454 |
-
{
|
| 455 |
- Across the full narration, recent-event material should occupy
|
| 456 |
{balance['recent_narration_share']} of the script, not the entire script.
|
| 457 |
- Aim for only {balance['date_mentions_min']}β{balance['date_mentions_max']} explicit calendar-
|
|
@@ -459,7 +640,7 @@ NEWS BALANCE β {news_balance_option}
|
|
| 459 |
- Do not mention a publication date merely to prove that a source is recent.
|
| 460 |
- Dates belong in narration only when chronology, escalation, timing, or a specific event
|
| 461 |
genuinely depends on them.
|
| 462 |
-
- It is fine for several paragraphs or complete documentary
|
| 463 |
|
| 464 |
RECENT NEWS WINDOW
|
| 465 |
|
|
@@ -478,12 +659,12 @@ RECENT NEWS WINDOW
|
|
| 478 |
|
| 479 |
DOCUMENTARY DEPTH
|
| 480 |
|
| 481 |
-
- Build one
|
| 482 |
- The non-news portions should add real documentary value: topography, physical geography,
|
| 483 |
mechanisms, geology, hydrology, infrastructure, ecological consequences, regional scale,
|
| 484 |
scientific uncertainty, monitoring methods, or what the evidence means for people.
|
| 485 |
-
- Do not use generic textbook filler. Every paragraph must add a specific fact,
|
| 486 |
-
example, consequence, measurement, research result, or documented uncertainty.
|
| 487 |
- Use named locations, agencies, datasets, projects, researchers, and measurements when they
|
| 488 |
improve clarity, but do not turn the script into a list of source metadata.
|
| 489 |
- Explain why important facts matter and how the mechanism works.
|
|
@@ -493,11 +674,18 @@ DOCUMENTARY DEPTH
|
|
| 493 |
INTRODUCTION β 120β160 WORDS
|
| 494 |
|
| 495 |
- Follow the selected hook strategy below.
|
| 496 |
-
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
- Do not overload the intro with dates. One exact date is enough when the selected hook truly
|
| 502 |
needs it; otherwise use none.
|
| 503 |
- The FINAL sentence of the intro must land strongly in one of two ways:
|
|
@@ -510,33 +698,26 @@ INTRODUCTION β 120β160 WORDS
|
|
| 510 |
|
| 511 |
CENTRAL STORY AND RETENTION
|
| 512 |
|
| 513 |
-
- Every
|
| 514 |
-
|
| 515 |
-
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
|
|
|
| 520 |
- Pay off earlier open loops later in the script so the story feels intentional.
|
| 521 |
- Put the strongest verified material in the first third, whether it is current news,
|
| 522 |
topography, a hard measurement, or an important scientific mechanism.
|
| 523 |
- Keep retention high through information, escalation, contrast, and consequence, not empty
|
| 524 |
mystery language.
|
| 525 |
|
| 526 |
-
UNEQUAL TOPIC LENGTHS
|
| 527 |
-
|
| 528 |
-
- The seven titled sections must not be equal in size.
|
| 529 |
-
- Give the most important or scientifically rich topics substantially more space.
|
| 530 |
-
- Use shorter sections as bridges, reveals, or transitions.
|
| 531 |
-
- The writing plan must assign a distinct word budget to every section.
|
| 532 |
-
- The largest section should be at least 150 words longer than the shortest section.
|
| 533 |
-
|
| 534 |
HUMAN WRITING
|
| 535 |
|
| 536 |
- Use mostly short and medium-length sentences.
|
| 537 |
- Keep most paragraphs between one and four sentences.
|
| 538 |
- Use natural sentence variation and active language.
|
| 539 |
-
- Avoid sounding like a report, literature review,
|
| 540 |
- Introduce researchers through what they did, measured, found, announced, or questioned.
|
| 541 |
- Use concrete nouns instead of vague references when the evidence gives a name.
|
| 542 |
- Do not overuse em dashes, three-part dramatic lists, fragments, or rhetorical questions.
|
|
@@ -548,7 +729,7 @@ COMPARISONS
|
|
| 548 |
|
| 549 |
- Use exactly three factual comparisons in the complete script.
|
| 550 |
- Each comparison must clarify scale, speed, depth, distance, volume, time, or impact.
|
| 551 |
-
- Spread the
|
| 552 |
- Check all units and conversions mathematically.
|
| 553 |
- Do not use additional decorative comparisons beyond those three.
|
| 554 |
|
|
@@ -556,19 +737,17 @@ DISCOVER TUBE AND CTA PLACEMENT
|
|
| 556 |
|
| 557 |
- Use the exact phrase β{CHANNEL_NAME}β exactly four times in the complete script.
|
| 558 |
- Exactly two questions in the complete script may contain β{CHANNEL_NAME}β.
|
| 559 |
-
- Placement 1: once in the introduction, inside the one-sentence channel
|
| 560 |
-
|
| 561 |
- Placement 2: around 40 percent of the video, as one brief subscribe sentence.
|
| 562 |
-
This occurrence is not a question and does not ask for comments.
|
| 563 |
- Placement 3: around 75 percent of the video, inside one topic-specific audience question.
|
| 564 |
-
Do not ask for a subscription
|
| 565 |
- Placement 4: within the final 100 words. Include a brief subscribe request and ask one
|
| 566 |
concrete comment question. The question itself must contain β{CHANNEL_NAME}β.
|
| 567 |
- Do not mention β{CHANNEL_NAME}β anywhere else.
|
| 568 |
- Do not use the word subscribe outside placements 2 and 4.
|
| 569 |
""".strip()
|
| 570 |
|
| 571 |
-
|
| 572 |
# =========================================================
|
| 573 |
# STYLE SAMPLE
|
| 574 |
# =========================================================
|
|
@@ -806,11 +985,24 @@ def research_topic(
|
|
| 806 |
title: str,
|
| 807 |
recency_days: int,
|
| 808 |
news_balance_option: str,
|
|
|
|
| 809 |
) -> str:
|
| 810 |
cutoff_date, current_date = get_news_window(
|
| 811 |
recency_days
|
| 812 |
)
|
| 813 |
balance = resolve_news_balance(news_balance_option)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 814 |
|
| 815 |
prompt = f"""
|
| 816 |
Today's date is {current_date.isoformat()}.
|
|
@@ -828,8 +1020,8 @@ SELECTED NEWS BALANCE
|
|
| 828 |
{balance['description']}
|
| 829 |
|
| 830 |
The final script should use recent news as a genuine anchor in approximately
|
| 831 |
-
{
|
| 832 |
-
|
| 833 |
finished script. The rest may use durable, authoritative documentary context.
|
| 834 |
|
| 835 |
CURRENT NEWS WINDOW
|
|
@@ -861,9 +1053,10 @@ RECENCY VERDICT: SUFFICIENT
|
|
| 861 |
RECENCY VERDICT: INSUFFICIENT
|
| 862 |
|
| 863 |
Return SUFFICIENT when there is enough reliable current material to support the selected news
|
| 864 |
-
balance plus enough authoritative documentary evidence to build
|
| 865 |
-
|
| 866 |
-
|
|
|
|
| 867 |
|
| 868 |
If the verdict is INSUFFICIENT:
|
| 869 |
|
|
@@ -907,27 +1100,32 @@ BUILD THIS EVIDENCE PACK
|
|
| 907 |
6. DOCUMENTARY BACKGROUND LEDGER with 4β10 authoritative sources for durable topography,
|
| 908 |
mechanisms, baseline science, historical context, or regional consequences. Include dates
|
| 909 |
internally, but mark them BACKGROUND and do not imply recency.
|
| 910 |
-
7. FACT BANK
|
|
|
|
| 911 |
BACKGROUND. Include location, source/institution, certainty, and why it matters.
|
| 912 |
-
8.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 913 |
- TOPOGRAPHY / GEOGRAPHY;
|
| 914 |
- DATE / CURRENT EVENT;
|
| 915 |
- NEWS CLIP CONTINUATION;
|
| 916 |
- HARD FACT / SCALE.
|
| 917 |
Also include two strong intro-ending candidates: one central question and one verified hard
|
| 918 |
fact/consequence.
|
| 919 |
-
|
| 920 |
mentioning in narration. Do NOT include dates that add no storytelling value.
|
| 921 |
-
|
| 922 |
competing explanations, and limitations.
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
exactly three.
|
| 927 |
-
|
| 928 |
enough to stay within {MAX_HISTORICAL_CONTEXT_PERCENT} percent of the final script.
|
| 929 |
-
|
| 930 |
-
|
| 931 |
stale filler, or generic textbook language.
|
| 932 |
|
| 933 |
Do not copy source sentences. Do not write dramatic narration. The evidence pack should be
|
|
@@ -1019,8 +1217,48 @@ def create_script_plan(
|
|
| 1019 |
global_requirements: str,
|
| 1020 |
news_balance_option: str,
|
| 1021 |
hook_option: str,
|
|
|
|
| 1022 |
) -> str:
|
| 1023 |
balance = resolve_news_balance(news_balance_option)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1024 |
|
| 1025 |
prompt = f"""
|
| 1026 |
Create a concise but detailed INTERNAL writing plan for this proposed title:
|
|
@@ -1031,92 +1269,92 @@ Create a concise but detailed INTERNAL writing plan for this proposed title:
|
|
| 1031 |
{research}
|
| 1032 |
</evidence_pack>
|
| 1033 |
|
| 1034 |
-
|
| 1035 |
-
|
|
|
|
|
|
|
|
|
|
| 1036 |
|
| 1037 |
CHUNK 1 β 900β1,000 words
|
| 1038 |
- A direct introduction of 120β160 words.
|
| 1039 |
-
- Two titled sections.
|
| 1040 |
- Follow the selected hook: {hook_option}.
|
| 1041 |
-
-
|
| 1042 |
-
|
|
|
|
| 1043 |
|
| 1044 |
CHUNK 2 β 1,000β1,100 words
|
| 1045 |
-
-
|
| 1046 |
-
-
|
| 1047 |
monitoring, and selected current developments.
|
| 1048 |
|
| 1049 |
CHUNK 3 β 1,000β1,100 words
|
| 1050 |
-
-
|
| 1051 |
-
-
|
|
|
|
|
|
|
|
|
|
| 1052 |
|
| 1053 |
-
|
| 1054 |
|
| 1055 |
{global_requirements}
|
| 1056 |
|
| 1057 |
NEWS / DOCUMENTARY ALLOCATION
|
| 1058 |
|
| 1059 |
-
- Mark every
|
| 1060 |
-
- Use NEWS ANCHOR for approximately {
|
| 1061 |
-
|
| 1062 |
-
- Use DOCUMENTARY CORE
|
| 1063 |
-
|
| 1064 |
- Recent-event narration across the whole script should be {balance['recent_narration_share']}.
|
| 1065 |
- Plan only {balance['date_mentions_min']}β{balance['date_mentions_max']} explicit calendar-date
|
| 1066 |
references for the spoken narration. Publication dates can remain internal in the plan.
|
| 1067 |
-
- Never create a standalone
|
| 1068 |
-
- Never create a standalone
|
| 1069 |
developments into the central documentary story.
|
| 1070 |
|
| 1071 |
INTRO PLAN
|
| 1072 |
|
| 1073 |
- State the exact hook mode that chunk 1 will use. If the selected hook is AUTO, choose the
|
| 1074 |
strongest mode from the evidence pack and record the choice.
|
| 1075 |
-
- Plan the first 3β4 sentences
|
| 1076 |
-
- Reserve exactly one sentence for
|
| 1077 |
-
|
| 1078 |
-
|
|
|
|
| 1079 |
- Choose the intro's final sentence type: CENTRAL QUESTION or HARD FACT / CONSEQUENCE.
|
| 1080 |
- Do not automatically choose a question every time.
|
| 1081 |
|
| 1082 |
-
|
| 1083 |
|
| 1084 |
-
-
|
| 1085 |
-
- Do not give neighboring sections similar budgets unless necessary.
|
| 1086 |
-
- Use the largest sections for the most important scientific or geographic material.
|
| 1087 |
-
- Use at least two noticeably short bridge sections.
|
| 1088 |
-
- The largest section must be at least 150 words longer than the shortest.
|
| 1089 |
-
|
| 1090 |
-
FOR EVERY SECTION PROVIDE
|
| 1091 |
-
|
| 1092 |
-
- a short, specific title;
|
| 1093 |
- ROLE: NEWS ANCHOR or DOCUMENTARY CORE;
|
| 1094 |
- its central purpose;
|
| 1095 |
- its exact word budget;
|
| 1096 |
- the exact facts, measurements, people, locations, topography, and mechanisms it uses;
|
| 1097 |
- the scientific explanation or analysis it contains;
|
| 1098 |
- the human or practical consequence;
|
| 1099 |
-
- if
|
| 1100 |
-
- if
|
| 1101 |
-
central story;
|
| 1102 |
- whether an explicit date should actually be spoken aloud;
|
| 1103 |
-
-
|
| 1104 |
- any essential historical context, limited to one or two brief points.
|
| 1105 |
|
| 1106 |
ALLOCATION RULES
|
| 1107 |
|
| 1108 |
-
- Assign every important fact to only one
|
| 1109 |
- Put the strongest verified material in chunk 1, but that material does not have to be news.
|
| 1110 |
- Reserve enough unused evidence for chunks 2 and 3.
|
| 1111 |
-
- Select exactly three verified comparisons and assign each to a different
|
| 1112 |
-
- Assign
|
| 1113 |
-
|
|
|
|
|
|
|
| 1114 |
- Do not create a debunking video. Silently use the strongest accurate angle.
|
| 1115 |
|
| 1116 |
DISCOVER TUBE PLACEMENT PLAN
|
| 1117 |
|
| 1118 |
-
1. Introduction: one
|
| 1119 |
-
|
| 1120 |
2. Around 40 percent: one brief non-question subscribe sentence containing β{CHANNEL_NAME}β.
|
| 1121 |
3. Around 75 percent: one topic-specific audience question containing β{CHANNEL_NAME}β.
|
| 1122 |
4. Final 100 words: one brief subscribe request and one concrete comment question; the question
|
|
@@ -1124,13 +1362,13 @@ DISCOVER TUBE PLACEMENT PLAN
|
|
| 1124 |
|
| 1125 |
Exactly four total mentions of β{CHANNEL_NAME}β and exactly two questions containing it.
|
| 1126 |
|
| 1127 |
-
Keep the complete plan between 1,500 and 2,
|
| 1128 |
Do not write sample narration and do not repeat the entire evidence pack.
|
| 1129 |
This is a plan only.
|
| 1130 |
""".strip()
|
| 1131 |
|
| 1132 |
log(
|
| 1133 |
-
"Phase 2 started: three-part
|
| 1134 |
)
|
| 1135 |
|
| 1136 |
plan, response = request_text(
|
|
@@ -1138,8 +1376,8 @@ This is a plan only.
|
|
| 1138 |
model=model,
|
| 1139 |
system_prompt=(
|
| 1140 |
"You are a senior documentary editor. Build a connected, high-retention plan that "
|
| 1141 |
-
"preserves a strong human writing style
|
| 1142 |
-
"
|
| 1143 |
),
|
| 1144 |
user_prompt=prompt,
|
| 1145 |
max_tokens=PLAN_MAX_TOKENS,
|
|
@@ -1163,7 +1401,6 @@ This is a plan only.
|
|
| 1163 |
|
| 1164 |
return plan
|
| 1165 |
|
| 1166 |
-
|
| 1167 |
# =========================================================
|
| 1168 |
# PHASE 3 β THREE SCRIPT CHUNKS
|
| 1169 |
# =========================================================
|
|
@@ -1224,6 +1461,18 @@ def build_chunk_prompt(
|
|
| 1224 |
maximum = spec["maximum"]
|
| 1225 |
target = spec["target"]
|
| 1226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1227 |
if chunk_number == 1:
|
| 1228 |
continuity_rule = (
|
| 1229 |
"Do not print the video title. Write the 120β160 word introduction according "
|
|
@@ -1263,6 +1512,10 @@ CHUNK PURPOSE
|
|
| 1263 |
|
| 1264 |
{spec['purpose']}
|
| 1265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1266 |
HARD LENGTH REQUIREMENT
|
| 1267 |
|
| 1268 |
- This chunk must contain between {minimum} and {maximum} words.
|
|
@@ -1291,7 +1544,7 @@ NEWS / DOCUMENTARY REQUIREMENTS FOR THIS CHUNK
|
|
| 1291 |
WRITING STANDARD
|
| 1292 |
|
| 1293 |
- {continuity_rule}
|
| 1294 |
-
-
|
| 1295 |
- Every paragraph must add a new fact, example, mechanism, measurement, consequence, event,
|
| 1296 |
research result, analysis, topographic detail, or documented uncertainty.
|
| 1297 |
- Write straight to the point and explain why the information matters.
|
|
@@ -1305,7 +1558,8 @@ WRITING STANDARD
|
|
| 1305 |
- Preserve uncertainty. Do not turn possible, estimated, preliminary, or disputed information
|
| 1306 |
into certainty.
|
| 1307 |
- Do not tell the audience that the proposed title was fact-checked or exaggerated.
|
| 1308 |
-
- Use
|
|
|
|
| 1309 |
- Use only the comparisons assigned to this chunk. The complete script must contain exactly
|
| 1310 |
three factual comparisons in total.
|
| 1311 |
- Do not include sources, URLs, citations, editor notes, camera directions, or B-roll.
|
|
@@ -1328,25 +1582,41 @@ def build_chunk_revision_prompt(
|
|
| 1328 |
cutoff_date: date,
|
| 1329 |
current_date: date,
|
| 1330 |
global_requirements: str,
|
|
|
|
| 1331 |
) -> str:
|
| 1332 |
current_words = count_words(
|
| 1333 |
current_chunk
|
| 1334 |
)
|
| 1335 |
|
|
|
|
|
|
|
| 1336 |
if current_words < minimum:
|
| 1337 |
-
|
| 1338 |
-
f"The chunk is {minimum - current_words} words below the minimum. "
|
| 1339 |
-
"
|
| 1340 |
-
"
|
| 1341 |
-
"
|
| 1342 |
)
|
| 1343 |
-
|
| 1344 |
-
|
| 1345 |
-
f"The chunk is {current_words - maximum} words above the maximum. "
|
| 1346 |
-
"
|
| 1347 |
"phrasing while preserving important science, geography, current anchors, open "
|
| 1348 |
"loops, comparisons, and CTA placement."
|
| 1349 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1350 |
|
| 1351 |
return f"""
|
| 1352 |
Rewrite the COMPLETE chunk below.
|
|
@@ -1387,8 +1657,10 @@ NEWS / DOCUMENTARY BALANCE CHECK
|
|
| 1387 |
- When shortening, remove repetitive chronology and source-date language before removing
|
| 1388 |
important science or geographic detail.
|
| 1389 |
|
| 1390 |
-
Keep the same
|
| 1391 |
-
explanations, analysis, planned comparisons, and content-based cliffhangers.
|
|
|
|
|
|
|
| 1392 |
Keep the narration direct, human, and information-dense. Do not add a new
|
| 1393 |
introduction, sources, citations, or production notes.
|
| 1394 |
|
|
@@ -1412,6 +1684,7 @@ def revise_chunk(
|
|
| 1412 |
cutoff_date: date,
|
| 1413 |
current_date: date,
|
| 1414 |
global_requirements: str,
|
|
|
|
| 1415 |
) -> str:
|
| 1416 |
prompt = build_chunk_revision_prompt(
|
| 1417 |
research=research,
|
|
@@ -1425,6 +1698,7 @@ def revise_chunk(
|
|
| 1425 |
cutoff_date=cutoff_date,
|
| 1426 |
current_date=current_date,
|
| 1427 |
global_requirements=global_requirements,
|
|
|
|
| 1428 |
)
|
| 1429 |
|
| 1430 |
revised, _ = request_text(
|
|
@@ -1539,6 +1813,7 @@ def generate_script(
|
|
| 1539 |
recency_option: str,
|
| 1540 |
news_balance_option: str,
|
| 1541 |
hook_option: str,
|
|
|
|
| 1542 |
):
|
| 1543 |
current_script = ""
|
| 1544 |
|
|
@@ -1566,6 +1841,7 @@ def generate_script(
|
|
| 1566 |
current_date=current_date,
|
| 1567 |
news_balance_option=news_balance_option,
|
| 1568 |
hook_option=hook_option,
|
|
|
|
| 1569 |
)
|
| 1570 |
|
| 1571 |
yield (
|
|
@@ -1580,6 +1856,7 @@ def generate_script(
|
|
| 1580 |
title=clean_title,
|
| 1581 |
recency_days=recency_days,
|
| 1582 |
news_balance_option=news_balance_option,
|
|
|
|
| 1583 |
)
|
| 1584 |
|
| 1585 |
yield (
|
|
@@ -1598,11 +1875,13 @@ def generate_script(
|
|
| 1598 |
global_requirements=global_requirements,
|
| 1599 |
news_balance_option=news_balance_option,
|
| 1600 |
hook_option=hook_option,
|
|
|
|
| 1601 |
)
|
| 1602 |
|
| 1603 |
chunks: list[str] = []
|
|
|
|
| 1604 |
|
| 1605 |
-
for spec in
|
| 1606 |
chunk_number = spec["number"]
|
| 1607 |
previous_script = joined_script(
|
| 1608 |
chunks
|
|
@@ -1636,7 +1915,7 @@ def generate_script(
|
|
| 1636 |
system_prompt=(
|
| 1637 |
"You are an experienced human documentary writer. Write dense, "
|
| 1638 |
"direct, natural spoken English with strong scientific and geographic "
|
| 1639 |
-
"depth, selective current-news material,
|
| 1640 |
"cliffhangers, and high retention. Preserve the requested news balance "
|
| 1641 |
"and do not overuse dates."
|
| 1642 |
),
|
|
@@ -1676,19 +1955,29 @@ def generate_script(
|
|
| 1676 |
)
|
| 1677 |
|
| 1678 |
# Maximum of three targeted correction rounds per chunk.
|
|
|
|
|
|
|
| 1679 |
for correction_attempt in range(3):
|
| 1680 |
-
|
| 1681 |
spec["minimum"]
|
| 1682 |
<= chunk_words
|
| 1683 |
<= spec["maximum"]
|
| 1684 |
-
)
|
|
|
|
|
|
|
| 1685 |
break
|
| 1686 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1687 |
yield (
|
| 1688 |
f"π Part {chunk_number}/3 has "
|
| 1689 |
f"{chunk_words} words; target is "
|
| 1690 |
-
f"{spec['minimum']}β{spec['maximum']}.
|
| 1691 |
-
f"Correction {correction_attempt + 1}/3β¦",
|
| 1692 |
joined_script(
|
| 1693 |
chunks + [chunk_text]
|
| 1694 |
),
|
|
@@ -1708,11 +1997,13 @@ def generate_script(
|
|
| 1708 |
cutoff_date=cutoff_date,
|
| 1709 |
current_date=current_date,
|
| 1710 |
global_requirements=global_requirements,
|
|
|
|
| 1711 |
)
|
| 1712 |
|
| 1713 |
chunk_words = count_words(
|
| 1714 |
chunk_text
|
| 1715 |
)
|
|
|
|
| 1716 |
|
| 1717 |
log(
|
| 1718 |
f"Part {chunk_number} after correction "
|
|
@@ -1779,6 +2070,7 @@ def generate_script(
|
|
| 1779 |
cutoff_date=cutoff_date,
|
| 1780 |
current_date=current_date,
|
| 1781 |
news_balance_option=news_balance_option,
|
|
|
|
| 1782 |
)
|
| 1783 |
|
| 1784 |
window_text = (
|
|
@@ -1955,6 +2247,7 @@ def clear_interface():
|
|
| 1955 |
DEFAULT_RECENCY_OPTION,
|
| 1956 |
DEFAULT_NEWS_BALANCE_OPTION,
|
| 1957 |
DEFAULT_HOOK_OPTION,
|
|
|
|
| 1958 |
"",
|
| 1959 |
"",
|
| 1960 |
0.0,
|
|
@@ -1972,8 +2265,8 @@ with gr.Blocks() as demo:
|
|
| 1972 |
# Discover Tube Documentary Script Writer
|
| 1973 |
|
| 1974 |
Creates a direct, information-dense, human-sounding YouTube documentary script of
|
| 1975 |
-
2,900β3,200 words.
|
| 1976 |
-
|
| 1977 |
"""
|
| 1978 |
)
|
| 1979 |
|
|
@@ -2028,6 +2321,16 @@ opening hook style without changing the core writing voice.
|
|
| 2028 |
),
|
| 2029 |
)
|
| 2030 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2031 |
style_file_input = gr.File(
|
| 2032 |
label=(
|
| 2033 |
"π Upload a handmade sample script for style inspiration "
|
|
@@ -2105,6 +2408,7 @@ opening hook style without changing the core writing voice.
|
|
| 2105 |
recency_input,
|
| 2106 |
news_balance_input,
|
| 2107 |
hook_input,
|
|
|
|
| 2108 |
],
|
| 2109 |
outputs=[
|
| 2110 |
status_output,
|
|
@@ -2135,6 +2439,7 @@ opening hook style without changing the core writing voice.
|
|
| 2135 |
recency_input,
|
| 2136 |
news_balance_input,
|
| 2137 |
hook_input,
|
|
|
|
| 2138 |
status_output,
|
| 2139 |
script_output,
|
| 2140 |
start_time_state,
|
|
|
|
| 100 |
|
| 101 |
DEFAULT_HOOK_OPTION = "Auto β choose the strongest opening"
|
| 102 |
|
| 103 |
+
VIDEO_FORMAT_OPTIONS = {
|
| 104 |
+
"Standard documentary β 7 sections": {
|
| 105 |
+
"section_count": 7,
|
| 106 |
+
"chunk_sections": [2, 3, 2],
|
| 107 |
+
"list_mode": False,
|
| 108 |
+
"label": "sections",
|
| 109 |
+
},
|
| 110 |
+
"List documentary β 10 subtopics": {
|
| 111 |
+
"section_count": 10,
|
| 112 |
+
"chunk_sections": [3, 4, 3],
|
| 113 |
+
"list_mode": True,
|
| 114 |
+
"label": "subtopics",
|
| 115 |
+
},
|
| 116 |
+
"List documentary β 20 subtopics": {
|
| 117 |
+
"section_count": 20,
|
| 118 |
+
"chunk_sections": [7, 7, 6],
|
| 119 |
+
"list_mode": True,
|
| 120 |
+
"label": "subtopics",
|
| 121 |
+
},
|
| 122 |
+
"List documentary β 30 subtopics": {
|
| 123 |
+
"section_count": 30,
|
| 124 |
+
"chunk_sections": [10, 10, 10],
|
| 125 |
+
"list_mode": True,
|
| 126 |
+
"label": "subtopics",
|
| 127 |
+
},
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
DEFAULT_VIDEO_FORMAT_OPTION = "Standard documentary β 7 sections"
|
| 131 |
+
|
| 132 |
# The three minimum values add up to exactly 2,900 words.
|
| 133 |
# The maximum values add up to exactly 3,200 words.
|
| 134 |
CHUNK_SPECS = [
|
|
|
|
| 259 |
)
|
| 260 |
|
| 261 |
|
| 262 |
+
def resolve_video_format(option: str) -> dict:
|
| 263 |
+
return VIDEO_FORMAT_OPTIONS.get(
|
| 264 |
+
option,
|
| 265 |
+
VIDEO_FORMAT_OPTIONS[DEFAULT_VIDEO_FORMAT_OPTION],
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
def get_chunk_specs(video_format_option: str) -> list[dict]:
|
| 270 |
+
format_config = resolve_video_format(video_format_option)
|
| 271 |
+
|
| 272 |
+
if not format_config["list_mode"]:
|
| 273 |
+
return CHUNK_SPECS
|
| 274 |
+
|
| 275 |
+
counts = format_config["chunk_sections"]
|
| 276 |
+
total = format_config["section_count"]
|
| 277 |
+
starts = [1, counts[0] + 1, counts[0] + counts[1] + 1]
|
| 278 |
+
ends = [counts[0], counts[0] + counts[1], total]
|
| 279 |
+
|
| 280 |
+
specs = []
|
| 281 |
+
for base, count, start, end in zip(CHUNK_SPECS, counts, starts, ends):
|
| 282 |
+
spec = dict(base)
|
| 283 |
+
spec["section_count"] = count
|
| 284 |
+
spec["section_start"] = start
|
| 285 |
+
spec["section_end"] = end
|
| 286 |
+
|
| 287 |
+
if base["number"] == 1:
|
| 288 |
+
spec["purpose"] = (
|
| 289 |
+
f"Write the direct introduction of 120β160 words and numbered subtopics "
|
| 290 |
+
f"{start} through {end}. Follow the selected hook strategy. Mention "
|
| 291 |
+
f"Discover Tube exactly once in the introduction. Keep every subtopic "
|
| 292 |
+
f"distinct, factual, and useful rather than padding the list."
|
| 293 |
+
)
|
| 294 |
+
elif base["number"] == 2:
|
| 295 |
+
spec["purpose"] = (
|
| 296 |
+
f"Write numbered subtopics {start} through {end}. Keep the list-documentary "
|
| 297 |
+
f"pace moving while still explaining mechanisms, geography, evidence, and "
|
| 298 |
+
f"consequences where useful. Place the 40-percent Discover Tube subscribe "
|
| 299 |
+
f"sentence inside this chunk. Do not recap part 1."
|
| 300 |
+
)
|
| 301 |
+
else:
|
| 302 |
+
spec["purpose"] = (
|
| 303 |
+
f"Write numbered subtopics {start} through {end} and then a connected ending "
|
| 304 |
+
f"of 100β160 words. Place one Discover Tube audience question around 75 "
|
| 305 |
+
f"percent of the full video. In the final 100 words, mention Discover Tube "
|
| 306 |
+
f"once more, include a brief subscribe request, and ask one concrete comment "
|
| 307 |
+
f"question."
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
specs.append(spec)
|
| 311 |
+
|
| 312 |
+
return specs
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
def get_chunk_structure_issue(text: str, spec: dict) -> Optional[str]:
|
| 316 |
+
if "section_start" not in spec:
|
| 317 |
+
return None
|
| 318 |
+
|
| 319 |
+
numbers = [
|
| 320 |
+
int(value)
|
| 321 |
+
for value in re.findall(
|
| 322 |
+
r"(?m)^##\s+(\d+)\.\s+.+$",
|
| 323 |
+
text or "",
|
| 324 |
+
)
|
| 325 |
+
]
|
| 326 |
+
expected = list(
|
| 327 |
+
range(
|
| 328 |
+
int(spec["section_start"]),
|
| 329 |
+
int(spec["section_end"]) + 1,
|
| 330 |
+
)
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
if numbers == expected:
|
| 334 |
+
return None
|
| 335 |
+
|
| 336 |
+
expected_text = f"{spec['section_start']}β{spec['section_end']}"
|
| 337 |
+
found_text = ", ".join(str(number) for number in numbers) if numbers else "none"
|
| 338 |
+
return (
|
| 339 |
+
f"Expected numbered headings {expected_text} exactly once and in order; "
|
| 340 |
+
f"found: {found_text}."
|
| 341 |
+
)
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
def build_video_structure_requirements(video_format_option: str) -> str:
|
| 345 |
+
config = resolve_video_format(video_format_option)
|
| 346 |
+
total = config["section_count"]
|
| 347 |
+
|
| 348 |
+
if not config["list_mode"]:
|
| 349 |
+
return f"""
|
| 350 |
+
VIDEO STRUCTURE β STANDARD DOCUMENTARY
|
| 351 |
+
|
| 352 |
+
- Build exactly {total} titled sections across the three chunks.
|
| 353 |
+
- The sections should feel like a connected documentary rather than a numbered list.
|
| 354 |
+
- Make section lengths deliberately unequal. Give the richest topics more room and use
|
| 355 |
+
shorter sections as bridges or reveals.
|
| 356 |
+
- The largest section should be at least 150 words longer than the shortest section.
|
| 357 |
+
""".strip()
|
| 358 |
+
|
| 359 |
+
return f"""
|
| 360 |
+
VIDEO STRUCTURE β LIST DOCUMENTARY ({total} SUBTOPICS)
|
| 361 |
+
|
| 362 |
+
- Build exactly {total} distinct, visible, numbered subtopics across the complete script.
|
| 363 |
+
- This is a Reasons-Why-style list documentary, but adapt the item type naturally to the
|
| 364 |
+
title: reasons, warning signs, places, facts, changes, risks, explanations, discoveries,
|
| 365 |
+
consequences, or another clearly fitting category.
|
| 366 |
+
- Every item must use the exact visible heading format: ## NUMBER. Short Title
|
| 367 |
+
- Number continuously from ## 1. through ## {total}. Never skip, duplicate, restart, merge,
|
| 368 |
+
or add an extra numbered item.
|
| 369 |
+
- Each numbered item must contribute a genuinely different idea. Do not split one fact into
|
| 370 |
+
several artificial items merely to reach the requested count.
|
| 371 |
+
- Keep the core Discover Tube writing voice: direct, documentary-like, evidence-dense, and
|
| 372 |
+
human. Do not turn it into a shallow countdown or repetitive listicle.
|
| 373 |
+
- Use tighter pacing as the item count rises. A 30-item script needs concise items; a 10-item
|
| 374 |
+
script can give each item substantially more explanation.
|
| 375 |
+
- Transitions should still connect neighboring items, but do not force a cliffhanger after
|
| 376 |
+
every single item. Use stronger open loops at natural intervals.
|
| 377 |
+
""".strip()
|
| 378 |
+
|
| 379 |
+
|
| 380 |
def build_hook_requirements(hook_option: str) -> str:
|
| 381 |
if hook_option == "Topography / geography opening":
|
| 382 |
return """
|
|
|
|
| 516 |
cutoff_date: date,
|
| 517 |
current_date: date,
|
| 518 |
news_balance_option: str,
|
| 519 |
+
video_format_option: str,
|
| 520 |
) -> list[str]:
|
| 521 |
warnings = []
|
| 522 |
|
|
|
|
| 551 |
f"subscribe appears {subscribe_mentions}x instead of 2x"
|
| 552 |
)
|
| 553 |
|
| 554 |
+
format_config = resolve_video_format(video_format_option)
|
| 555 |
+
if format_config["list_mode"]:
|
| 556 |
+
expected = format_config["section_count"]
|
| 557 |
+
numbered_headings = re.findall(
|
| 558 |
+
r"(?m)^##\s+(\d+)\.\s+.+$",
|
| 559 |
+
text or "",
|
| 560 |
+
)
|
| 561 |
+
numbers = [int(value) for value in numbered_headings]
|
| 562 |
+
expected_numbers = list(range(1, expected + 1))
|
| 563 |
+
|
| 564 |
+
if numbers != expected_numbers:
|
| 565 |
+
warnings.append(
|
| 566 |
+
f"numbered subtopics are not exactly 1β{expected} in continuous order "
|
| 567 |
+
f"({len(numbers)} matching headings found)"
|
| 568 |
+
)
|
| 569 |
+
|
| 570 |
if len(old_years) > MAX_OLD_YEAR_MENTIONS:
|
| 571 |
unique_old_years = sorted(set(old_years))
|
| 572 |
|
|
|
|
| 601 |
current_date: date,
|
| 602 |
news_balance_option: str,
|
| 603 |
hook_option: str,
|
| 604 |
+
video_format_option: str,
|
| 605 |
) -> str:
|
| 606 |
balance = resolve_news_balance(news_balance_option)
|
| 607 |
hook_requirements = build_hook_requirements(hook_option)
|
| 608 |
+
format_config = resolve_video_format(video_format_option)
|
| 609 |
+
structure_requirements = build_video_structure_requirements(video_format_option)
|
| 610 |
+
topic_count = format_config["section_count"]
|
| 611 |
+
|
| 612 |
+
# Scale the number of explicit news anchors with the chosen list size without making
|
| 613 |
+
# the narration date-heavy. Standard mode keeps the original ranges.
|
| 614 |
+
if format_config["list_mode"]:
|
| 615 |
+
ratio_min = balance["recent_anchor_min"] / 7
|
| 616 |
+
ratio_max = balance["recent_anchor_max"] / 7
|
| 617 |
+
recent_anchor_min = max(1, round(topic_count * ratio_min))
|
| 618 |
+
recent_anchor_max = max(recent_anchor_min, round(topic_count * ratio_max))
|
| 619 |
+
else:
|
| 620 |
+
recent_anchor_min = balance["recent_anchor_min"]
|
| 621 |
+
recent_anchor_max = balance["recent_anchor_max"]
|
| 622 |
|
| 623 |
return f"""
|
| 624 |
Write for a high-retention science and geography documentary with a selective current-news
|
| 625 |
layer. The narration must feel human-written, purposeful, conversational, and factual.
|
| 626 |
+
Preserve the existing direct Discover Tube writing style; change the structure and balance of
|
| 627 |
+
material when requested, not the voice.
|
| 628 |
+
|
| 629 |
+
{structure_requirements}
|
| 630 |
|
| 631 |
NEWS BALANCE β {news_balance_option}
|
| 632 |
|
| 633 |
- {balance['description']}
|
| 634 |
- Use recent news as the true narrative anchor in approximately
|
| 635 |
+
{recent_anchor_min}β{recent_anchor_max} of the {topic_count} main topics/subtopics.
|
| 636 |
- Across the full narration, recent-event material should occupy
|
| 637 |
{balance['recent_narration_share']} of the script, not the entire script.
|
| 638 |
- Aim for only {balance['date_mentions_min']}β{balance['date_mentions_max']} explicit calendar-
|
|
|
|
| 640 |
- Do not mention a publication date merely to prove that a source is recent.
|
| 641 |
- Dates belong in narration only when chronology, escalation, timing, or a specific event
|
| 642 |
genuinely depends on them.
|
| 643 |
+
- It is fine for several paragraphs or complete documentary topics to contain no dates.
|
| 644 |
|
| 645 |
RECENT NEWS WINDOW
|
| 646 |
|
|
|
|
| 659 |
|
| 660 |
DOCUMENTARY DEPTH
|
| 661 |
|
| 662 |
+
- Build one coherent documentary even when the selected format contains many numbered items.
|
| 663 |
- The non-news portions should add real documentary value: topography, physical geography,
|
| 664 |
mechanisms, geology, hydrology, infrastructure, ecological consequences, regional scale,
|
| 665 |
scientific uncertainty, monitoring methods, or what the evidence means for people.
|
| 666 |
+
- Do not use generic textbook filler. Every paragraph or numbered item must add a specific fact,
|
| 667 |
+
mechanism, example, consequence, measurement, research result, or documented uncertainty.
|
| 668 |
- Use named locations, agencies, datasets, projects, researchers, and measurements when they
|
| 669 |
improve clarity, but do not turn the script into a list of source metadata.
|
| 670 |
- Explain why important facts matter and how the mechanism works.
|
|
|
|
| 674 |
INTRODUCTION β 120β160 WORDS
|
| 675 |
|
| 676 |
- Follow the selected hook strategy below.
|
| 677 |
+
- Mention β{CHANNEL_NAME}β exactly once in one short, natural sentence that is woven into the
|
| 678 |
+
story instead of sounding like a company mission statement.
|
| 679 |
+
- That sentence must smoothly communicate BOTH ideas: we make documentary-style videos that
|
| 680 |
+
dig deeper into major natural, geographic, and scientific stories, and we keep viewers
|
| 681 |
+
updated when important new developments change or advance those stories.
|
| 682 |
+
- Prefer conversational constructions such as: βStories like this are what we dig into on
|
| 683 |
+
Discover Tube, where our documentaries go beyond the headline and keep you updated as new
|
| 684 |
+
developments unfold.β Do NOT copy this example mechanically; vary it naturally to fit the
|
| 685 |
+
topic and the sentence before it.
|
| 686 |
+
- Avoid stiff phrasing such as βDiscover Tube makes documentary films...β or language that
|
| 687 |
+
sounds like an About Us page.
|
| 688 |
+
- This Discover Tube sentence is not a subscription request and not a question.
|
| 689 |
- Do not overload the intro with dates. One exact date is enough when the selected hook truly
|
| 690 |
needs it; otherwise use none.
|
| 691 |
- The FINAL sentence of the intro must land strongly in one of two ways:
|
|
|
|
| 698 |
|
| 699 |
CENTRAL STORY AND RETENTION
|
| 700 |
|
| 701 |
+
- Every main topic or numbered subtopic must answer part of the central documentary question
|
| 702 |
+
and give the viewer a reason to continue.
|
| 703 |
+
- In standard documentary mode, end sections 1 through 6 with content-based open loops.
|
| 704 |
+
- In list-documentary mode, use open loops at natural intervals and especially at chunk
|
| 705 |
+
boundaries; do not make all 10/20/30 items end with the same rhetorical tease.
|
| 706 |
+
- Vary transitions through measurements, unresolved results, locations, consequences,
|
| 707 |
+
scientific limitations, official decisions, physical mechanisms, or competing explanations.
|
| 708 |
+
- Do not end every topic with a rhetorical question.
|
| 709 |
- Pay off earlier open loops later in the script so the story feels intentional.
|
| 710 |
- Put the strongest verified material in the first third, whether it is current news,
|
| 711 |
topography, a hard measurement, or an important scientific mechanism.
|
| 712 |
- Keep retention high through information, escalation, contrast, and consequence, not empty
|
| 713 |
mystery language.
|
| 714 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
HUMAN WRITING
|
| 716 |
|
| 717 |
- Use mostly short and medium-length sentences.
|
| 718 |
- Keep most paragraphs between one and four sentences.
|
| 719 |
- Use natural sentence variation and active language.
|
| 720 |
+
- Avoid sounding like a report, literature review, AI summary, or generic listicle.
|
| 721 |
- Introduce researchers through what they did, measured, found, announced, or questioned.
|
| 722 |
- Use concrete nouns instead of vague references when the evidence gives a name.
|
| 723 |
- Do not overuse em dashes, three-part dramatic lists, fragments, or rhetorical questions.
|
|
|
|
| 729 |
|
| 730 |
- Use exactly three factual comparisons in the complete script.
|
| 731 |
- Each comparison must clarify scale, speed, depth, distance, volume, time, or impact.
|
| 732 |
+
- Spread the comparisons across different parts of the script.
|
| 733 |
- Check all units and conversions mathematically.
|
| 734 |
- Do not use additional decorative comparisons beyond those three.
|
| 735 |
|
|
|
|
| 737 |
|
| 738 |
- Use the exact phrase β{CHANNEL_NAME}β exactly four times in the complete script.
|
| 739 |
- Exactly two questions in the complete script may contain β{CHANNEL_NAME}β.
|
| 740 |
+
- Placement 1: once in the introduction, inside the natural one-sentence channel description.
|
| 741 |
+
This is not a question and contains no subscribe or comment request.
|
| 742 |
- Placement 2: around 40 percent of the video, as one brief subscribe sentence.
|
|
|
|
| 743 |
- Placement 3: around 75 percent of the video, inside one topic-specific audience question.
|
| 744 |
+
Do not ask for a subscription there.
|
| 745 |
- Placement 4: within the final 100 words. Include a brief subscribe request and ask one
|
| 746 |
concrete comment question. The question itself must contain β{CHANNEL_NAME}β.
|
| 747 |
- Do not mention β{CHANNEL_NAME}β anywhere else.
|
| 748 |
- Do not use the word subscribe outside placements 2 and 4.
|
| 749 |
""".strip()
|
| 750 |
|
|
|
|
| 751 |
# =========================================================
|
| 752 |
# STYLE SAMPLE
|
| 753 |
# =========================================================
|
|
|
|
| 985 |
title: str,
|
| 986 |
recency_days: int,
|
| 987 |
news_balance_option: str,
|
| 988 |
+
video_format_option: str,
|
| 989 |
) -> str:
|
| 990 |
cutoff_date, current_date = get_news_window(
|
| 991 |
recency_days
|
| 992 |
)
|
| 993 |
balance = resolve_news_balance(news_balance_option)
|
| 994 |
+
format_config = resolve_video_format(video_format_option)
|
| 995 |
+
topic_count = format_config["section_count"]
|
| 996 |
+
list_mode = format_config["list_mode"]
|
| 997 |
+
|
| 998 |
+
if list_mode:
|
| 999 |
+
ratio_min = balance["recent_anchor_min"] / 7
|
| 1000 |
+
ratio_max = balance["recent_anchor_max"] / 7
|
| 1001 |
+
research_anchor_min = max(1, round(topic_count * ratio_min))
|
| 1002 |
+
research_anchor_max = max(research_anchor_min, round(topic_count * ratio_max))
|
| 1003 |
+
else:
|
| 1004 |
+
research_anchor_min = balance["recent_anchor_min"]
|
| 1005 |
+
research_anchor_max = balance["recent_anchor_max"]
|
| 1006 |
|
| 1007 |
prompt = f"""
|
| 1008 |
Today's date is {current_date.isoformat()}.
|
|
|
|
| 1020 |
{balance['description']}
|
| 1021 |
|
| 1022 |
The final script should use recent news as a genuine anchor in approximately
|
| 1023 |
+
{research_anchor_min}β{research_anchor_max} of {topic_count} main topics/subtopics, not in every
|
| 1024 |
+
topic. Recent-event narration should occupy {balance['recent_narration_share']} of the
|
| 1025 |
finished script. The rest may use durable, authoritative documentary context.
|
| 1026 |
|
| 1027 |
CURRENT NEWS WINDOW
|
|
|
|
| 1053 |
RECENCY VERDICT: INSUFFICIENT
|
| 1054 |
|
| 1055 |
Return SUFFICIENT when there is enough reliable current material to support the selected news
|
| 1056 |
+
balance plus enough authoritative documentary evidence to build {topic_count} connected
|
| 1057 |
+
main topics/subtopics. A larger list format does NOT require a separate news story for every
|
| 1058 |
+
item. For lighter news modes, a smaller number of strong recent anchors can support several
|
| 1059 |
+
documentary subtopics.
|
| 1060 |
|
| 1061 |
If the verdict is INSUFFICIENT:
|
| 1062 |
|
|
|
|
| 1100 |
6. DOCUMENTARY BACKGROUND LEDGER with 4β10 authoritative sources for durable topography,
|
| 1101 |
mechanisms, baseline science, historical context, or regional consequences. Include dates
|
| 1102 |
internally, but mark them BACKGROUND and do not imply recency.
|
| 1103 |
+
7. FACT BANK with enough specific, non-duplicative evidence to support all {topic_count}
|
| 1104 |
+
main topics/subtopics (normally at least {max(35, topic_count * 2)} useful facts). Label every fact CURRENT or
|
| 1105 |
BACKGROUND. Include location, source/institution, certainty, and why it matters.
|
| 1106 |
+
8. SUBTOPIC BANK: propose at least {topic_count + (5 if list_mode else 2)} distinct candidate
|
| 1107 |
+
topic angles so the planner can select exactly {topic_count} without padding or duplication.
|
| 1108 |
+
For list mode, each candidate must be meaningfully different and strong enough to support a
|
| 1109 |
+
visible numbered item.
|
| 1110 |
+
9. OPENING MATERIAL BANK with one strong evidence-based candidate for each opening mode:
|
| 1111 |
- TOPOGRAPHY / GEOGRAPHY;
|
| 1112 |
- DATE / CURRENT EVENT;
|
| 1113 |
- NEWS CLIP CONTINUATION;
|
| 1114 |
- HARD FACT / SCALE.
|
| 1115 |
Also include two strong intro-ending candidates: one central question and one verified hard
|
| 1116 |
fact/consequence.
|
| 1117 |
+
10. RECENT DATA BLOCK containing the strongest current figures and measurements that are worth
|
| 1118 |
mentioning in narration. Do NOT include dates that add no storytelling value.
|
| 1119 |
+
11. SCIENTIFIC EXPLANATIONS needed to understand the story: mechanism, method, uncertainty,
|
| 1120 |
competing explanations, and limitations.
|
| 1121 |
+
12. TOPOGRAPHY AND GEOGRAPHY details that can make the documentary visually specific.
|
| 1122 |
+
13. HUMAN, environmental, economic, infrastructure, policy, or safety consequences.
|
| 1123 |
+
14. At least six candidate factual comparisons with checked units. The script will select
|
| 1124 |
exactly three.
|
| 1125 |
+
15. ESSENTIAL HISTORICAL CONTEXT, limited to what genuinely improves understanding and short
|
| 1126 |
enough to stay within {MAX_HISTORICAL_CONTEXT_PERCENT} percent of the final script.
|
| 1127 |
+
16. CLAIMS TO AVOID.
|
| 1128 |
+
17. EXTRA VERIFIED FACTS that can be used to reach the word target without repetitive dates,
|
| 1129 |
stale filler, or generic textbook language.
|
| 1130 |
|
| 1131 |
Do not copy source sentences. Do not write dramatic narration. The evidence pack should be
|
|
|
|
| 1217 |
global_requirements: str,
|
| 1218 |
news_balance_option: str,
|
| 1219 |
hook_option: str,
|
| 1220 |
+
video_format_option: str,
|
| 1221 |
) -> str:
|
| 1222 |
balance = resolve_news_balance(news_balance_option)
|
| 1223 |
+
format_config = resolve_video_format(video_format_option)
|
| 1224 |
+
topic_count = format_config["section_count"]
|
| 1225 |
+
list_mode = format_config["list_mode"]
|
| 1226 |
+
chunk_counts = format_config["chunk_sections"]
|
| 1227 |
+
|
| 1228 |
+
if list_mode:
|
| 1229 |
+
ratio_min = balance["recent_anchor_min"] / 7
|
| 1230 |
+
ratio_max = balance["recent_anchor_max"] / 7
|
| 1231 |
+
anchor_min = max(1, round(topic_count * ratio_min))
|
| 1232 |
+
anchor_max = max(anchor_min, round(topic_count * ratio_max))
|
| 1233 |
+
structure_plan = f"""
|
| 1234 |
+
LIST-DOCUMENTARY STRUCTURE
|
| 1235 |
+
|
| 1236 |
+
- Plan exactly {topic_count} numbered subtopics.
|
| 1237 |
+
- Chunk 1 contains subtopics 1β{chunk_counts[0]} after the introduction.
|
| 1238 |
+
- Chunk 2 contains subtopics {chunk_counts[0] + 1}β{chunk_counts[0] + chunk_counts[1]}.
|
| 1239 |
+
- Chunk 3 contains subtopics {chunk_counts[0] + chunk_counts[1] + 1}β{topic_count}, followed by
|
| 1240 |
+
the 100β160 word ending.
|
| 1241 |
+
- Every planned heading must use: ## NUMBER. Short Title
|
| 1242 |
+
- The item type must fit the title naturally. Use βreasonsβ only if the title truly asks why;
|
| 1243 |
+
otherwise use facts, warning signs, locations, risks, mechanisms, changes, consequences, or
|
| 1244 |
+
another fitting category.
|
| 1245 |
+
- Give each item an exact word budget. Keep enough variation to avoid monotony, but do not use
|
| 1246 |
+
the standard documentary rule requiring a 150-word gap between longest and shortest items.
|
| 1247 |
+
- Prevent duplication aggressively: each numbered item must have its own core claim and evidence.
|
| 1248 |
+
""".strip()
|
| 1249 |
+
else:
|
| 1250 |
+
anchor_min = balance["recent_anchor_min"]
|
| 1251 |
+
anchor_max = balance["recent_anchor_max"]
|
| 1252 |
+
structure_plan = """
|
| 1253 |
+
STANDARD DOCUMENTARY STRUCTURE
|
| 1254 |
+
|
| 1255 |
+
- Plan exactly seven titled sections: two in chunk 1, three in chunk 2, and two in chunk 3.
|
| 1256 |
+
- Give every section an exact individual word budget.
|
| 1257 |
+
- Do not give neighboring sections similar budgets unless necessary.
|
| 1258 |
+
- Use the largest sections for the richest scientific or geographic material.
|
| 1259 |
+
- Use at least two noticeably short bridge sections.
|
| 1260 |
+
- The largest section must be at least 150 words longer than the shortest.
|
| 1261 |
+
""".strip()
|
| 1262 |
|
| 1263 |
prompt = f"""
|
| 1264 |
Create a concise but detailed INTERNAL writing plan for this proposed title:
|
|
|
|
| 1269 |
{research}
|
| 1270 |
</evidence_pack>
|
| 1271 |
|
| 1272 |
+
SELECTED VIDEO FORMAT
|
| 1273 |
+
|
| 1274 |
+
{video_format_option}
|
| 1275 |
+
|
| 1276 |
+
The final spoken script must contain 2,900β3,200 words and exactly three writing chunks:
|
| 1277 |
|
| 1278 |
CHUNK 1 β 900β1,000 words
|
| 1279 |
- A direct introduction of 120β160 words.
|
|
|
|
| 1280 |
- Follow the selected hook: {hook_option}.
|
| 1281 |
+
- Then cover the first {chunk_counts[0]} main topics/subtopics.
|
| 1282 |
+
- Move into the strongest story material instead of automatically dumping dates or source
|
| 1283 |
+
chronology.
|
| 1284 |
|
| 1285 |
CHUNK 2 β 1,000β1,100 words
|
| 1286 |
+
- Cover the next {chunk_counts[1]} main topics/subtopics.
|
| 1287 |
+
- Carry the densest scientific explanation, analysis, regional consequences, named research or
|
| 1288 |
monitoring, and selected current developments.
|
| 1289 |
|
| 1290 |
CHUNK 3 β 1,000β1,100 words
|
| 1291 |
+
- Cover the final {chunk_counts[2]} main topics/subtopics.
|
| 1292 |
+
- Finish with a connected ending of 100β160 words that resolves the story and explains what
|
| 1293 |
+
matters next.
|
| 1294 |
+
|
| 1295 |
+
That produces exactly {topic_count} main topics/subtopics in the full script.
|
| 1296 |
|
| 1297 |
+
{structure_plan}
|
| 1298 |
|
| 1299 |
{global_requirements}
|
| 1300 |
|
| 1301 |
NEWS / DOCUMENTARY ALLOCATION
|
| 1302 |
|
| 1303 |
+
- Mark every main topic/subtopic internally as either NEWS ANCHOR or DOCUMENTARY CORE.
|
| 1304 |
+
- Use NEWS ANCHOR for approximately {anchor_min}β{anchor_max} items total. Do not force news
|
| 1305 |
+
into every item.
|
| 1306 |
+
- Use DOCUMENTARY CORE for topography, physical mechanisms, scientific explanation, regional
|
| 1307 |
+
consequences, long-running systems, infrastructure, or other durable material.
|
| 1308 |
- Recent-event narration across the whole script should be {balance['recent_narration_share']}.
|
| 1309 |
- Plan only {balance['date_mentions_min']}β{balance['date_mentions_max']} explicit calendar-date
|
| 1310 |
references for the spoken narration. Publication dates can remain internal in the plan.
|
| 1311 |
+
- Never create a standalone history lesson merely to fill an item.
|
| 1312 |
+
- Never create a standalone latest-update item merely to satisfy recency. Blend current
|
| 1313 |
developments into the central documentary story.
|
| 1314 |
|
| 1315 |
INTRO PLAN
|
| 1316 |
|
| 1317 |
- State the exact hook mode that chunk 1 will use. If the selected hook is AUTO, choose the
|
| 1318 |
strongest mode from the evidence pack and record the choice.
|
| 1319 |
+
- Plan the first 3β4 sentences by function only, not as sample narration.
|
| 1320 |
+
- Reserve exactly one short bridge sentence for Discover Tube. It must feel conversational and
|
| 1321 |
+
connected to the story, not like a channel description pasted into the intro. It should
|
| 1322 |
+
naturally communicate that Discover Tube goes deeper through documentary-style videos and
|
| 1323 |
+
keeps viewers updated as important new developments unfold.
|
| 1324 |
- Choose the intro's final sentence type: CENTRAL QUESTION or HARD FACT / CONSEQUENCE.
|
| 1325 |
- Do not automatically choose a question every time.
|
| 1326 |
|
| 1327 |
+
FOR EVERY MAIN TOPIC / SUBTOPIC PROVIDE
|
| 1328 |
|
| 1329 |
+
- its exact heading/title;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1330 |
- ROLE: NEWS ANCHOR or DOCUMENTARY CORE;
|
| 1331 |
- its central purpose;
|
| 1332 |
- its exact word budget;
|
| 1333 |
- the exact facts, measurements, people, locations, topography, and mechanisms it uses;
|
| 1334 |
- the scientific explanation or analysis it contains;
|
| 1335 |
- the human or practical consequence;
|
| 1336 |
+
- if NEWS ANCHOR: the current development, publication date, and event date;
|
| 1337 |
+
- if DOCUMENTARY CORE: the durable evidence it explains and how it connects to the story;
|
|
|
|
| 1338 |
- whether an explicit date should actually be spoken aloud;
|
| 1339 |
+
- its transition to the next item or section;
|
| 1340 |
- any essential historical context, limited to one or two brief points.
|
| 1341 |
|
| 1342 |
ALLOCATION RULES
|
| 1343 |
|
| 1344 |
+
- Assign every important fact to only one topic/subtopic.
|
| 1345 |
- Put the strongest verified material in chunk 1, but that material does not have to be news.
|
| 1346 |
- Reserve enough unused evidence for chunks 2 and 3.
|
| 1347 |
+
- Select exactly three verified comparisons and assign each to a different part of the script.
|
| 1348 |
+
- Assign named studies, projects, reports, alerts, datasets, or monitoring efforts where they
|
| 1349 |
+
add substance. They do not all need to be recent.
|
| 1350 |
+
- In list mode, audit the full list for overlap before finalizing the plan. If two items are
|
| 1351 |
+
substantially similar, merge the idea and replace one with a genuinely different topic.
|
| 1352 |
- Do not create a debunking video. Silently use the strongest accurate angle.
|
| 1353 |
|
| 1354 |
DISCOVER TUBE PLACEMENT PLAN
|
| 1355 |
|
| 1356 |
+
1. Introduction: one smooth non-question mention of β{CHANNEL_NAME}β inside the natural bridge
|
| 1357 |
+
sentence described above.
|
| 1358 |
2. Around 40 percent: one brief non-question subscribe sentence containing β{CHANNEL_NAME}β.
|
| 1359 |
3. Around 75 percent: one topic-specific audience question containing β{CHANNEL_NAME}β.
|
| 1360 |
4. Final 100 words: one brief subscribe request and one concrete comment question; the question
|
|
|
|
| 1362 |
|
| 1363 |
Exactly four total mentions of β{CHANNEL_NAME}β and exactly two questions containing it.
|
| 1364 |
|
| 1365 |
+
Keep the complete plan between 1,500 and 2,700 words. Use compact bullet points.
|
| 1366 |
Do not write sample narration and do not repeat the entire evidence pack.
|
| 1367 |
This is a plan only.
|
| 1368 |
""".strip()
|
| 1369 |
|
| 1370 |
log(
|
| 1371 |
+
f"Phase 2 started: three-part plan for {video_format_option}."
|
| 1372 |
)
|
| 1373 |
|
| 1374 |
plan, response = request_text(
|
|
|
|
| 1376 |
model=model,
|
| 1377 |
system_prompt=(
|
| 1378 |
"You are a senior documentary editor. Build a connected, high-retention plan that "
|
| 1379 |
+
"preserves a strong human writing style, obeys the exact requested topic count, "
|
| 1380 |
+
"uses only the selected amount of current news, and prevents repetitive list items."
|
| 1381 |
),
|
| 1382 |
user_prompt=prompt,
|
| 1383 |
max_tokens=PLAN_MAX_TOKENS,
|
|
|
|
| 1401 |
|
| 1402 |
return plan
|
| 1403 |
|
|
|
|
| 1404 |
# =========================================================
|
| 1405 |
# PHASE 3 β THREE SCRIPT CHUNKS
|
| 1406 |
# =========================================================
|
|
|
|
| 1461 |
maximum = spec["maximum"]
|
| 1462 |
target = spec["target"]
|
| 1463 |
|
| 1464 |
+
if "section_start" in spec:
|
| 1465 |
+
format_rule = (
|
| 1466 |
+
f"This chunk must contain exactly the numbered headings ## {spec['section_start']}. "
|
| 1467 |
+
f"through ## {spec['section_end']}. Use every number once, in order, with no "
|
| 1468 |
+
f"extra numbered subtopic."
|
| 1469 |
+
)
|
| 1470 |
+
else:
|
| 1471 |
+
format_rule = (
|
| 1472 |
+
"This chunk must contain exactly the standard documentary section headings "
|
| 1473 |
+
"assigned to it in the plan."
|
| 1474 |
+
)
|
| 1475 |
+
|
| 1476 |
if chunk_number == 1:
|
| 1477 |
continuity_rule = (
|
| 1478 |
"Do not print the video title. Write the 120β160 word introduction according "
|
|
|
|
| 1512 |
|
| 1513 |
{spec['purpose']}
|
| 1514 |
|
| 1515 |
+
EXACT STRUCTURE FOR THIS CHUNK
|
| 1516 |
+
|
| 1517 |
+
- {format_rule}
|
| 1518 |
+
|
| 1519 |
HARD LENGTH REQUIREMENT
|
| 1520 |
|
| 1521 |
- This chunk must contain between {minimum} and {maximum} words.
|
|
|
|
| 1544 |
WRITING STANDARD
|
| 1545 |
|
| 1546 |
- {continuity_rule}
|
| 1547 |
+
- Follow the exact topic/subtopic budgets assigned in the plan.
|
| 1548 |
- Every paragraph must add a new fact, example, mechanism, measurement, consequence, event,
|
| 1549 |
research result, analysis, topographic detail, or documented uncertainty.
|
| 1550 |
- Write straight to the point and explain why the information matters.
|
|
|
|
| 1558 |
- Preserve uncertainty. Do not turn possible, estimated, preliminary, or disputed information
|
| 1559 |
into certainty.
|
| 1560 |
- Do not tell the audience that the proposed title was fact-checked or exaggerated.
|
| 1561 |
+
- Use every heading exactly as planned for this chunk. In list mode, preserve the exact
|
| 1562 |
+
continuous numbering.
|
| 1563 |
- Use only the comparisons assigned to this chunk. The complete script must contain exactly
|
| 1564 |
three factual comparisons in total.
|
| 1565 |
- Do not include sources, URLs, citations, editor notes, camera directions, or B-roll.
|
|
|
|
| 1582 |
cutoff_date: date,
|
| 1583 |
current_date: date,
|
| 1584 |
global_requirements: str,
|
| 1585 |
+
structure_issue: Optional[str] = None,
|
| 1586 |
) -> str:
|
| 1587 |
current_words = count_words(
|
| 1588 |
current_chunk
|
| 1589 |
)
|
| 1590 |
|
| 1591 |
+
operations = []
|
| 1592 |
+
|
| 1593 |
if current_words < minimum:
|
| 1594 |
+
operations.append(
|
| 1595 |
+
f"The chunk is {minimum - current_words} words below the minimum. Expand it with "
|
| 1596 |
+
"unused verified facts, topography, mechanisms, scientific explanation, "
|
| 1597 |
+
"measurements, consequences, or planned current developments assigned to this "
|
| 1598 |
+
"part. Respect the section roles and spoken-date budget."
|
| 1599 |
)
|
| 1600 |
+
elif current_words > maximum:
|
| 1601 |
+
operations.append(
|
| 1602 |
+
f"The chunk is {current_words - maximum} words above the maximum. Remove "
|
| 1603 |
+
"repetition, unnecessary chronology, source-date language, and decorative "
|
| 1604 |
"phrasing while preserving important science, geography, current anchors, open "
|
| 1605 |
"loops, comparisons, and CTA placement."
|
| 1606 |
)
|
| 1607 |
+
else:
|
| 1608 |
+
operations.append(
|
| 1609 |
+
"The chunk is already inside the required word range. Preserve its overall length."
|
| 1610 |
+
)
|
| 1611 |
+
|
| 1612 |
+
if structure_issue:
|
| 1613 |
+
operations.append(
|
| 1614 |
+
"Repair this exact structural problem: " + structure_issue + " Preserve every "
|
| 1615 |
+
"correct numbered heading, restore missing headings, remove duplicates, and keep "
|
| 1616 |
+
"the planned evidence attached to the correct item."
|
| 1617 |
+
)
|
| 1618 |
+
|
| 1619 |
+
operation = "\n".join(operations)
|
| 1620 |
|
| 1621 |
return f"""
|
| 1622 |
Rewrite the COMPLETE chunk below.
|
|
|
|
| 1657 |
- When shortening, remove repetitive chronology and source-date language before removing
|
| 1658 |
important science or geographic detail.
|
| 1659 |
|
| 1660 |
+
Keep the same topic purposes, exact headings, appropriate topic pacing, scientific
|
| 1661 |
+
explanations, analysis, planned comparisons, and content-based cliffhangers. If the chunk uses
|
| 1662 |
+
numbered ## headings, preserve the intended number range exactly: do not skip, duplicate, merge,
|
| 1663 |
+
restart, or add a numbered item.
|
| 1664 |
Keep the narration direct, human, and information-dense. Do not add a new
|
| 1665 |
introduction, sources, citations, or production notes.
|
| 1666 |
|
|
|
|
| 1684 |
cutoff_date: date,
|
| 1685 |
current_date: date,
|
| 1686 |
global_requirements: str,
|
| 1687 |
+
structure_issue: Optional[str] = None,
|
| 1688 |
) -> str:
|
| 1689 |
prompt = build_chunk_revision_prompt(
|
| 1690 |
research=research,
|
|
|
|
| 1698 |
cutoff_date=cutoff_date,
|
| 1699 |
current_date=current_date,
|
| 1700 |
global_requirements=global_requirements,
|
| 1701 |
+
structure_issue=structure_issue,
|
| 1702 |
)
|
| 1703 |
|
| 1704 |
revised, _ = request_text(
|
|
|
|
| 1813 |
recency_option: str,
|
| 1814 |
news_balance_option: str,
|
| 1815 |
hook_option: str,
|
| 1816 |
+
video_format_option: str,
|
| 1817 |
):
|
| 1818 |
current_script = ""
|
| 1819 |
|
|
|
|
| 1841 |
current_date=current_date,
|
| 1842 |
news_balance_option=news_balance_option,
|
| 1843 |
hook_option=hook_option,
|
| 1844 |
+
video_format_option=video_format_option,
|
| 1845 |
)
|
| 1846 |
|
| 1847 |
yield (
|
|
|
|
| 1856 |
title=clean_title,
|
| 1857 |
recency_days=recency_days,
|
| 1858 |
news_balance_option=news_balance_option,
|
| 1859 |
+
video_format_option=video_format_option,
|
| 1860 |
)
|
| 1861 |
|
| 1862 |
yield (
|
|
|
|
| 1875 |
global_requirements=global_requirements,
|
| 1876 |
news_balance_option=news_balance_option,
|
| 1877 |
hook_option=hook_option,
|
| 1878 |
+
video_format_option=video_format_option,
|
| 1879 |
)
|
| 1880 |
|
| 1881 |
chunks: list[str] = []
|
| 1882 |
+
active_chunk_specs = get_chunk_specs(video_format_option)
|
| 1883 |
|
| 1884 |
+
for spec in active_chunk_specs:
|
| 1885 |
chunk_number = spec["number"]
|
| 1886 |
previous_script = joined_script(
|
| 1887 |
chunks
|
|
|
|
| 1915 |
system_prompt=(
|
| 1916 |
"You are an experienced human documentary writer. Write dense, "
|
| 1917 |
"direct, natural spoken English with strong scientific and geographic "
|
| 1918 |
+
"depth, selective current-news material, well-paced topic sizes, connected "
|
| 1919 |
"cliffhangers, and high retention. Preserve the requested news balance "
|
| 1920 |
"and do not overuse dates."
|
| 1921 |
),
|
|
|
|
| 1955 |
)
|
| 1956 |
|
| 1957 |
# Maximum of three targeted correction rounds per chunk.
|
| 1958 |
+
structure_issue = get_chunk_structure_issue(chunk_text, spec)
|
| 1959 |
+
|
| 1960 |
for correction_attempt in range(3):
|
| 1961 |
+
length_ok = (
|
| 1962 |
spec["minimum"]
|
| 1963 |
<= chunk_words
|
| 1964 |
<= spec["maximum"]
|
| 1965 |
+
)
|
| 1966 |
+
|
| 1967 |
+
if length_ok and not structure_issue:
|
| 1968 |
break
|
| 1969 |
|
| 1970 |
+
issue_text = (
|
| 1971 |
+
f" Structure check: {structure_issue}"
|
| 1972 |
+
if structure_issue
|
| 1973 |
+
else ""
|
| 1974 |
+
)
|
| 1975 |
+
|
| 1976 |
yield (
|
| 1977 |
f"π Part {chunk_number}/3 has "
|
| 1978 |
f"{chunk_words} words; target is "
|
| 1979 |
+
f"{spec['minimum']}β{spec['maximum']}."
|
| 1980 |
+
f"{issue_text} Correction {correction_attempt + 1}/3β¦",
|
| 1981 |
joined_script(
|
| 1982 |
chunks + [chunk_text]
|
| 1983 |
),
|
|
|
|
| 1997 |
cutoff_date=cutoff_date,
|
| 1998 |
current_date=current_date,
|
| 1999 |
global_requirements=global_requirements,
|
| 2000 |
+
structure_issue=structure_issue,
|
| 2001 |
)
|
| 2002 |
|
| 2003 |
chunk_words = count_words(
|
| 2004 |
chunk_text
|
| 2005 |
)
|
| 2006 |
+
structure_issue = get_chunk_structure_issue(chunk_text, spec)
|
| 2007 |
|
| 2008 |
log(
|
| 2009 |
f"Part {chunk_number} after correction "
|
|
|
|
| 2070 |
cutoff_date=cutoff_date,
|
| 2071 |
current_date=current_date,
|
| 2072 |
news_balance_option=news_balance_option,
|
| 2073 |
+
video_format_option=video_format_option,
|
| 2074 |
)
|
| 2075 |
|
| 2076 |
window_text = (
|
|
|
|
| 2247 |
DEFAULT_RECENCY_OPTION,
|
| 2248 |
DEFAULT_NEWS_BALANCE_OPTION,
|
| 2249 |
DEFAULT_HOOK_OPTION,
|
| 2250 |
+
DEFAULT_VIDEO_FORMAT_OPTION,
|
| 2251 |
"",
|
| 2252 |
"",
|
| 2253 |
0.0,
|
|
|
|
| 2265 |
# Discover Tube Documentary Script Writer
|
| 2266 |
|
| 2267 |
Creates a direct, information-dense, human-sounding YouTube documentary script of
|
| 2268 |
+
2,900β3,200 words. Control the news balance, opening hook, and video structure: either a
|
| 2269 |
+
standard documentary or a 10/20/30-subtopic list documentary, without changing the core voice.
|
| 2270 |
"""
|
| 2271 |
)
|
| 2272 |
|
|
|
|
| 2321 |
),
|
| 2322 |
)
|
| 2323 |
|
| 2324 |
+
video_format_input = gr.Dropdown(
|
| 2325 |
+
choices=list(VIDEO_FORMAT_OPTIONS.keys()),
|
| 2326 |
+
value=DEFAULT_VIDEO_FORMAT_OPTION,
|
| 2327 |
+
label="π§© Video format",
|
| 2328 |
+
info=(
|
| 2329 |
+
"Choose the normal 7-section documentary or a Reasons-Why-style list "
|
| 2330 |
+
"documentary with exactly 10, 20, or 30 visible numbered subtopics."
|
| 2331 |
+
),
|
| 2332 |
+
)
|
| 2333 |
+
|
| 2334 |
style_file_input = gr.File(
|
| 2335 |
label=(
|
| 2336 |
"π Upload a handmade sample script for style inspiration "
|
|
|
|
| 2408 |
recency_input,
|
| 2409 |
news_balance_input,
|
| 2410 |
hook_input,
|
| 2411 |
+
video_format_input,
|
| 2412 |
],
|
| 2413 |
outputs=[
|
| 2414 |
status_output,
|
|
|
|
| 2439 |
recency_input,
|
| 2440 |
news_balance_input,
|
| 2441 |
hook_input,
|
| 2442 |
+
video_format_input,
|
| 2443 |
status_output,
|
| 2444 |
script_output,
|
| 2445 |
start_time_state,
|