Spaces:
Sleeping
Sleeping
#!/usr/bin/env python3 | |
""" | |
Theorem Explanation Agent - Gradio Interface | |
A web interface for generating educational videos explaining mathematical theorems and concepts. | |
""" | |
import gradio as gr | |
def generate_explanation(topic, context, max_scenes): | |
"""Generate educational content explanation.""" | |
if not topic.strip(): | |
return "β Please enter a topic to explain" | |
result = f"""π **Theorem Explanation Agent** | |
π **Topic:** {topic} | |
π **Context:** {context if context else "None specified"} | |
π¬ **Scenes:** {max_scenes} | |
β **Demo Generation Complete!** | |
π― **Generated Educational Content:** | |
β’ Introduction to {topic} | |
β’ Fundamental concepts and definitions | |
β’ Step-by-step mathematical derivation | |
β’ Visual demonstrations and proofs | |
β’ Real-world applications and examples | |
β’ Practice problems and solutions | |
π **Video Specifications:** | |
β’ Duration: ~{max_scenes * 0.8:.1f} minutes | |
β’ Scene count: {max_scenes} | |
β’ Style: Mathematical animations | |
β’ Voiceover: AI-generated narration | |
β οΈ **Demo Mode Active** | |
This is a simulation showing the interface capabilities. | |
In production mode, actual Manim animations would be generated. | |
π **Production Features:** | |
β Manim mathematical animations | |
β AI-powered script generation | |
β Professional voiceover synthesis | |
β Multiple output formats | |
β Custom styling and branding | |
""" | |
return result | |
# Define the interface explicitly | |
iface = gr.Interface( | |
fn=generate_explanation, | |
inputs=[ | |
gr.Textbox( | |
label="π― Mathematical Topic", | |
placeholder="Enter any mathematical concept (e.g., Pythagorean Theorem, Derivatives, etc.)", | |
value="" | |
), | |
gr.Textbox( | |
label="π Additional Context", | |
placeholder="Specify learning level, focus areas, or special requirements (optional)", | |
value="" | |
), | |
gr.Slider( | |
label="π¬ Number of Video Scenes", | |
minimum=1, | |
maximum=8, | |
value=4, | |
step=1, | |
info="More scenes = more detailed explanation" | |
) | |
], | |
outputs=gr.Textbox( | |
label="π Generated Educational Content", | |
lines=20, | |
show_copy_button=True | |
), | |
title="π Theorem Explanation Agent", | |
description="π Generate educational videos explaining mathematical theorems and concepts using AI-powered animations", | |
examples=[ | |
["Pythagorean Theorem", "Include visual proof and real-world applications", 4], | |
["Calculus Derivatives", "Focus on geometric interpretation for beginners", 5], | |
["Newton's Laws of Motion", "Physics applications with practical examples", 3], | |
["Quadratic Formula", "Step-by-step derivation with examples", 4], | |
["Probability Distributions", "Visual explanations with real-world data", 5] | |
], | |
theme=gr.themes.Soft(), | |
css="footer {visibility: hidden}" | |
) | |
# Export for HF Spaces | |
demo = iface | |
if __name__ == "__main__": | |
demo.launch() |