Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,9 +60,8 @@ with gr.Blocks(title="Math Tutor AI") as demo:
|
|
| 60 |
""")
|
| 61 |
|
| 62 |
chatbot = gr.Chatbot(
|
| 63 |
-
height
|
| 64 |
-
label
|
| 65 |
-
type = "messages",
|
| 66 |
show_copy_button = True,
|
| 67 |
)
|
| 68 |
|
|
@@ -78,8 +77,8 @@ with gr.Blocks(title="Math Tutor AI") as demo:
|
|
| 78 |
clear = gr.Button("ποΈ Clear Chat", variant="secondary")
|
| 79 |
|
| 80 |
gr.Examples(
|
| 81 |
-
label
|
| 82 |
-
examples=[
|
| 83 |
"Solve: 2xΒ² - 7x + 3 = 0",
|
| 84 |
"Find the area of a triangle with base 12 cm and height 8 cm.",
|
| 85 |
"If sin ΞΈ = 3/5, find cos ΞΈ and tan ΞΈ.",
|
|
@@ -87,7 +86,7 @@ with gr.Blocks(title="Math Tutor AI") as demo:
|
|
| 87 |
"Find the compound interest on βΉ5000 at 10% per annum for 2 years.",
|
| 88 |
"Prove that β2 is irrational.",
|
| 89 |
],
|
| 90 |
-
inputs
|
| 91 |
)
|
| 92 |
|
| 93 |
gr.Markdown("""
|
|
@@ -96,8 +95,15 @@ with gr.Blocks(title="Math Tutor AI") as demo:
|
|
| 96 |
""")
|
| 97 |
|
| 98 |
# ββ Event Handlers ββββββββββββββββββββββββββββββββββββββ
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
clear.click(lambda: ([], ""), outputs=[chatbot, question])
|
| 102 |
|
| 103 |
demo.launch(theme=gr.themes.Soft())
|
|
|
|
| 60 |
""")
|
| 61 |
|
| 62 |
chatbot = gr.Chatbot(
|
| 63 |
+
height = 450,
|
| 64 |
+
label = "Math Tutor",
|
|
|
|
| 65 |
show_copy_button = True,
|
| 66 |
)
|
| 67 |
|
|
|
|
| 77 |
clear = gr.Button("ποΈ Clear Chat", variant="secondary")
|
| 78 |
|
| 79 |
gr.Examples(
|
| 80 |
+
label = "Try these examples:",
|
| 81 |
+
examples = [
|
| 82 |
"Solve: 2xΒ² - 7x + 3 = 0",
|
| 83 |
"Find the area of a triangle with base 12 cm and height 8 cm.",
|
| 84 |
"If sin ΞΈ = 3/5, find cos ΞΈ and tan ΞΈ.",
|
|
|
|
| 86 |
"Find the compound interest on βΉ5000 at 10% per annum for 2 years.",
|
| 87 |
"Prove that β2 is irrational.",
|
| 88 |
],
|
| 89 |
+
inputs = question,
|
| 90 |
)
|
| 91 |
|
| 92 |
gr.Markdown("""
|
|
|
|
| 95 |
""")
|
| 96 |
|
| 97 |
# ββ Event Handlers ββββββββββββββββββββββββββββββββββββββ
|
| 98 |
+
def respond_tuple(question, history):
|
| 99 |
+
if not question.strip():
|
| 100 |
+
return "", history
|
| 101 |
+
answer = solve(question, history)
|
| 102 |
+
history = history + [[question, answer]]
|
| 103 |
+
return "", history
|
| 104 |
+
|
| 105 |
+
submit.click(respond_tuple, [question, chatbot], [question, chatbot])
|
| 106 |
+
question.submit(respond_tuple, [question, chatbot], [question, chatbot])
|
| 107 |
clear.click(lambda: ([], ""), outputs=[chatbot, question])
|
| 108 |
|
| 109 |
demo.launch(theme=gr.themes.Soft())
|