Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -192,29 +192,35 @@ def submit_feedback(question, model_answer, feedback, correct_answer):
|
|
192 |
# === Gradio UI ===
|
193 |
with gr.Blocks() as demo:
|
194 |
gr.Markdown("## ๐งฎ Math Question Answering with DSPy + Feedback")
|
195 |
-
|
196 |
-
with gr.Tab("Ask a Math Question"):
|
197 |
with gr.Row():
|
198 |
question_input = gr.Textbox(label="Enter your math question", lines=2)
|
|
|
|
|
199 |
gr.Markdown("### ๐ง Answer:")
|
200 |
answer_output = gr.Markdown()
|
201 |
|
202 |
-
#
|
203 |
hidden_q = gr.Textbox(visible=False)
|
204 |
hidden_a = gr.Textbox(visible=False)
|
205 |
-
|
|
|
206 |
submit_btn.click(fn=ask_question, inputs=[question_input], outputs=[answer_output, hidden_q, hidden_a])
|
207 |
|
208 |
-
|
209 |
-
gr.
|
210 |
-
|
211 |
-
fb_answer = gr.Textbox(label="Model's Answer")
|
212 |
-
fb_like = gr.Radio(["๐", "๐"], label="Your Feedback")
|
213 |
-
fb_correct = gr.Textbox(label="Correct Answer (optional)")
|
214 |
fb_submit_btn = gr.Button("Submit Feedback")
|
215 |
fb_status = gr.Textbox(label="Status", interactive=False)
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
demo.launch(share=True, debug=True)
|
|
|
192 |
# === Gradio UI ===
|
193 |
with gr.Blocks() as demo:
|
194 |
gr.Markdown("## ๐งฎ Math Question Answering with DSPy + Feedback")
|
195 |
+
|
196 |
+
with gr.Tab("Ask a Math Question & Submit Feedback"):
|
197 |
with gr.Row():
|
198 |
question_input = gr.Textbox(label="Enter your math question", lines=2)
|
199 |
+
submit_btn = gr.Button("Get Answer")
|
200 |
+
|
201 |
gr.Markdown("### ๐ง Answer:")
|
202 |
answer_output = gr.Markdown()
|
203 |
|
204 |
+
# Hidden fields to hold question and answer for feedback inputs
|
205 |
hidden_q = gr.Textbox(visible=False)
|
206 |
hidden_a = gr.Textbox(visible=False)
|
207 |
+
|
208 |
+
# Connect submit button to ask_question function
|
209 |
submit_btn.click(fn=ask_question, inputs=[question_input], outputs=[answer_output, hidden_q, hidden_a])
|
210 |
|
211 |
+
gr.Markdown("### ๐ Submit Feedback")
|
212 |
+
fb_like = gr.Radio(["๐", "๐"], label="Was the answer helpful?")
|
213 |
+
fb_correct = gr.Textbox(label="Correct Answer (optional) or Comments")
|
|
|
|
|
|
|
214 |
fb_submit_btn = gr.Button("Submit Feedback")
|
215 |
fb_status = gr.Textbox(label="Status", interactive=False)
|
216 |
+
|
217 |
+
# Feedback submit button uses hidden fields + feedback inputs
|
218 |
+
fb_submit_btn.click(
|
219 |
+
fn=submit_feedback,
|
220 |
+
inputs=[hidden_q, hidden_a, fb_like, fb_correct],
|
221 |
+
outputs=[fb_status]
|
222 |
+
)
|
223 |
+
|
224 |
+
|
225 |
|
226 |
demo.launch(share=True, debug=True)
|