Update app.py
Browse files
app.py
CHANGED
@@ -1,75 +1,53 @@
|
|
1 |
-
import gradio as gr
|
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 |
-
|
38 |
-
|
39 |
-
#
|
40 |
-
with gr.
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
)
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
)
|
55 |
-
input_text = gr.Textbox(
|
56 |
-
lines=10,
|
57 |
-
label="Input Text",
|
58 |
-
placeholder="Enter your code or mathematical expression here"
|
59 |
-
)
|
60 |
-
process_button = gr.Button("Process")
|
61 |
-
|
62 |
-
# Output section
|
63 |
-
with gr.Column():
|
64 |
-
gr.Markdown("### Output")
|
65 |
-
output_result = gr.Textbox(lines=15, interactive=False)
|
66 |
-
|
67 |
-
# Link button to function
|
68 |
-
process_button.click(
|
69 |
-
fn=optimize_or_simplify,
|
70 |
-
inputs=[input_text, task_type],
|
71 |
-
outputs=output_result
|
72 |
-
)
|
73 |
-
|
74 |
-
# Launch the app
|
75 |
-
app.launch()
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Define learning paths and corresponding content
|
4 |
+
learning_paths = {
|
5 |
+
"Math": "Welcome to the Math path! Solve problems and explore concepts like algebra, calculus, and geometry.",
|
6 |
+
"Science & Engineering": "Dive into physics, chemistry, and engineering concepts with interactive examples.",
|
7 |
+
"Computer Science & Programming": "Learn programming, algorithms, and computer science fundamentals.",
|
8 |
+
"Data Science & Data Analysis": "Master data manipulation, visualization, and analysis techniques."
|
9 |
+
}
|
10 |
+
|
11 |
+
# Function to display the selected learning path's content
|
12 |
+
def show_learning_content(selected_path):
|
13 |
+
"""
|
14 |
+
Displays content for the selected learning path.
|
15 |
+
"""
|
16 |
+
return f"You selected: {selected_path}\n\n{learning_paths[selected_path]}"
|
17 |
+
|
18 |
+
# Function to simulate feedback or progression
|
19 |
+
def provide_feedback(selected_path):
|
20 |
+
return f"Great choice! Let's dive into {selected_path}."
|
21 |
+
|
22 |
+
# Gradio interface
|
23 |
+
with gr.Blocks() as app:
|
24 |
+
gr.Markdown("## Interactive Learning Platform")
|
25 |
+
gr.Markdown("Choose a topic to start learning:")
|
26 |
+
|
27 |
+
# Progress bar at the top
|
28 |
+
gr.Markdown('<div style="width: 100%; background-color: lightgray; height: 5px; border-radius: 5px;">'
|
29 |
+
'<div style="width: 25%; background-color: green; height: 100%;"></div></div>',
|
30 |
+
unsafe_allow_html=True)
|
31 |
+
|
32 |
+
# Options for learning paths
|
33 |
+
selected_topic = gr.Radio(
|
34 |
+
choices=list(learning_paths.keys()),
|
35 |
+
label="Select a Learning Path",
|
36 |
+
value="Math"
|
37 |
+
)
|
38 |
+
|
39 |
+
# Buttons for user interaction
|
40 |
+
with gr.Row():
|
41 |
+
continue_button = gr.Button("Continue")
|
42 |
+
feedback_button = gr.Button("Get Feedback")
|
43 |
+
|
44 |
+
# Outputs
|
45 |
+
learning_output = gr.Textbox(lines=8, interactive=False, label="Learning Content")
|
46 |
+
feedback_output = gr.Textbox(interactive=False, label="Feedback")
|
47 |
+
|
48 |
+
# Link interactions to actions
|
49 |
+
continue_button.click(fn=show_learning_content, inputs=selected_topic, outputs=learning_output)
|
50 |
+
feedback_button.click(fn=provide_feedback, inputs=selected_topic, outputs=feedback_output)
|
51 |
+
|
52 |
+
# Launch the app
|
53 |
+
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|