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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -17
app.py CHANGED
@@ -76,7 +76,7 @@ def translate_to_msa(egyptian_text):
76
  outputs = model.generate(
77
  **inputs,
78
  max_new_tokens=48,
79
- do_sample=False, # greedy — much faster than sampling
80
  repetition_penalty=1.3,
81
  pad_token_id=tokenizer.pad_token_id,
82
  eos_token_id=tokenizer.eos_token_id,
@@ -120,14 +120,6 @@ 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
- # HELPER TO SHOW/HIDE CORRECTION TEXTBOX
125
- # ==============================================
126
- def toggle_correction_box(choice):
127
- if choice == "No":
128
- return gr.update(visible=True)
129
- return gr.update(visible=False, value="")
130
-
131
  # ==============================================
132
  # GRADIO INTERFACE
133
  # ==============================================
@@ -152,9 +144,9 @@ with gr.Blocks(title="SlangGPT Translator") as demo:
152
  value="Yes"
153
  )
154
  correction_textbox = gr.Textbox(
155
- label="If incorrect, please provide the correct MSA translation (optional)",
156
  lines=2,
157
- visible=False,
158
  placeholder="Example: اذهب إلى المنزل"
159
  )
160
  rating_slider = gr.Slider(
@@ -177,12 +169,6 @@ with gr.Blocks(title="SlangGPT Translator") as demo:
177
  outputs=[feedback_group, latest_translation]
178
  )
179
 
180
- correct_radio.change(
181
- fn=toggle_correction_box,
182
- inputs=correct_radio,
183
- outputs=correction_textbox
184
- )
185
-
186
  submit_feedback.click(
187
  fn=save_feedback,
188
  inputs=[egyptian_input, latest_translation, correct_radio, rating_slider, correction_textbox],
 
76
  outputs = model.generate(
77
  **inputs,
78
  max_new_tokens=48,
79
+ do_sample=False,
80
  repetition_penalty=1.3,
81
  pad_token_id=tokenizer.pad_token_id,
82
  eos_token_id=tokenizer.eos_token_id,
 
120
  except Exception as e:
121
  return f"⚠️ Feedback could not be saved: {str(e)}"
122
 
 
 
 
 
 
 
 
 
123
  # ==============================================
124
  # GRADIO INTERFACE
125
  # ==============================================
 
144
  value="Yes"
145
  )
146
  correction_textbox = gr.Textbox(
147
+ label="Correct MSA translation (optional fill only if incorrect)",
148
  lines=2,
149
+ visible=True,
150
  placeholder="Example: اذهب إلى المنزل"
151
  )
152
  rating_slider = gr.Slider(
 
169
  outputs=[feedback_group, latest_translation]
170
  )
171
 
 
 
 
 
 
 
172
  submit_feedback.click(
173
  fn=save_feedback,
174
  inputs=[egyptian_input, latest_translation, correct_radio, rating_slider, correction_textbox],