Spaces:
Sleeping
Sleeping
Update app.py from anycoder
Browse files
app.py
CHANGED
|
@@ -413,18 +413,17 @@ def create_demo():
|
|
| 413 |
label="Sample Size",
|
| 414 |
info="Number of rows to display initially"
|
| 415 |
)
|
| 416 |
-
load_btn = gr.Button("π Load Data", variant="primary"
|
| 417 |
|
| 418 |
gr.Markdown("### Quick Actions")
|
| 419 |
explore_btn = gr.Button("π Quick Explore", variant="secondary")
|
| 420 |
quality_btn = gr.Button("π Quality Check", variant="secondary")
|
| 421 |
|
| 422 |
with gr.Column(scale=2):
|
| 423 |
-
data_info = gr.JSON(label="Dataset Information"
|
| 424 |
sample_data = gr.Dataframe(
|
| 425 |
label="Sample Data",
|
| 426 |
-
interactive=False
|
| 427 |
-
elem_classes=["sample-data"]
|
| 428 |
)
|
| 429 |
|
| 430 |
# Quality Analysis Tab
|
|
@@ -453,8 +452,8 @@ def create_demo():
|
|
| 453 |
detect_anomalies_btn = gr.Button("β οΈ Detect Anomalies")
|
| 454 |
|
| 455 |
with gr.Column(scale=2):
|
| 456 |
-
quality_report = gr.JSON(label="Quality Analysis"
|
| 457 |
-
anomaly_results = gr.JSON(label="Anomaly Detection Results"
|
| 458 |
|
| 459 |
# AI Assistant Tab
|
| 460 |
with gr.TabItem("π€ AI Assistant"):
|
|
@@ -467,8 +466,7 @@ def create_demo():
|
|
| 467 |
info="Ask questions about your dataset using natural language"
|
| 468 |
)
|
| 469 |
ai_history = gr.List(
|
| 470 |
-
label="Chat History"
|
| 471 |
-
elem_classes=["chat-history"]
|
| 472 |
)
|
| 473 |
ai_btn = gr.Button("π¬ Ask AI", variant="primary")
|
| 474 |
ai_clear_btn = gr.Button("ποΈ Clear Chat")
|
|
@@ -476,10 +474,9 @@ def create_demo():
|
|
| 476 |
with gr.Column(scale=2):
|
| 477 |
ai_response = gr.Textbox(
|
| 478 |
label="AI Response",
|
| 479 |
-
lines=10
|
| 480 |
-
elem_classes=["ai-response"]
|
| 481 |
)
|
| 482 |
-
ai_insights = gr.Markdown(label="Insights"
|
| 483 |
|
| 484 |
# Validation & Cleaning Tab
|
| 485 |
with gr.TabItem("β
Validation & Cleaning"):
|
|
@@ -492,8 +489,7 @@ def create_demo():
|
|
| 492 |
label="Rules (format: column:rule_type:param)",
|
| 493 |
placeholder="id:unique, price:range:0,1000, email:null",
|
| 494 |
lines=8,
|
| 495 |
-
info="Enter validation rules separated by commas. Use tab for autocomplete suggestions."
|
| 496 |
-
elem_classes=["rules-input"]
|
| 497 |
)
|
| 498 |
|
| 499 |
# Hidden component to store current column list for suggestions
|
|
@@ -501,8 +497,7 @@ def create_demo():
|
|
| 501 |
|
| 502 |
# Create suggestion display
|
| 503 |
with gr.Accordion("β
Suggestions", open=False) as suggestions_accordion:
|
| 504 |
-
|
| 505 |
-
with suggestions_container:
|
| 506 |
suggestions_list = gr.Radio(
|
| 507 |
[],
|
| 508 |
label="Select suggestion",
|
|
@@ -524,12 +519,10 @@ def create_demo():
|
|
| 524 |
|
| 525 |
with gr.Column(scale=2):
|
| 526 |
validation_results = gr.Dataframe(
|
| 527 |
-
label="Validation Results"
|
| 528 |
-
elem_classes=["validation-results"]
|
| 529 |
)
|
| 530 |
cleaning_preview = gr.Dataframe(
|
| 531 |
-
label="Cleaned Data Preview"
|
| 532 |
-
elem_classes=["cleaning-preview"]
|
| 533 |
)
|
| 534 |
|
| 535 |
# Reporting Tab
|
|
@@ -546,8 +539,8 @@ def create_demo():
|
|
| 546 |
download_report_btn = gr.Button("π₯ Download Report", variant="secondary")
|
| 547 |
|
| 548 |
with gr.Column(scale=2):
|
| 549 |
-
report_output = gr.Markdown(label="Report"
|
| 550 |
-
report_json = gr.JSON(label="Report JSON"
|
| 551 |
|
| 552 |
# Event Handlers - Updated with real-time suggestions
|
| 553 |
def update_quality_columns(file):
|
|
@@ -853,7 +846,7 @@ def create_demo():
|
|
| 853 |
gr.File(label="Download Report")
|
| 854 |
)
|
| 855 |
|
| 856 |
-
# Real-time suggestions for rules input
|
| 857 |
rules_input.change(
|
| 858 |
get_suggestions,
|
| 859 |
[rules_input, columns_state],
|
|
@@ -869,13 +862,6 @@ def create_demo():
|
|
| 869 |
[suggestions_list, rules_input],
|
| 870 |
rules_input
|
| 871 |
)
|
| 872 |
-
|
| 873 |
-
# Also enable tab completion - using keyup instead of key_up for Gradio 6
|
| 874 |
-
rules_input.keyup(
|
| 875 |
-
lambda: None, # No-op, just to trigger suggestion update
|
| 876 |
-
rules_input,
|
| 877 |
-
None
|
| 878 |
-
)
|
| 879 |
|
| 880 |
return demo
|
| 881 |
|
|
|
|
| 413 |
label="Sample Size",
|
| 414 |
info="Number of rows to display initially"
|
| 415 |
)
|
| 416 |
+
load_btn = gr.Button("π Load Data", variant="primary")
|
| 417 |
|
| 418 |
gr.Markdown("### Quick Actions")
|
| 419 |
explore_btn = gr.Button("π Quick Explore", variant="secondary")
|
| 420 |
quality_btn = gr.Button("π Quality Check", variant="secondary")
|
| 421 |
|
| 422 |
with gr.Column(scale=2):
|
| 423 |
+
data_info = gr.JSON(label="Dataset Information")
|
| 424 |
sample_data = gr.Dataframe(
|
| 425 |
label="Sample Data",
|
| 426 |
+
interactive=False
|
|
|
|
| 427 |
)
|
| 428 |
|
| 429 |
# Quality Analysis Tab
|
|
|
|
| 452 |
detect_anomalies_btn = gr.Button("β οΈ Detect Anomalies")
|
| 453 |
|
| 454 |
with gr.Column(scale=2):
|
| 455 |
+
quality_report = gr.JSON(label="Quality Analysis")
|
| 456 |
+
anomaly_results = gr.JSON(label="Anomaly Detection Results")
|
| 457 |
|
| 458 |
# AI Assistant Tab
|
| 459 |
with gr.TabItem("π€ AI Assistant"):
|
|
|
|
| 466 |
info="Ask questions about your dataset using natural language"
|
| 467 |
)
|
| 468 |
ai_history = gr.List(
|
| 469 |
+
label="Chat History"
|
|
|
|
| 470 |
)
|
| 471 |
ai_btn = gr.Button("π¬ Ask AI", variant="primary")
|
| 472 |
ai_clear_btn = gr.Button("ποΈ Clear Chat")
|
|
|
|
| 474 |
with gr.Column(scale=2):
|
| 475 |
ai_response = gr.Textbox(
|
| 476 |
label="AI Response",
|
| 477 |
+
lines=10
|
|
|
|
| 478 |
)
|
| 479 |
+
ai_insights = gr.Markdown(label="Insights")
|
| 480 |
|
| 481 |
# Validation & Cleaning Tab
|
| 482 |
with gr.TabItem("β
Validation & Cleaning"):
|
|
|
|
| 489 |
label="Rules (format: column:rule_type:param)",
|
| 490 |
placeholder="id:unique, price:range:0,1000, email:null",
|
| 491 |
lines=8,
|
| 492 |
+
info="Enter validation rules separated by commas. Use tab for autocomplete suggestions."
|
|
|
|
| 493 |
)
|
| 494 |
|
| 495 |
# Hidden component to store current column list for suggestions
|
|
|
|
| 497 |
|
| 498 |
# Create suggestion display
|
| 499 |
with gr.Accordion("β
Suggestions", open=False) as suggestions_accordion:
|
| 500 |
+
with gr.Column() as suggestions_container:
|
|
|
|
| 501 |
suggestions_list = gr.Radio(
|
| 502 |
[],
|
| 503 |
label="Select suggestion",
|
|
|
|
| 519 |
|
| 520 |
with gr.Column(scale=2):
|
| 521 |
validation_results = gr.Dataframe(
|
| 522 |
+
label="Validation Results"
|
|
|
|
| 523 |
)
|
| 524 |
cleaning_preview = gr.Dataframe(
|
| 525 |
+
label="Cleaned Data Preview"
|
|
|
|
| 526 |
)
|
| 527 |
|
| 528 |
# Reporting Tab
|
|
|
|
| 539 |
download_report_btn = gr.Button("π₯ Download Report", variant="secondary")
|
| 540 |
|
| 541 |
with gr.Column(scale=2):
|
| 542 |
+
report_output = gr.Markdown(label="Report")
|
| 543 |
+
report_json = gr.JSON(label="Report JSON")
|
| 544 |
|
| 545 |
# Event Handlers - Updated with real-time suggestions
|
| 546 |
def update_quality_columns(file):
|
|
|
|
| 846 |
gr.File(label="Download Report")
|
| 847 |
)
|
| 848 |
|
| 849 |
+
# Real-time suggestions for rules input - using change event (Gradio 6 compatible)
|
| 850 |
rules_input.change(
|
| 851 |
get_suggestions,
|
| 852 |
[rules_input, columns_state],
|
|
|
|
| 862 |
[suggestions_list, rules_input],
|
| 863 |
rules_input
|
| 864 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 865 |
|
| 866 |
return demo
|
| 867 |
|