Aivis commited on
Commit
95bac5d
·
verified ·
1 Parent(s): 86fb94a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -224,7 +224,7 @@ with gr.Blocks() as demo:
224
  content_dict = get_topic_content(topic_code)
225
  return gr.update(choices=list(content_dict.keys()), visible=True), content_dict, topic_code
226
 
227
- def update_reports(topic_content_name:str, content_dict:dict)-> Tuple[Any, Dict[str, str], str]:
228
  """
229
  Updates the UI dropdown menu with available report titles for a selected topic content,
230
  and returns the titles dictionary and the corresponding content code.
@@ -233,7 +233,7 @@ with gr.Blocks() as demo:
233
  topic_content_name (str): The name of the selected topic content (e.g., "Darba samaksa (algas)").
234
  Topic content you can get from `update_topic_content` (`content_dict` object).
235
  content_dict (dict): A dictionary mapping topic content names to their corresponding content codes.
236
- Typically obtained from `update_topic_content` (`content_dict` object).
237
 
238
  Returns:
239
  tuple:
@@ -252,7 +252,7 @@ with gr.Blocks() as demo:
252
  """
253
  topic_content_code = content_dict[topic_content_name]
254
  titles_dict = get_titles(topic_content_code)
255
- return gr.update(choices=list(titles_dict.keys()), visible=True), titles_dict, topic_content_code
256
 
257
  def update_topic_params_and_link(report_title:str, titles_dict:str)-> Tuple[str, Any, Any]:
258
  """
@@ -311,7 +311,7 @@ with gr.Blocks() as demo:
311
 
312
  topic_dropdown.change(fn=update_topic_content, inputs=topic_dropdown, outputs=[topic_content_dropdown, topic_content_state, topic_code_state])
313
  topic_content_dropdown.change(fn=update_reports, inputs=[topic_content_dropdown, topic_content_state], #, topic_code_state],
314
- outputs=[report_dropdown, titles_state, topic_content_code_state])
315
  report_dropdown.change(fn=update_topic_params_and_link, inputs=[report_dropdown, titles_state], #, topic_code_state, topic_content_code_state],
316
  outputs=[topic_params_box, link_output, kwargs_box])
317
 
 
224
  content_dict = get_topic_content(topic_code)
225
  return gr.update(choices=list(content_dict.keys()), visible=True), content_dict, topic_code
226
 
227
+ def update_reports(topic_content_name:str, content_dict:dict)-> Tuple[Dict[str, str], str, Any]:
228
  """
229
  Updates the UI dropdown menu with available report titles for a selected topic content,
230
  and returns the titles dictionary and the corresponding content code.
 
233
  topic_content_name (str): The name of the selected topic content (e.g., "Darba samaksa (algas)").
234
  Topic content you can get from `update_topic_content` (`content_dict` object).
235
  content_dict (dict): A dictionary mapping topic content names to their corresponding content codes.
236
+ Obtained from `update_topic_content` (2nd returned object: `content_dict`).
237
 
238
  Returns:
239
  tuple:
 
252
  """
253
  topic_content_code = content_dict[topic_content_name]
254
  titles_dict = get_titles(topic_content_code)
255
+ return titles_dict, topic_content_code, gr.update(choices=list(titles_dict.keys()), visible=True)
256
 
257
  def update_topic_params_and_link(report_title:str, titles_dict:str)-> Tuple[str, Any, Any]:
258
  """
 
311
 
312
  topic_dropdown.change(fn=update_topic_content, inputs=topic_dropdown, outputs=[topic_content_dropdown, topic_content_state, topic_code_state])
313
  topic_content_dropdown.change(fn=update_reports, inputs=[topic_content_dropdown, topic_content_state], #, topic_code_state],
314
+ outputs=[titles_state, topic_content_code_state, report_dropdown])
315
  report_dropdown.change(fn=update_topic_params_and_link, inputs=[report_dropdown, titles_state], #, topic_code_state, topic_content_code_state],
316
  outputs=[topic_params_box, link_output, kwargs_box])
317