Spaces:
Sleeping
Sleeping
import gradio as gr | |
from theory_tools import get_theory, get_theory_topics | |
# Get available topics for dropdown | |
try: | |
topics = get_theory_topics() | |
topic_choices = list(topics.keys()) | |
except Exception: | |
topic_choices = ["Error loading topics"] | |
# Create the Gradio interface with tabs | |
with gr.Blocks(title="Quantum Circuits Learning Programme") as demo: | |
gr.Markdown("# Quantum Circuits Learning Programme") | |
gr.Markdown( | |
"Learn about quantum circuits through interactive content from the Qiskit textbook." | |
) | |
with gr.Tabs(): | |
with gr.TabItem("Browse Topics"): | |
topics_output = gr.JSON(label="Available Topics") | |
topics_btn = gr.Button("Load Available Topics") | |
topics_btn.click(fn=get_theory_topics, outputs=topics_output) | |
with gr.TabItem("Learn Theory"): | |
topic_input = gr.Textbox( | |
label="Enter a Quantum Topic", | |
placeholder="e.g., teleportation, superdense coding, what is quantum", | |
info="Enter the name of a quantum topic to learn about", | |
) | |
theory_output = gr.Markdown(label="Theory Content") | |
theory_btn = gr.Button("Get Theory Content") | |
theory_btn.click(fn=get_theory, inputs=topic_input, outputs=theory_output) | |
# Launch the interface | |
if __name__ == "__main__": | |
demo.launch(mcp_server=True) | |