Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,13 +87,8 @@ CUSTOM_CSS = """
|
|
| 87 |
color: #4f46e5 !important;
|
| 88 |
font-weight: 600 !important;
|
| 89 |
}
|
| 90 |
-
.
|
| 91 |
-
|
| 92 |
-
margin-top: 2rem !important;
|
| 93 |
-
margin-bottom: 2rem !important;
|
| 94 |
-
border-radius: 16px !important;
|
| 95 |
-
overflow: hidden !important;
|
| 96 |
-
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1) !important;
|
| 97 |
}
|
| 98 |
.sidebar-container {
|
| 99 |
background-color: white !important;
|
|
@@ -101,6 +96,9 @@ CUSTOM_CSS = """
|
|
| 101 |
padding: 16px !important;
|
| 102 |
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
|
| 103 |
}
|
|
|
|
|
|
|
|
|
|
| 104 |
.app-title {
|
| 105 |
background: linear-gradient(90deg, #4f46e5, #8b5cf6) !important;
|
| 106 |
-webkit-background-clip: text !important;
|
|
@@ -114,11 +112,12 @@ CUSTOM_CSS = """
|
|
| 114 |
font-size: 1.25rem !important;
|
| 115 |
margin-bottom: 2rem !important;
|
| 116 |
}
|
| 117 |
-
.
|
| 118 |
-
|
| 119 |
-
height: 700px !important;
|
| 120 |
border-radius: 12px !important;
|
|
|
|
| 121 |
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
|
|
|
|
| 122 |
}
|
| 123 |
.results-container {
|
| 124 |
background-color: #f8fafc !important;
|
|
@@ -138,6 +137,12 @@ CUSTOM_CSS = """
|
|
| 138 |
font-size: 0.875rem !important;
|
| 139 |
margin-right: 8px !important;
|
| 140 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
"""
|
| 142 |
|
| 143 |
# Cache directory and file paths
|
|
@@ -410,7 +415,7 @@ def create_ui():
|
|
| 410 |
|
| 411 |
with gr.Blocks(css=CUSTOM_CSS, title=TITLE) as demo:
|
| 412 |
# Header with enhanced styling
|
| 413 |
-
with gr.Row(
|
| 414 |
with gr.Column():
|
| 415 |
gr.Markdown(f"<h1 class='app-title'>{TITLE}</h1>")
|
| 416 |
gr.Markdown(f"<p class='app-subtitle'>{SUBTITLE}</p>")
|
|
@@ -421,52 +426,52 @@ def create_ui():
|
|
| 421 |
# Main content area - redesigned layout
|
| 422 |
with gr.Row():
|
| 423 |
# Left panel - Input controls
|
| 424 |
-
with gr.Column(scale=1
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
stats_output = gr.Markdown("", label="π Analysis Results", elem_classes=["results-container"])
|
| 448 |
|
| 449 |
# Right panel - Examples moved to right side
|
| 450 |
-
with gr.Column(scale=1
|
| 451 |
-
gr.
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
|
|
|
| 462 |
|
| 463 |
# Full width visualization area at the bottom
|
| 464 |
-
with gr.Row(
|
| 465 |
with gr.Column():
|
| 466 |
# Tab container for visualizations
|
| 467 |
with gr.Tabs():
|
| 468 |
with gr.Tab("π§© Knowledge Graph"):
|
| 469 |
-
output_graph = gr.HTML(label=""
|
| 470 |
|
| 471 |
with gr.Tab("π·οΈ Entity Recognition"):
|
| 472 |
output_entity_viz = gr.HTML(label="")
|
|
@@ -499,7 +504,7 @@ def create_ui():
|
|
| 499 |
)
|
| 500 |
|
| 501 |
# Footer
|
| 502 |
-
with gr.Row(
|
| 503 |
gr.Markdown("---")
|
| 504 |
gr.Markdown("π **Instructions:** Enter text in any language, select a model, and click 'Extract & Visualize' to generate a knowledge graph.")
|
| 505 |
gr.Markdown("π οΈ Powered by Phi-3 Instruct Graph | Emergent Methods")
|
|
|
|
| 87 |
color: #4f46e5 !important;
|
| 88 |
font-weight: 600 !important;
|
| 89 |
}
|
| 90 |
+
.header-container {
|
| 91 |
+
margin-bottom: 24px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
}
|
| 93 |
.sidebar-container {
|
| 94 |
background-color: white !important;
|
|
|
|
| 96 |
padding: 16px !important;
|
| 97 |
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
|
| 98 |
}
|
| 99 |
+
.visualization-container {
|
| 100 |
+
margin-top: 24px !important;
|
| 101 |
+
}
|
| 102 |
.app-title {
|
| 103 |
background: linear-gradient(90deg, #4f46e5, #8b5cf6) !important;
|
| 104 |
-webkit-background-clip: text !important;
|
|
|
|
| 112 |
font-size: 1.25rem !important;
|
| 113 |
margin-bottom: 2rem !important;
|
| 114 |
}
|
| 115 |
+
.examples-container {
|
| 116 |
+
background-color: white !important;
|
|
|
|
| 117 |
border-radius: 12px !important;
|
| 118 |
+
padding: 16px !important;
|
| 119 |
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
|
| 120 |
+
margin-bottom: 16px !important;
|
| 121 |
}
|
| 122 |
.results-container {
|
| 123 |
background-color: #f8fafc !important;
|
|
|
|
| 137 |
font-size: 0.875rem !important;
|
| 138 |
margin-right: 8px !important;
|
| 139 |
}
|
| 140 |
+
.graph-container iframe {
|
| 141 |
+
width: 100% !important;
|
| 142 |
+
height: 700px !important;
|
| 143 |
+
border-radius: 12px !important;
|
| 144 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
|
| 145 |
+
}
|
| 146 |
"""
|
| 147 |
|
| 148 |
# Cache directory and file paths
|
|
|
|
| 415 |
|
| 416 |
with gr.Blocks(css=CUSTOM_CSS, title=TITLE) as demo:
|
| 417 |
# Header with enhanced styling
|
| 418 |
+
with gr.Row():
|
| 419 |
with gr.Column():
|
| 420 |
gr.Markdown(f"<h1 class='app-title'>{TITLE}</h1>")
|
| 421 |
gr.Markdown(f"<p class='app-subtitle'>{SUBTITLE}</p>")
|
|
|
|
| 426 |
# Main content area - redesigned layout
|
| 427 |
with gr.Row():
|
| 428 |
# Left panel - Input controls
|
| 429 |
+
with gr.Column(scale=1):
|
| 430 |
+
with gr.Box():
|
| 431 |
+
input_model = gr.Dropdown(
|
| 432 |
+
MODEL_LIST,
|
| 433 |
+
label="π€ Select Model",
|
| 434 |
+
info="Choose a model to process your text",
|
| 435 |
+
value=MODEL_LIST[0] if MODEL_LIST else None
|
| 436 |
+
)
|
| 437 |
+
|
| 438 |
+
input_text = gr.TextArea(
|
| 439 |
+
label="π Input Text",
|
| 440 |
+
info="Enter text in any language to extract a knowledge graph",
|
| 441 |
+
placeholder="Enter text here...",
|
| 442 |
+
lines=8,
|
| 443 |
+
value=EXAMPLES[0][0] # Pre-fill with first example
|
| 444 |
+
)
|
| 445 |
+
|
| 446 |
+
with gr.Row():
|
| 447 |
+
submit_button = gr.Button("π Extract & Visualize", variant="primary", scale=2)
|
| 448 |
+
clear_button = gr.Button("π Clear", variant="secondary", scale=1)
|
| 449 |
+
|
| 450 |
+
# Statistics will appear here
|
| 451 |
+
stats_output = gr.Markdown("", label="π Analysis Results")
|
|
|
|
| 452 |
|
| 453 |
# Right panel - Examples moved to right side
|
| 454 |
+
with gr.Column(scale=1):
|
| 455 |
+
with gr.Box():
|
| 456 |
+
gr.Markdown("<h3>π Example Texts</h3>")
|
| 457 |
+
# Removed elem_classes parameter that was causing the error
|
| 458 |
+
gr.Examples(
|
| 459 |
+
examples=EXAMPLES,
|
| 460 |
+
inputs=input_text,
|
| 461 |
+
label=""
|
| 462 |
+
)
|
| 463 |
+
|
| 464 |
+
# JSON output moved to right side as well
|
| 465 |
+
with gr.Accordion("π JSON Data", open=False):
|
| 466 |
+
output_json = gr.JSON(label="")
|
| 467 |
|
| 468 |
# Full width visualization area at the bottom
|
| 469 |
+
with gr.Row():
|
| 470 |
with gr.Column():
|
| 471 |
# Tab container for visualizations
|
| 472 |
with gr.Tabs():
|
| 473 |
with gr.Tab("π§© Knowledge Graph"):
|
| 474 |
+
output_graph = gr.HTML(label="")
|
| 475 |
|
| 476 |
with gr.Tab("π·οΈ Entity Recognition"):
|
| 477 |
output_entity_viz = gr.HTML(label="")
|
|
|
|
| 504 |
)
|
| 505 |
|
| 506 |
# Footer
|
| 507 |
+
with gr.Row():
|
| 508 |
gr.Markdown("---")
|
| 509 |
gr.Markdown("π **Instructions:** Enter text in any language, select a model, and click 'Extract & Visualize' to generate a knowledge graph.")
|
| 510 |
gr.Markdown("π οΈ Powered by Phi-3 Instruct Graph | Emergent Methods")
|