Repository navigation
Expand file tree
/
Copy pathgen_outline_part2.py
More file actions
82 lines (67 loc) · 2.94 KB
/
Copy pathgen_outline_part2.py
File metadata and controls
82 lines (67 loc) · 2.94 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
"""Generate remaining chapters + foreshadowing ledger."""
import os
import sys
from pathlib import Path
from dotenv import load_dotenv
BASE_DIR = Path(__file__).parent
load_dotenv(BASE_DIR / ".env")
WRITER_MODEL = os.environ.get("AUTONOVEL_WRITER_MODEL", "claude-sonnet-4-6")
API_KEY = os.environ.get("ANTHROPIC_API_KEY", "")
API_BASE = os.environ.get("AUTONOVEL_API_BASE_URL", "https://api.anthropic.com")
def call_writer(prompt, max_tokens=16000):
import httpx
headers = {
"x-api-key": API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
}
payload = {
"model": WRITER_MODEL,
"max_tokens": max_tokens,
"temperature": 0.5,
"system": (
"You are a novel architect continuing an outline. Write in the same format "
"as the preceding chapters. Every chapter needs: POV, Location, Save the Cat beat, "
"% mark, Emotional arc, Try-fail cycle, Beats, Plants, Payoffs, Character movement, "
"The lie, Word count target."
),
"messages": [{"role": "user", "content": prompt}],
}
resp = httpx.post(f"{API_BASE}/v1/messages", headers=headers, json=payload, timeout=600)
resp.raise_for_status()
return resp.json()["content"][0]["text"]
part1 = open('/tmp/outline_output.md').read()
mystery = (BASE_DIR / "MYSTERY.md").read_text()
prompt = f"""Here are the first 17 chapters of a 24-chapter outline for "The Second Son of the House of Bells."
The outline was cut off mid-chapter-17. Continue from where it left off, then complete chapters 18-24,
then write the Foreshadowing Ledger.
THE OUTLINE SO FAR:
{part1}
THE CENTRAL MYSTERY (for reference):
{mystery}
REMAINING STRUCTURE NEEDED:
Ch 17 (complete it): Maret confrontation -- she reveals the truth about the void
Ch 18: Dark Night of the Soul -- Cass processes what he's learned
Ch 19: Break Into Three -- new information or perspective changes everything
Ch 20-21: Gathering forces, making a plan
Ch 22: The climax at the Bell Tower -- Cass answers the question
Ch 23: Aftermath and resolution
Ch 24: Final Image (mirror of Opening Image)
Then write:
## Foreshadowing Ledger
| # | Thread | Planted (Ch) | Reinforced (Ch) | Payoff (Ch) | Type |
|---|--------|-------------|-----------------|-------------|------|
Include at LEAST 15 threads. Types: object, dialogue, action, symbolic, structural.
Plant-to-payoff distance must be at least 3 chapters.
REMEMBER:
- The climax uses the fourth option: Cass amplifies the question into audible range
so the city can hear and answer for themselves
- This doesn't free Perin directly (Stability Trap -- not everything resolves cleanly)
- Cass's lie must be fully shattered by the climax
- Final Image should mirror Ch 1's Opening Image but show transformation
- At least one quiet chapter in the back half
"""
print("Calling writer model...", file=sys.stderr)
result = call_writer(prompt)
print(result)