mgbam commited on
Commit
eb9907d
·
verified ·
1 Parent(s): b80eb6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -51,21 +51,22 @@ voice_agent = Agent(
51
  "Create a 1-2 minute voiceover script. Return JSON with key 'script'."
52
  )
53
 
54
- # Orchestrator
55
  document_orchestrator = Agent(
56
  name="Workshop Orchestrator",
57
  instructions="Invoke: topic_agent, content_agent, slide_agent, code_agent, voice_agent (optional); collect outputs.",
58
  handoffs=[
59
- handoff(topic_agent, name="outline"),
60
- handoff(content_agent, name="content"),
61
- handoff(slide_agent, name="slides"),
62
- handoff(code_agent, name="code_labs"),
63
- handoff(voice_agent, name="voiceover", optional=True),
64
  ]
65
  )
66
 
67
  runner = Runner()
68
 
 
69
  def build_workshop_bundle(topic: str, audience: str):
70
  prompt = f"Create a {topic} workshop for {audience}."
71
  results = runner.run(document_orchestrator, prompt).outputs
@@ -76,13 +77,13 @@ def build_workshop_bundle(topic: str, audience: str):
76
  if isinstance(voice_info, dict) and "script" in voice_info:
77
  audio_path = generate_tts_audio(voice_info["script"])
78
 
79
- # Render slides
80
  slides_json = results.get("slides", {})
81
  with open("static/slides_template.html") as f:
82
  template = f.read()
83
  slide_html = template.replace("{{SLIDES_JSON}}", json.dumps(slides_json))
84
 
85
- # Bundle into ZIP
86
  tmpdir = tempfile.mkdtemp()
87
  zip_path = os.path.join(tmpdir, "workshop_bundle.zip")
88
  with ZipFile(zip_path, "w") as zipf:
@@ -100,7 +101,7 @@ def build_workshop_bundle(topic: str, audience: str):
100
  zipf.write(audio_path, os.path.basename(audio_path))
101
  return slide_html, audio_path, zip_path
102
 
103
- # Gradio UI
104
  def run_app(topic, audience):
105
  return build_workshop_bundle(topic, audience)
106
 
 
51
  "Create a 1-2 minute voiceover script. Return JSON with key 'script'."
52
  )
53
 
54
+ # Orchestrator with corrected handoff signature
55
  document_orchestrator = Agent(
56
  name="Workshop Orchestrator",
57
  instructions="Invoke: topic_agent, content_agent, slide_agent, code_agent, voice_agent (optional); collect outputs.",
58
  handoffs=[
59
+ handoff(topic_agent, "outline"),
60
+ handoff(content_agent, "content"),
61
+ handoff(slide_agent, "slides"),
62
+ handoff(code_agent, "code_labs"),
63
+ handoff(voice_agent, "voiceover", optional=True),
64
  ]
65
  )
66
 
67
  runner = Runner()
68
 
69
+ # Bundle builder
70
  def build_workshop_bundle(topic: str, audience: str):
71
  prompt = f"Create a {topic} workshop for {audience}."
72
  results = runner.run(document_orchestrator, prompt).outputs
 
77
  if isinstance(voice_info, dict) and "script" in voice_info:
78
  audio_path = generate_tts_audio(voice_info["script"])
79
 
80
+ # Render slides to HTML
81
  slides_json = results.get("slides", {})
82
  with open("static/slides_template.html") as f:
83
  template = f.read()
84
  slide_html = template.replace("{{SLIDES_JSON}}", json.dumps(slides_json))
85
 
86
+ # Bundle outputs into ZIP
87
  tmpdir = tempfile.mkdtemp()
88
  zip_path = os.path.join(tmpdir, "workshop_bundle.zip")
89
  with ZipFile(zip_path, "w") as zipf:
 
101
  zipf.write(audio_path, os.path.basename(audio_path))
102
  return slide_html, audio_path, zip_path
103
 
104
+ # Gradio UI setup
105
  def run_app(topic, audience):
106
  return build_workshop_bundle(topic, audience)
107