RDF Validation Deployment commited on
Commit
db439cd
Β·
1 Parent(s): 3bbd742

Simplify to minimal interface - remove tabs, heavy markdown, and complex CSS to prevent crashes - 2025-10-04 15:51:32

Browse files
Files changed (1) hide show
  1. app.py +9 -135
app.py CHANGED
@@ -515,146 +515,20 @@ def get_property_usage(property_name: str, class_name: str = "") -> str:
515
 
516
  return json.dumps(usage, indent=2)
517
 
518
- # Create Gradio interface
519
  def create_interface():
520
- # Custom CSS to improve rendering and reduce page weight
521
- custom_css = """
522
- /* Make HF logo smaller */
523
- .svelte-1rjryqp {
524
- max-width: 48px !important;
525
- max-height: 48px !important;
526
- }
527
-
528
- /* Improve container layout */
529
- .gradio-container {
530
- max-width: 1200px !important;
531
- margin: auto !important;
532
- }
533
 
534
- /* Fix tab rendering */
535
- .tabs {
536
- overflow: visible !important;
537
- }
538
-
539
- /* Better code display */
540
- .code-wrap {
541
- font-family: 'Courier New', monospace !important;
542
- font-size: 12px !important;
543
- }
544
- """
545
-
546
- with gr.Blocks(title="BIBFRAME Ontology Documentation MCP Server", css=custom_css, theme=gr.themes.Soft()) as demo:
547
- gr.Markdown(f"""
548
- # πŸ“š BIBFRAME Ontology Documentation MCP Server
549
-
550
- **Status:** {'βœ… Loaded' if kb._loaded else '⚠️ Using fallback data'} - {len(kb.properties)} properties, {len(kb.classes)} classes
551
-
552
- This server provides BIBFRAME ontology documentation via MCP tools.
553
- """)
554
 
555
- with gr.Tabs(visible=True, elem_id="main-tabs"):
556
- # Tab 1: Property Lookup
557
- with gr.Tab("Property Lookup", elem_id="property-tab"):
558
- with gr.Row():
559
- with gr.Column():
560
- property_input = gr.Textbox(
561
- label="Property Name",
562
- placeholder="e.g., assigner, bf:assigner, or title",
563
- max_lines=1
564
- )
565
- property_btn = gr.Button("πŸ” Look Up Property", variant="primary")
566
-
567
- property_output = gr.Code(label="Property Information", language="json", lines=20)
568
-
569
- property_btn.click(
570
- fn=get_property_info,
571
- inputs=[property_input],
572
- outputs=[property_output]
573
- )
574
-
575
- # Tab 2: Class Lookup
576
- with gr.Tab("Class Lookup", elem_id="class-tab"):
577
- with gr.Row():
578
- with gr.Column():
579
- class_input = gr.Textbox(
580
- label="Class Name",
581
- placeholder="e.g., Work, AdminMetadata, or Instance",
582
- max_lines=1
583
- )
584
- class_btn = gr.Button("πŸ” Look Up Class", variant="primary")
585
-
586
- class_output = gr.Code(label="Class Information", language="json", lines=20)
587
-
588
- class_btn.click(
589
- fn=get_class_info,
590
- inputs=[class_input],
591
- outputs=[class_output]
592
- )
593
-
594
- # Tab 3: Search
595
- with gr.Tab("Search Ontology", elem_id="search-tab"):
596
- with gr.Row():
597
- with gr.Column():
598
- search_input = gr.Textbox(
599
- label="Search Term",
600
- placeholder="e.g., title, agent, date, or admin",
601
- max_lines=1
602
- )
603
- search_type = gr.Radio(
604
- label="Search Type",
605
- choices=["all", "properties", "classes"],
606
- value="all"
607
- )
608
- search_btn = gr.Button("πŸ” Search", variant="primary")
609
-
610
- search_output = gr.Code(label="Search Results", language="json", lines=20)
611
-
612
- search_btn.click(
613
- fn=search_ontology,
614
- inputs=[search_input, search_type],
615
- outputs=[search_output]
616
- )
617
-
618
- # Tab 4: Property Usage
619
- with gr.Tab("Property Usage Context", elem_id="usage-tab"):
620
- with gr.Row():
621
- with gr.Column():
622
- usage_prop_input = gr.Textbox(
623
- label="Property Name",
624
- placeholder="e.g., assigner, title, or adminMetadata",
625
- max_lines=1
626
- )
627
- usage_class_input = gr.Textbox(
628
- label="Class Context (optional)",
629
- placeholder="e.g., AdminMetadata, Work, or Instance",
630
- max_lines=1
631
- )
632
- usage_btn = gr.Button("πŸ” Get Usage Info", variant="primary")
633
-
634
- usage_output = gr.Code(label="Usage Information", language="json", lines=20)
635
-
636
- usage_btn.click(
637
- fn=get_property_usage,
638
- inputs=[usage_prop_input, usage_class_input],
639
- outputs=[usage_output]
640
- )
641
 
642
- # Simplified footer to reduce page weight
643
- gr.Markdown("""
644
- ---
645
- ### MCP Configuration:
646
- ```json
647
- {
648
- "mcpServers": {
649
- "bibframe-docs": {
650
- "url": "https://your-space.hf.space/gradio_api/mcp/"
651
- }
652
- }
653
- }
654
- ```
655
 
656
- **Resources:** [BIBFRAME Docs](https://www.loc.gov/bibframe/) | [Validator](https://huggingface.co/spaces/jimfhahn/mcp4rdf)
657
- """)
658
 
659
  return demo
660
 
 
515
 
516
  return json.dumps(usage, indent=2)
517
 
518
+ # Create Gradio interface - MINIMAL VERSION to prevent crashes
519
  def create_interface():
 
 
 
 
 
 
 
 
 
 
 
 
 
520
 
521
+ with gr.Blocks(title="BIBFRAME MCP Server") as demo:
522
+ gr.Markdown("""# πŸ“š BIBFRAME MCP Server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
 
524
+ Query BIBFRAME ontology via MCP tools. Enter terms below.""")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
 
526
+ # Single simple interface without tabs to reduce load
527
+ property_input = gr.Textbox(label="Property or Class", placeholder="e.g., assigner, Work")
528
+ lookup_btn = gr.Button("Search")
529
+ output = gr.Textbox(label="Result", lines=15)
 
 
 
 
 
 
 
 
 
530
 
531
+ lookup_btn.click(fn=get_property_info, inputs=[property_input], outputs=[output])
 
532
 
533
  return demo
534