manasagangotri commited on
Commit
0e643c9
ยท
verified ยท
1 Parent(s): 9aeba3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -13
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
- #answer_output = gr.Markdown(label="Answer")
203
  hidden_q = gr.Textbox(visible=False)
204
  hidden_a = gr.Textbox(visible=False)
205
- submit_btn = gr.Button("Get Answer")
 
206
  submit_btn.click(fn=ask_question, inputs=[question_input], outputs=[answer_output, hidden_q, hidden_a])
207
 
208
- with gr.Tab("Submit Feedback"):
209
- gr.Markdown("### Was the answer helpful?")
210
- fb_question = gr.Textbox(label="Original Question")
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
- fb_submit_btn.click(fn=submit_feedback,
217
- inputs=[fb_question, fb_answer, fb_like, fb_correct],
218
- outputs=[fb_status])
 
 
 
 
 
 
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)