newtechdevng commited on
Commit
e083b3d
Β·
verified Β·
1 Parent(s): 01d976b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -60,9 +60,8 @@ with gr.Blocks(title="Math Tutor AI") as demo:
60
  """)
61
 
62
  chatbot = gr.Chatbot(
63
- height = 450,
64
- label = "Math Tutor",
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 = "Try these examples:",
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 = question,
91
  )
92
 
93
  gr.Markdown("""
@@ -96,8 +95,15 @@ with gr.Blocks(title="Math Tutor AI") as demo:
96
  """)
97
 
98
  # ── Event Handlers ──────────────────────────────────────
99
- submit.click(respond, [question, chatbot], [question, chatbot])
100
- question.submit(respond, [question, chatbot], [question, chatbot])
 
 
 
 
 
 
 
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())