Jaward commited on
Commit
daa52a0
·
verified ·
1 Parent(s): ff0b57d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -114,6 +114,7 @@ def create_slides(slides: list[dict], title: str, output_dir: str = OUTPUT_DIR)
114
  slide_number = i + 1
115
  md_content = slide['content']
116
  html_content = render_md_to_html(md_content)
 
117
 
118
  # Replace placeholders in the template
119
  slide_html = template_content.replace("<!--SLIDE_NUMBER-->", str(slide_number))
@@ -121,7 +122,7 @@ def create_slides(slides: list[dict], title: str, output_dir: str = OUTPUT_DIR)
121
  slide_html = slide_html.replace("Lecture title", title)
122
  slide_html = slide_html.replace("<!--CONTENT-->", html_content)
123
  slide_html = slide_html.replace("speaker name", "Prof. AI Feynman")
124
- slide_html = slide_html.replace("date", "May 2nd, 2025")
125
 
126
  html_file = os.path.join(output_dir, f"slide_{slide_number}.html")
127
  with open(html_file, "w", encoding="utf-8") as f:
@@ -407,6 +408,7 @@ async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_
407
  # Total slides include user-specified content slides plus Introduction and Closing slides
408
  content_slides = num_slides
409
  total_slides = content_slides + 2
 
410
 
411
  research_agent = AssistantAgent(
412
  name="research_agent",
@@ -422,7 +424,7 @@ async def on_generate(api_service, api_key, serpapi_key, title, lecture_content_
422
  system_message=f"""
423
  You are a Slide Agent. Using the research from the conversation history and the specified number of content slides ({content_slides}), generate exactly {content_slides} content slides, plus an Introduction slide as the first slide and a Closing slide as the last slide, making a total of {total_slides} slides.
424
 
425
- - The Introduction slide (first slide) should have the title "Introduction to {title}" and content containing only the lecture title, speaker name (Prof. AI Feynman), and date (May 2nd, 2025), centered, in plain text.
426
  - The Closing slide (last slide) should have the title "Closing" and content containing only "The End\nThank you", centered, in plain text.
427
  - The remaining {content_slides} slides should be content slides based on the lecture description and audience type, with meaningful titles and content in valid Markdown format.
428
 
@@ -1260,7 +1262,7 @@ with gr.Blocks(
1260
  api_key = gr.Textbox(label="Model Provider API Key", type="password", placeholder="Not required for Ollama or Azure AI Foundry (use GITHUB_TOKEN env var)")
1261
  serpapi_key = gr.Textbox(label="SerpApi Key (For Research Agent)", type="password", placeholder="Enter your SerpApi key (optional)")
1262
  num_slides = gr.Slider(1, 20, step=1, label="Number of Lecture Slides (will add intro and closing slides)", value=3)
1263
- speaker_audio = gr.Audio(label="Speaker sample speech (MP3 or WAV)", type="filepath", elem_id="speaker-audio")
1264
  generate_btn = gr.Button("Generate Lecture")
1265
  with gr.Column(scale=2):
1266
  default_slide_html = """
 
114
  slide_number = i + 1
115
  md_content = slide['content']
116
  html_content = render_md_to_html(md_content)
117
+ date = datetime.datetime.now().strftime("%Y-%m-%d")
118
 
119
  # Replace placeholders in the template
120
  slide_html = template_content.replace("<!--SLIDE_NUMBER-->", str(slide_number))
 
122
  slide_html = slide_html.replace("Lecture title", title)
123
  slide_html = slide_html.replace("<!--CONTENT-->", html_content)
124
  slide_html = slide_html.replace("speaker name", "Prof. AI Feynman")
125
+ slide_html = slide_html.replace("date", date)
126
 
127
  html_file = os.path.join(output_dir, f"slide_{slide_number}.html")
128
  with open(html_file, "w", encoding="utf-8") as f:
 
408
  # Total slides include user-specified content slides plus Introduction and Closing slides
409
  content_slides = num_slides
410
  total_slides = content_slides + 2
411
+ date = datetime.datetime.now().strftime("%Y-%m-%d")
412
 
413
  research_agent = AssistantAgent(
414
  name="research_agent",
 
424
  system_message=f"""
425
  You are a Slide Agent. Using the research from the conversation history and the specified number of content slides ({content_slides}), generate exactly {content_slides} content slides, plus an Introduction slide as the first slide and a Closing slide as the last slide, making a total of {total_slides} slides.
426
 
427
+ - The Introduction slide (first slide) should have the title "Introduction to {title}" and content containing only the lecture title, speaker name (Prof. AI Feynman), and date {date}, centered, in plain text.
428
  - The Closing slide (last slide) should have the title "Closing" and content containing only "The End\nThank you", centered, in plain text.
429
  - The remaining {content_slides} slides should be content slides based on the lecture description and audience type, with meaningful titles and content in valid Markdown format.
430
 
 
1262
  api_key = gr.Textbox(label="Model Provider API Key", type="password", placeholder="Not required for Ollama or Azure AI Foundry (use GITHUB_TOKEN env var)")
1263
  serpapi_key = gr.Textbox(label="SerpApi Key (For Research Agent)", type="password", placeholder="Enter your SerpApi key (optional)")
1264
  num_slides = gr.Slider(1, 20, step=1, label="Number of Lecture Slides (will add intro and closing slides)", value=3)
1265
+ speaker_audio = gr.Audio(value="feynman.mp3", label="Speaker sample speech (MP3 or WAV)", type="filepath", elem_id="speaker-audio")
1266
  generate_btn = gr.Button("Generate Lecture")
1267
  with gr.Column(scale=2):
1268
  default_slide_html = """