Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
073522f
1
Parent(s):
61af0c2
fixed filtering bugs for data exp
Browse files- tabs/data_exploration.py +65 -77
tabs/data_exploration.py
CHANGED
@@ -576,8 +576,25 @@ def create_exploration_tab(df):
|
|
576 |
)
|
577 |
|
578 |
with gr.Column(scale=1, min_width=100):
|
|
|
|
|
|
|
|
|
579 |
index_display = gr.HTML(
|
580 |
-
value="<div style=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
581 |
elem_id="index-display",
|
582 |
)
|
583 |
|
@@ -602,6 +619,53 @@ def create_exploration_tab(df):
|
|
602 |
# State for tracking current index (simple integer state)
|
603 |
current_index = gr.State(value=0)
|
604 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
# Reset filters
|
606 |
def reset_filters():
|
607 |
return (
|
@@ -744,79 +808,3 @@ def create_exploration_tab(df):
|
|
744 |
tool_info_display,
|
745 |
index_display,
|
746 |
]
|
747 |
-
|
748 |
-
|
749 |
-
def filter_and_update_display(model, dataset, min_score, max_score, current_index):
|
750 |
-
"""Filter the dataset and update the display with comprehensive error handling."""
|
751 |
-
try:
|
752 |
-
df_chat = get_chat_and_score_df(model, dataset)
|
753 |
-
df_chat = df_chat[
|
754 |
-
(df_chat["score"] >= min_score) & (df_chat["score"] <= max_score)
|
755 |
-
]
|
756 |
-
|
757 |
-
if df_chat.empty:
|
758 |
-
return (
|
759 |
-
'<div style="padding: 1.5rem; color: var(--text-muted); text-align: center; font-style: italic; background-color: var(--surface-color-alt); border-radius: 8px; border: 1px dashed var(--border-color);">No data available for selected filters</div>',
|
760 |
-
'<div style="padding: 1.5rem; color: var(--text-muted); text-align: center; font-style: italic;">No metrics available</div>',
|
761 |
-
'<div style="padding: 1.5rem; color: var(--text-muted); text-align: center; font-style: italic;">No tool information available</div>',
|
762 |
-
'<div style="font-weight: 500; color: var(--text-muted);">0/0</div>',
|
763 |
-
)
|
764 |
-
|
765 |
-
max_index = len(df_chat) - 1
|
766 |
-
current_index = min(current_index, max_index)
|
767 |
-
chat_html, metrics_html, tool_html = update_chat_display(df_chat, current_index)
|
768 |
-
|
769 |
-
index_display = f"""
|
770 |
-
<div style="
|
771 |
-
display: flex;
|
772 |
-
align-items: center;
|
773 |
-
justify-content: center;
|
774 |
-
font-weight: 500;
|
775 |
-
color: var(--primary-text);
|
776 |
-
background-color: var(--surface-color-alt);
|
777 |
-
padding: 0.5rem 1rem;
|
778 |
-
border-radius: 20px;
|
779 |
-
font-size: 0.9rem;
|
780 |
-
width: fit-content;
|
781 |
-
margin: 0 auto;">
|
782 |
-
<span style="margin-right: 0.25rem;">📄</span>{current_index + 1}/{len(df_chat)}
|
783 |
-
</div>
|
784 |
-
"""
|
785 |
-
return chat_html, metrics_html, tool_html, index_display
|
786 |
-
|
787 |
-
except Exception as e:
|
788 |
-
error_html = f"""
|
789 |
-
<div style="
|
790 |
-
padding: 1.5rem;
|
791 |
-
color: var(--score-low);
|
792 |
-
background-color: var(--surface-color);
|
793 |
-
border: 1px solid var(--score-low);
|
794 |
-
border-radius: 8px;
|
795 |
-
display: flex;
|
796 |
-
align-items: flex-start;">
|
797 |
-
<div style="
|
798 |
-
flex-shrink: 0;
|
799 |
-
margin-right: 1rem;
|
800 |
-
font-size: 1.5rem;">⚠️</div>
|
801 |
-
<div>
|
802 |
-
<div style="
|
803 |
-
font-weight: 600;
|
804 |
-
margin-bottom: 0.5rem;">Error Occurred</div>
|
805 |
-
<div style="
|
806 |
-
font-family: monospace;
|
807 |
-
background-color: var(--surface-color-alt);
|
808 |
-
padding: 1rem;
|
809 |
-
border-radius: 4px;
|
810 |
-
white-space: pre-wrap;
|
811 |
-
font-size: 0.9rem;">
|
812 |
-
{str(e)}
|
813 |
-
</div>
|
814 |
-
</div>
|
815 |
-
</div>
|
816 |
-
"""
|
817 |
-
return (
|
818 |
-
error_html,
|
819 |
-
'<div style="padding: 1.5rem; color: var(--text-muted); text-align: center; font-style: italic;">No metrics available</div>',
|
820 |
-
'<div style="padding: 1.5rem; color: var(--text-muted); text-align: center; font-style: italic;">No tool information available</div>',
|
821 |
-
'<div style="font-weight: 500; color: var(--text-muted);">0/0</div>',
|
822 |
-
)
|
|
|
576 |
)
|
577 |
|
578 |
with gr.Column(scale=1, min_width=100):
|
579 |
+
# Get initial count from default data
|
580 |
+
df_initial = get_chat_and_score_df(MODELS[0], DATASETS[0])
|
581 |
+
initial_count = len(df_initial)
|
582 |
+
|
583 |
index_display = gr.HTML(
|
584 |
+
value=f"""<div style="
|
585 |
+
display: flex;
|
586 |
+
align-items: center;
|
587 |
+
justify-content: center;
|
588 |
+
font-weight: 500;
|
589 |
+
color: var(--primary-text);
|
590 |
+
background-color: var(--surface-color-alt);
|
591 |
+
padding: 0.5rem 1rem;
|
592 |
+
border-radius: 20px;
|
593 |
+
font-size: 0.9rem;
|
594 |
+
width: fit-content;
|
595 |
+
margin: 0 auto;">
|
596 |
+
<span style="margin-right: 0.5rem;">📄</span>1/{initial_count}
|
597 |
+
</div>""",
|
598 |
elem_id="index-display",
|
599 |
)
|
600 |
|
|
|
619 |
# State for tracking current index (simple integer state)
|
620 |
current_index = gr.State(value=0)
|
621 |
|
622 |
+
def reset_index():
|
623 |
+
"""Reset the current index to 0"""
|
624 |
+
return 0
|
625 |
+
|
626 |
+
# Add these explicit event handlers for model and dataset changes
|
627 |
+
explore_model.change(
|
628 |
+
reset_index,
|
629 |
+
inputs=[],
|
630 |
+
outputs=[current_index],
|
631 |
+
)
|
632 |
+
|
633 |
+
explore_dataset.change(
|
634 |
+
reset_index,
|
635 |
+
inputs=[],
|
636 |
+
outputs=[current_index],
|
637 |
+
)
|
638 |
+
|
639 |
+
min_score.change(
|
640 |
+
reset_index,
|
641 |
+
inputs=[],
|
642 |
+
outputs=[current_index],
|
643 |
+
)
|
644 |
+
|
645 |
+
max_score.change(
|
646 |
+
reset_index,
|
647 |
+
inputs=[],
|
648 |
+
outputs=[current_index],
|
649 |
+
)
|
650 |
+
|
651 |
+
n_turns_filter.change(
|
652 |
+
reset_index,
|
653 |
+
inputs=[],
|
654 |
+
outputs=[current_index],
|
655 |
+
)
|
656 |
+
|
657 |
+
len_query_filter.change(
|
658 |
+
reset_index,
|
659 |
+
inputs=[],
|
660 |
+
outputs=[current_index],
|
661 |
+
)
|
662 |
+
|
663 |
+
n_tools_filter.change(
|
664 |
+
reset_index,
|
665 |
+
inputs=[],
|
666 |
+
outputs=[current_index],
|
667 |
+
)
|
668 |
+
|
669 |
# Reset filters
|
670 |
def reset_filters():
|
671 |
return (
|
|
|
808 |
tool_info_display,
|
809 |
index_display,
|
810 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|