-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
76 lines (62 loc) · 2.11 KB
/
main.py
File metadata and controls
76 lines (62 loc) · 2.11 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
"""
Main Pipeline
Orchestrates the multi-agent book writing workflow.
"""
from agents.planner import run_planner
from agents.researcher import run_researcher
from agents.writer import run_writer
from agents.editor import run_editor
from shared.context import get_context
import time
def run_pipeline(num_chapters=5):
"""
Execute the complete book writing pipeline.
Args:
num_chapters: Number of chapters to generate
"""
print("=" * 60)
print("MULTI-AGENT BOOK WRITER")
print("=" * 60)
print()
start_time = time.time()
try:
# Step 1: Planning Phase
print("\n[PIPELINE] Step 1: Planning Phase")
print("-" * 60)
chapters = run_planner(num_chapters)
if not chapters:
print("[PIPELINE] Planning failed. Exiting.")
return
# Step 2: Research Phase
print("\n[PIPELINE] Step 2: Research Phase")
print("-" * 60)
run_researcher()
# Step 3: Writing Phase
print("\n[PIPELINE] Step 3: Writing Phase")
print("-" * 60)
run_writer()
# Step 4: Editing Phase
print("\n[PIPELINE] Step 4: Editing Phase")
print("-" * 60)
run_editor()
# Summary
end_time = time.time()
elapsed_time = end_time - start_time
context = get_context()
print("\n" + "=" * 60)
print("PIPELINE COMPLETE!")
print("=" * 60)
print(f"Title: {context['title']}")
print(f"Chapters: {len(context['chapters'])}")
print(f"Total time: {elapsed_time:.2f} seconds")
print(f"Output: output/draft.txt")
print("=" * 60)
except Exception as e:
print(f"\n[PIPELINE] Error: {str(e)}")
raise
if __name__ == "__main__":
import sys
# Get number of chapters from command line or use default
num_chapters = int(sys.argv[1]) if len(sys.argv) > 1 else 5
run_pipeline(num_chapters)
print("\n✓ Book written! Check output/draft.txt")