manuelcozar55 commited on
Commit
0d6e3a2
verified
1 Parent(s): f74fdd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -14
app.py CHANGED
@@ -158,23 +158,24 @@ with gr.Blocks() as demo:
158
  action = gr.Radio(label="Seleccione una acci贸n", choices=["Resumen", "Clasificar", "Traducir"])
159
  target_language = gr.Dropdown(label="Seleccionar idioma de traducci贸n", choices=["en", "fr", "de"], visible=False)
160
  summary_length = gr.Radio(label="Seleccione la longitud del resumen", choices=["Corto", "Medio", "Largo"], visible=False)
 
 
161
 
162
  with gr.Column():
163
  output_text = gr.Textbox(label="Resultado", lines=20)
164
- question = gr.Textbox(label="Hacer una pregunta al documento", lines=2, visible=False)
165
- answer = gr.Textbox(label="Respuesta", lines=2, interactive=False, visible=False)
166
 
167
  def update_visible_elements(action):
168
  if action == "Traducir":
169
- return gr.update(visible=True), gr.update(visible=False), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False))
170
  elif action == "Resumen":
171
- return gr.update(visible(False)), gr.update(visible(True)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False))
172
  elif action == "Clasificar":
173
- return gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(True)), gr.update(visible(True)), gr.update(visible(True))
174
  else:
175
- return gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False))
176
 
177
- action.change(update_visible_elements, inputs=action, outputs=[target_language, summary_length, question, output_text, answer])
178
 
179
  submit_button = gr.Button("Procesar")
180
  submit_button.click(process_file, inputs=[file, action, target_language, summary_length], outputs=output_text)
@@ -188,17 +189,11 @@ with gr.Blocks() as demo:
188
  download_button = gr.Button("Descargar Resultado")
189
  download_button.click(
190
  fn=generate_file,
191
- inputs=[output_text],
192
  outputs=gr.File()
193
  )
194
 
195
- question_button = gr.Button("Hacer Pregunta")
196
  question_button.click(answer_question, inputs=[output_text, question], outputs=answer)
197
 
198
- with gr.Row():
199
- question.render()
200
- question_button.render()
201
- answer.render()
202
-
203
  # Ejecutar la aplicaci贸n Gradio
204
  demo.launch(share=True)
 
158
  action = gr.Radio(label="Seleccione una acci贸n", choices=["Resumen", "Clasificar", "Traducir"])
159
  target_language = gr.Dropdown(label="Seleccionar idioma de traducci贸n", choices=["en", "fr", "de"], visible=False)
160
  summary_length = gr.Radio(label="Seleccione la longitud del resumen", choices=["Corto", "Medio", "Largo"], visible=False)
161
+ question = gr.Textbox(label="Hacer una pregunta al documento", lines=1, visible=False)
162
+ question_button = gr.Button("Enviar Pregunta", visible=False)
163
 
164
  with gr.Column():
165
  output_text = gr.Textbox(label="Resultado", lines=20)
166
+ answer = gr.Textbox(label="Respuesta", lines=1, interactive=False, visible=False)
 
167
 
168
  def update_visible_elements(action):
169
  if action == "Traducir":
170
+ return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible(False)), gr.update(visible(False))
171
  elif action == "Resumen":
172
+ return gr.update(visible(False)), gr.update(visible(True)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False))
173
  elif action == "Clasificar":
174
+ return gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(True)), gr.update(visible(True)), gr.update(visible(True)), gr.update(visible(True))
175
  else:
176
+ return gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False)), gr.update(visible(False))
177
 
178
+ action.change(update_visible_elements, inputs=action, outputs=[target_language, summary_length, question, question_button, output_text, answer])
179
 
180
  submit_button = gr.Button("Procesar")
181
  submit_button.click(process_file, inputs=[file, action, target_language, summary_length], outputs=output_text)
 
189
  download_button = gr.Button("Descargar Resultado")
190
  download_button.click(
191
  fn=generate_file,
192
+ inputs=[],
193
  outputs=gr.File()
194
  )
195
 
 
196
  question_button.click(answer_question, inputs=[output_text, question], outputs=answer)
197
 
 
 
 
 
 
198
  # Ejecutar la aplicaci贸n Gradio
199
  demo.launch(share=True)