siddhartharya commited on
Commit
e74958a
·
verified ·
1 Parent(s): 6801885

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -18
app.py CHANGED
@@ -464,8 +464,6 @@ def process_uploaded_file(file, state_bookmarks):
464
  return (
465
  "⚠️ Please upload a bookmarks HTML file.",
466
  "",
467
- gr.update(choices=[]),
468
- display_bookmarks(),
469
  state_bookmarks # Return the unchanged state
470
  )
471
 
@@ -476,8 +474,6 @@ def process_uploaded_file(file, state_bookmarks):
476
  return (
477
  "⚠️ Error decoding the file. Please ensure it's a valid HTML file.",
478
  "",
479
- gr.update(choices=[]),
480
- display_bookmarks(),
481
  state_bookmarks # Return the unchanged state
482
  )
483
 
@@ -488,8 +484,6 @@ def process_uploaded_file(file, state_bookmarks):
488
  return (
489
  "⚠️ Error parsing the bookmarks HTML file.",
490
  "",
491
- gr.update(choices=[]),
492
- display_bookmarks(),
493
  state_bookmarks # Return the unchanged state
494
  )
495
 
@@ -498,8 +492,6 @@ def process_uploaded_file(file, state_bookmarks):
498
  return (
499
  "⚠️ No bookmarks found in the uploaded file.",
500
  "",
501
- gr.update(choices=[]),
502
- display_bookmarks(),
503
  state_bookmarks # Return the unchanged state
504
  )
505
 
@@ -524,8 +516,6 @@ def process_uploaded_file(file, state_bookmarks):
524
  return (
525
  "⚠️ Error building search index.",
526
  "",
527
- gr.update(choices=[]),
528
- display_bookmarks(),
529
  state_bookmarks # Return the unchanged state
530
  )
531
 
@@ -539,8 +529,6 @@ def process_uploaded_file(file, state_bookmarks):
539
  return (
540
  message,
541
  bookmark_html,
542
- gr.update(choices=choices, value=[]),
543
- bookmark_html,
544
  bookmarks.copy() # Return the updated state
545
  )
546
 
@@ -550,7 +538,7 @@ def delete_selected_bookmarks(selected_indices, state_bookmarks):
550
  """
551
  global bookmarks, faiss_index
552
  if not selected_indices:
553
- return "⚠️ No bookmarks selected.", gr.update(choices=[]), display_bookmarks(), state_bookmarks
554
 
555
  ids_to_delete = []
556
  indices_to_delete = []
@@ -581,7 +569,7 @@ def delete_selected_bookmarks(selected_indices, state_bookmarks):
581
  return (
582
  message,
583
  gr.update(choices=choices, value=[]),
584
- display_bookmarks(),
585
  bookmarks.copy() # Return the updated state
586
  )
587
 
@@ -593,14 +581,14 @@ def edit_selected_bookmarks_category(selected_indices, new_category, state_bookm
593
  return (
594
  "⚠️ No bookmarks selected.",
595
  gr.update(choices=[]),
596
- display_bookmarks(),
597
  state_bookmarks
598
  )
599
  if not new_category:
600
  return (
601
  "⚠️ No new category selected.",
602
  gr.update(choices=[]),
603
- display_bookmarks(),
604
  state_bookmarks
605
  )
606
 
@@ -623,7 +611,7 @@ def edit_selected_bookmarks_category(selected_indices, new_category, state_bookm
623
  return (
624
  message,
625
  gr.update(choices=choices, value=[]),
626
- display_bookmarks(),
627
  bookmarks.copy() # Return the updated state
628
  )
629
 
@@ -790,7 +778,7 @@ Navigate through the tabs to explore each feature in detail.
790
  process_button.click(
791
  process_uploaded_file,
792
  inputs=[upload, state_bookmarks],
793
- outputs=[output_text, bookmark_display, None, None, state_bookmarks]
794
  )
795
 
796
  # Chat with Bookmarks Tab
 
464
  return (
465
  "⚠️ Please upload a bookmarks HTML file.",
466
  "",
 
 
467
  state_bookmarks # Return the unchanged state
468
  )
469
 
 
474
  return (
475
  "⚠️ Error decoding the file. Please ensure it's a valid HTML file.",
476
  "",
 
 
477
  state_bookmarks # Return the unchanged state
478
  )
479
 
 
484
  return (
485
  "⚠️ Error parsing the bookmarks HTML file.",
486
  "",
 
 
487
  state_bookmarks # Return the unchanged state
488
  )
489
 
 
492
  return (
493
  "⚠️ No bookmarks found in the uploaded file.",
494
  "",
 
 
495
  state_bookmarks # Return the unchanged state
496
  )
497
 
 
516
  return (
517
  "⚠️ Error building search index.",
518
  "",
 
 
519
  state_bookmarks # Return the unchanged state
520
  )
521
 
 
529
  return (
530
  message,
531
  bookmark_html,
 
 
532
  bookmarks.copy() # Return the updated state
533
  )
534
 
 
538
  """
539
  global bookmarks, faiss_index
540
  if not selected_indices:
541
+ return "⚠️ No bookmarks selected.", gr.update(choices=[]), bookmark_display_manage.update(value=display_bookmarks()), state_bookmarks
542
 
543
  ids_to_delete = []
544
  indices_to_delete = []
 
569
  return (
570
  message,
571
  gr.update(choices=choices, value=[]),
572
+ bookmark_display_manage.update(value=display_bookmarks()),
573
  bookmarks.copy() # Return the updated state
574
  )
575
 
 
581
  return (
582
  "⚠️ No bookmarks selected.",
583
  gr.update(choices=[]),
584
+ bookmark_display_manage.update(value=display_bookmarks()),
585
  state_bookmarks
586
  )
587
  if not new_category:
588
  return (
589
  "⚠️ No new category selected.",
590
  gr.update(choices=[]),
591
+ bookmark_display_manage.update(value=display_bookmarks()),
592
  state_bookmarks
593
  )
594
 
 
611
  return (
612
  message,
613
  gr.update(choices=choices, value=[]),
614
+ bookmark_display_manage.update(value=display_bookmarks()),
615
  bookmarks.copy() # Return the updated state
616
  )
617
 
 
778
  process_button.click(
779
  process_uploaded_file,
780
  inputs=[upload, state_bookmarks],
781
+ outputs=[output_text, bookmark_display, state_bookmarks]
782
  )
783
 
784
  # Chat with Bookmarks Tab