openfree commited on
Commit
1d8e135
Β·
verified Β·
1 Parent(s): 6c0b182

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +112 -31
app.py CHANGED
@@ -641,55 +641,136 @@ def fetch_items(item_type, search_query="", sort_by="rank", limit=1000):
641
  print(f"Error fetching items: {e}")
642
  return []
643
 
644
- # μΈν„°νŽ˜μ΄μŠ€ μˆ˜μ •
645
  def create_interface():
646
- with gr.Blocks(title="HuggingFace Trending Board") as interface:
647
- gr.Markdown("# πŸ€— HuggingFace Trending TOP 300 Board")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
648
 
649
  with gr.Tabs() as tabs:
650
  # Spaces νƒ­
651
  with gr.Tab("🎯 Trending Spaces"):
652
- with gr.Row():
653
- spaces_search = gr.Textbox(label="Search Spaces", placeholder="Enter search terms...")
654
- spaces_sort = gr.Radio(
655
- choices=["rank", "rising_rate", "popularity"],
656
- value="rank",
657
- label="Sort by",
658
- interactive=True
659
- )
660
- spaces_refresh_btn = gr.Button("Refresh", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
661
  spaces_gallery = gr.HTML()
662
  spaces_status = gr.Markdown("Ready")
663
 
664
  # Models νƒ­
665
  with gr.Tab("πŸ€– Trending Models"):
666
- with gr.Row():
667
- models_search = gr.Textbox(label="Search Models", placeholder="Enter search terms...")
668
- models_sort = gr.Radio(
669
- choices=["rank", "rising_rate", "popularity"],
670
- value="rank",
671
- label="Sort by",
672
- interactive=True
673
- )
674
- models_refresh_btn = gr.Button("Refresh", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
675
  models_gallery = gr.HTML()
676
  models_status = gr.Markdown("Ready")
677
 
678
  # Datasets νƒ­
679
  with gr.Tab("πŸ“Š Trending Datasets"):
680
- with gr.Row():
681
- datasets_search = gr.Textbox(label="Search Datasets", placeholder="Enter search terms...")
682
- datasets_sort = gr.Radio(
683
- choices=["rank", "rising_rate", "popularity"],
684
- value="rank",
685
- label="Sort by",
686
- interactive=True
687
- )
688
- datasets_refresh_btn = gr.Button("Refresh", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
689
  datasets_gallery = gr.HTML()
690
  datasets_status = gr.Markdown("Ready")
691
 
692
- # Event handlers
693
  spaces_refresh_btn.click(
694
  fn=get_trending_spaces,
695
  inputs=[spaces_search, spaces_sort],
 
641
  print(f"Error fetching items: {e}")
642
  return []
643
 
 
644
  def create_interface():
645
+ with gr.Blocks(title="HuggingFace Trending Board", css="""
646
+ .search-sort-container {
647
+ background: rgba(255,255,255,0.9);
648
+ border-radius: 15px;
649
+ padding: 20px;
650
+ margin: 10px 0;
651
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
652
+ }
653
+ .search-box {
654
+ border: 2px solid #e1e1e1;
655
+ border-radius: 10px;
656
+ padding: 10px;
657
+ transition: all 0.3s ease;
658
+ }
659
+ .search-box:focus {
660
+ border-color: #7b61ff;
661
+ box-shadow: 0 0 0 2px rgba(123,97,255,0.2);
662
+ }
663
+ .sort-radio {
664
+ display: inline-flex;
665
+ gap: 15px;
666
+ background: #f5f5f5;
667
+ padding: 10px;
668
+ border-radius: 10px;
669
+ }
670
+ .refresh-btn {
671
+ background: linear-gradient(135deg, #7b61ff, #6366f1);
672
+ color: white;
673
+ border: none;
674
+ padding: 10px 20px;
675
+ border-radius: 10px;
676
+ cursor: pointer;
677
+ transition: all 0.3s ease;
678
+ }
679
+ .refresh-btn:hover {
680
+ transform: translateY(-2px);
681
+ box-shadow: 0 4px 12px rgba(99,102,241,0.4);
682
+ }
683
+ """) as interface:
684
+ gr.Markdown("""
685
+ # πŸ€— HuggingFace Trending TOP 300 Board
686
+ <div style='margin-bottom: 20px; padding: 10px; background: linear-gradient(135deg, rgba(123,97,255,0.1), rgba(99,102,241,0.1)); border-radius: 10px;'>
687
+ Explore, search, and sort through the top AI content from HuggingFace
688
+ </div>
689
+ """)
690
 
691
  with gr.Tabs() as tabs:
692
  # Spaces νƒ­
693
  with gr.Tab("🎯 Trending Spaces"):
694
+ with gr.Box(elem_classes="search-sort-container"):
695
+ with gr.Row(equal_height=True):
696
+ with gr.Column(scale=2):
697
+ spaces_search = gr.Textbox(
698
+ label="πŸ” Search Spaces",
699
+ placeholder="Enter keywords to search...",
700
+ elem_classes="search-box"
701
+ )
702
+ with gr.Column(scale=2):
703
+ spaces_sort = gr.Radio(
704
+ choices=["rank", "rising_rate", "popularity"],
705
+ value="rank",
706
+ label="πŸ“Š Sort by",
707
+ interactive=True,
708
+ elem_classes="sort-radio"
709
+ )
710
+ with gr.Column(scale=1):
711
+ spaces_refresh_btn = gr.Button(
712
+ "πŸ”„ Refresh",
713
+ variant="primary",
714
+ elem_classes="refresh-btn"
715
+ )
716
  spaces_gallery = gr.HTML()
717
  spaces_status = gr.Markdown("Ready")
718
 
719
  # Models νƒ­
720
  with gr.Tab("πŸ€– Trending Models"):
721
+ with gr.Box(elem_classes="search-sort-container"):
722
+ with gr.Row(equal_height=True):
723
+ with gr.Column(scale=2):
724
+ models_search = gr.Textbox(
725
+ label="πŸ” Search Models",
726
+ placeholder="Enter keywords to search...",
727
+ elem_classes="search-box"
728
+ )
729
+ with gr.Column(scale=2):
730
+ models_sort = gr.Radio(
731
+ choices=["rank", "rising_rate", "popularity"],
732
+ value="rank",
733
+ label="πŸ“Š Sort by",
734
+ interactive=True,
735
+ elem_classes="sort-radio"
736
+ )
737
+ with gr.Column(scale=1):
738
+ models_refresh_btn = gr.Button(
739
+ "πŸ”„ Refresh",
740
+ variant="primary",
741
+ elem_classes="refresh-btn"
742
+ )
743
  models_gallery = gr.HTML()
744
  models_status = gr.Markdown("Ready")
745
 
746
  # Datasets νƒ­
747
  with gr.Tab("πŸ“Š Trending Datasets"):
748
+ with gr.Box(elem_classes="search-sort-container"):
749
+ with gr.Row(equal_height=True):
750
+ with gr.Column(scale=2):
751
+ datasets_search = gr.Textbox(
752
+ label="πŸ” Search Datasets",
753
+ placeholder="Enter keywords to search...",
754
+ elem_classes="search-box"
755
+ )
756
+ with gr.Column(scale=2):
757
+ datasets_sort = gr.Radio(
758
+ choices=["rank", "rising_rate", "popularity"],
759
+ value="rank",
760
+ label="πŸ“Š Sort by",
761
+ interactive=True,
762
+ elem_classes="sort-radio"
763
+ )
764
+ with gr.Column(scale=1):
765
+ datasets_refresh_btn = gr.Button(
766
+ "πŸ”„ Refresh",
767
+ variant="primary",
768
+ elem_classes="refresh-btn"
769
+ )
770
  datasets_gallery = gr.HTML()
771
  datasets_status = gr.Markdown("Ready")
772
 
773
+ # Event handlers (κΈ°μ‘΄ μ½”λ“œμ™€ 동일)
774
  spaces_refresh_btn.click(
775
  fn=get_trending_spaces,
776
  inputs=[spaces_search, spaces_sort],