AdhamAshraf commited on
Commit
2f4c802
·
verified ·
1 Parent(s): bf6c1ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -120,6 +120,17 @@ def save_feedback(egyptian_input, generated_output, correct_incorrect, rating, c
120
  except Exception as e:
121
  return f"⚠️ Feedback could not be saved: {str(e)}"
122
 
 
 
 
 
 
 
 
 
 
 
 
123
  # ==============================================
124
  # GRADIO INTERFACE
125
  # ==============================================
@@ -174,17 +185,8 @@ with gr.Blocks(title="SlangGPT Translator") as demo:
174
  inputs=[egyptian_input, latest_translation, correct_radio, rating_slider, correction_textbox],
175
  outputs=feedback_status
176
  ).then(
177
- lambda: gr.update(visible=False),
178
- outputs=feedback_group
179
- ).then(
180
- lambda: gr.update(value=""),
181
- outputs=correction_textbox
182
- ).then(
183
- lambda: gr.update(value="Yes"),
184
- outputs=correct_radio
185
- ).then(
186
- lambda: gr.update(value=None),
187
- outputs=rating_slider
188
  )
189
 
190
  gr.Markdown("### Examples")
 
120
  except Exception as e:
121
  return f"⚠️ Feedback could not be saved: {str(e)}"
122
 
123
+ # ==============================================
124
+ # RESET UI — ONE ROUND TRIP INSTEAD OF FOUR
125
+ # ==============================================
126
+ def reset_feedback_ui():
127
+ return (
128
+ gr.update(visible=False), # feedback_group
129
+ gr.update(value=""), # correction_textbox
130
+ gr.update(value="Yes"), # correct_radio
131
+ gr.update(value=None), # rating_slider
132
+ )
133
+
134
  # ==============================================
135
  # GRADIO INTERFACE
136
  # ==============================================
 
185
  inputs=[egyptian_input, latest_translation, correct_radio, rating_slider, correction_textbox],
186
  outputs=feedback_status
187
  ).then(
188
+ fn=reset_feedback_ui,
189
+ outputs=[feedback_group, correction_textbox, correct_radio, rating_slider]
 
 
 
 
 
 
 
 
 
190
  )
191
 
192
  gr.Markdown("### Examples")