bhardwaj08sarthak commited on
Commit
97fda2b
·
verified ·
1 Parent(s): cb1db7c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -45,6 +45,9 @@ EXAMPLE_UPLOAD_FILES = [
45
  EXAMPLE_UPLOAD_DIR / "About Riverstone.docx",
46
  EXAMPLE_UPLOAD_DIR / "Matt.xlsx",
47
  ]
 
 
 
48
 
49
 
50
  # --- character wiki upload/build/download -----------------------------------
@@ -346,6 +349,11 @@ def build_uploaded_wikis(uploaded_files, existing_wiki_json):
346
  )
347
 
348
 
 
 
 
 
 
349
  # --- record access -----------------------------------------------------------
350
 
351
 
@@ -640,11 +648,13 @@ with gr.Blocks(title="Vernacular - Riverstone Translation Review") as demo:
640
  file_count="multiple",
641
  file_types=[".doc", ".docx", ".xls", ".xlsx", ".json", ".txt", ".csv"],
642
  )
643
- gr.Examples(
644
- examples=[[str(path)] for path in EXAMPLE_UPLOAD_FILES if path.exists()],
645
- inputs=wiki_source_files,
646
- label="Example source files",
647
- )
 
 
648
  existing_wiki_json = gr.File(
649
  label="Upload existing wiki JSON",
650
  file_count="single",
@@ -733,6 +743,11 @@ with gr.Blocks(title="Vernacular - Riverstone Translation Review") as demo:
733
  [wiki_source_files, existing_wiki_json],
734
  [wiki_build_status, wiki_json_file, uploaded_review_files],
735
  )
 
 
 
 
 
736
 
737
  if __name__ == "__main__":
738
  demo.launch()
 
45
  EXAMPLE_UPLOAD_DIR / "About Riverstone.docx",
46
  EXAMPLE_UPLOAD_DIR / "Matt.xlsx",
47
  ]
48
+ EXAMPLE_UPLOAD_CHOICES = [
49
+ (path.name, str(path)) for path in EXAMPLE_UPLOAD_FILES if path.exists()
50
+ ]
51
 
52
 
53
  # --- character wiki upload/build/download -----------------------------------
 
349
  )
350
 
351
 
352
+ def load_selected_examples(selected_examples):
353
+ selected_examples = selected_examples or []
354
+ return gr.update(value=selected_examples)
355
+
356
+
357
  # --- record access -----------------------------------------------------------
358
 
359
 
 
648
  file_count="multiple",
649
  file_types=[".doc", ".docx", ".xls", ".xlsx", ".json", ".txt", ".csv"],
650
  )
651
+ with gr.Row():
652
+ example_files = gr.CheckboxGroup(
653
+ choices=EXAMPLE_UPLOAD_CHOICES,
654
+ label="Example source files",
655
+ interactive=True,
656
+ )
657
+ load_examples_btn = gr.Button("Use selected examples", scale=1)
658
  existing_wiki_json = gr.File(
659
  label="Upload existing wiki JSON",
660
  file_count="single",
 
743
  [wiki_source_files, existing_wiki_json],
744
  [wiki_build_status, wiki_json_file, uploaded_review_files],
745
  )
746
+ load_examples_btn.click(
747
+ load_selected_examples,
748
+ [example_files],
749
+ [wiki_source_files],
750
+ )
751
 
752
  if __name__ == "__main__":
753
  demo.launch()