File size: 1,535 Bytes
22cc337
eba4c06
22cc337
eba4c06
 
 
 
 
 
 
 
 
 
 
22cc337
eba4c06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22cc337
eba4c06
22cc337
7d3769d
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
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 as e:
    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_input = gr.Textbox(label="Enter query (or leave empty)", placeholder="Optional: enter a search term")
            topics_output = gr.JSON(label="Available Topics")
            topics_btn = gr.Button("Load Available Topics")
            topics_btn.click(fn=get_theory_topics, inputs=topics_input, 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)