Spaces:
Sleeping
Sleeping
File size: 1,388 Bytes
22cc337 eba4c06 22cc337 eba4c06 17aca7c eba4c06 17aca7c eba4c06 0a9b724 17aca7c eba4c06 17aca7c eba4c06 22cc337 eba4c06 22cc337 17aca7c |
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 |
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)
|