UI improvment
Browse files- front/tabs/tab_drias.py +15 -1
front/tabs/tab_drias.py
CHANGED
|
@@ -37,8 +37,14 @@ def show_results(sql_queries_state, dataframes_state, plots_state):
|
|
| 37 |
|
| 38 |
def filter_by_model(dataframes, figures, index_state, model_selection):
|
| 39 |
df = dataframes[index_state]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
if model_selection != "ALL":
|
| 41 |
df = df[df["model"] == model_selection]
|
|
|
|
|
|
|
| 42 |
figure = figures[index_state](df)
|
| 43 |
return df, figure
|
| 44 |
|
|
@@ -93,7 +99,7 @@ def create_drias_tab():
|
|
| 93 |
table_names_list = gr.State([])
|
| 94 |
|
| 95 |
with gr.Tab("Beta - Talk to DRIAS", elem_id="tab-vanna", id=6):
|
| 96 |
-
with gr.Accordion(label="Details"):
|
| 97 |
gr.Markdown(DRIAS_UI_TEXT)
|
| 98 |
|
| 99 |
# Add examples for common questions
|
|
@@ -154,6 +160,10 @@ def create_drias_tab():
|
|
| 154 |
|
| 155 |
# Handle example selection
|
| 156 |
examples_hidden.change(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
ask_drias_query,
|
| 158 |
inputs=[examples_hidden, index_state],
|
| 159 |
outputs=[
|
|
@@ -191,6 +201,10 @@ def create_drias_tab():
|
|
| 191 |
)
|
| 192 |
|
| 193 |
drias_direct_question.submit(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
ask_drias_query,
|
| 195 |
inputs=[drias_direct_question, index_state],
|
| 196 |
outputs=[
|
|
|
|
| 37 |
|
| 38 |
def filter_by_model(dataframes, figures, index_state, model_selection):
|
| 39 |
df = dataframes[index_state]
|
| 40 |
+
if df.empty:
|
| 41 |
+
return df, None
|
| 42 |
+
if "model" not in df.columns:
|
| 43 |
+
return df, figures[index_state](df)
|
| 44 |
if model_selection != "ALL":
|
| 45 |
df = df[df["model"] == model_selection]
|
| 46 |
+
if df.empty:
|
| 47 |
+
return df, None
|
| 48 |
figure = figures[index_state](df)
|
| 49 |
return df, figure
|
| 50 |
|
|
|
|
| 99 |
table_names_list = gr.State([])
|
| 100 |
|
| 101 |
with gr.Tab("Beta - Talk to DRIAS", elem_id="tab-vanna", id=6):
|
| 102 |
+
with gr.Accordion(label="Details") as details_accordion:
|
| 103 |
gr.Markdown(DRIAS_UI_TEXT)
|
| 104 |
|
| 105 |
# Add examples for common questions
|
|
|
|
| 160 |
|
| 161 |
# Handle example selection
|
| 162 |
examples_hidden.change(
|
| 163 |
+
lambda x: (gr.Accordion(open=False), gr.Textbox(value=x)),
|
| 164 |
+
inputs=[examples_hidden],
|
| 165 |
+
outputs=[details_accordion, drias_direct_question]
|
| 166 |
+
).then(
|
| 167 |
ask_drias_query,
|
| 168 |
inputs=[examples_hidden, index_state],
|
| 169 |
outputs=[
|
|
|
|
| 201 |
)
|
| 202 |
|
| 203 |
drias_direct_question.submit(
|
| 204 |
+
lambda: gr.Accordion(open=False),
|
| 205 |
+
inputs=None,
|
| 206 |
+
outputs=[details_accordion]
|
| 207 |
+
).then(
|
| 208 |
ask_drias_query,
|
| 209 |
inputs=[drias_direct_question, index_state],
|
| 210 |
outputs=[
|