Spaces:
Running
on
Zero
Running
on
Zero
Add abstract modal functionality and update styles
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
|
3 |
import gradio as gr
|
4 |
import polars as pl
|
|
|
5 |
|
6 |
from app_pr import demo as demo_pr
|
7 |
from semantic_search import semantic_search
|
@@ -52,6 +53,7 @@ df_main = df_orig.select(
|
|
52 |
"Models",
|
53 |
"Datasets",
|
54 |
"claimed",
|
|
|
55 |
"paper_id",
|
56 |
)
|
57 |
|
@@ -151,6 +153,25 @@ def update_search_mode(search_mode: str) -> gr.Accordion:
|
|
151 |
return gr.Accordion(visible=search_mode == "Semantic Search")
|
152 |
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
with gr.Blocks(css_paths="style.css") as demo:
|
155 |
gr.Markdown(DESCRIPTION)
|
156 |
with gr.Accordion(label="Tutorial", open=True):
|
@@ -196,6 +217,9 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
196 |
elem_id="table",
|
197 |
column_widths=[COLUMN_INFO[col][1] for col in COLUMN_INFO],
|
198 |
)
|
|
|
|
|
|
|
199 |
|
200 |
search_mode.change(
|
201 |
fn=update_search_mode,
|
@@ -203,6 +227,8 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
203 |
outputs=advanced_search_options,
|
204 |
)
|
205 |
|
|
|
|
|
206 |
inputs = [
|
207 |
search_mode,
|
208 |
search_query,
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
import polars as pl
|
5 |
+
from gradio_modal import Modal
|
6 |
|
7 |
from app_pr import demo as demo_pr
|
8 |
from semantic_search import semantic_search
|
|
|
53 |
"Models",
|
54 |
"Datasets",
|
55 |
"claimed",
|
56 |
+
"abstract",
|
57 |
"paper_id",
|
58 |
)
|
59 |
|
|
|
153 |
return gr.Accordion(visible=search_mode == "Semantic Search")
|
154 |
|
155 |
|
156 |
+
def df_row_selected(
|
157 |
+
evt: gr.SelectData,
|
158 |
+
) -> tuple[
|
159 |
+
Modal,
|
160 |
+
gr.Textbox, # title
|
161 |
+
gr.Textbox, # abstract
|
162 |
+
]:
|
163 |
+
if evt.index[1] != 0:
|
164 |
+
return Modal(), gr.Textbox(), gr.Textbox()
|
165 |
+
|
166 |
+
title = evt.row_value[0]
|
167 |
+
row = df_main.filter(pl.col("Title") == title)
|
168 |
+
return (
|
169 |
+
Modal(visible=True),
|
170 |
+
gr.Textbox(value=row["Title"].item()), # title
|
171 |
+
gr.Textbox(value=row["abstract"].item()), # abstract
|
172 |
+
)
|
173 |
+
|
174 |
+
|
175 |
with gr.Blocks(css_paths="style.css") as demo:
|
176 |
gr.Markdown(DESCRIPTION)
|
177 |
with gr.Accordion(label="Tutorial", open=True):
|
|
|
217 |
elem_id="table",
|
218 |
column_widths=[COLUMN_INFO[col][1] for col in COLUMN_INFO],
|
219 |
)
|
220 |
+
with Modal(visible=False, elem_id="abstract-modal") as abstract_modal:
|
221 |
+
title = gr.Textbox(label="Title")
|
222 |
+
abstract = gr.Textbox(label="Abstract")
|
223 |
|
224 |
search_mode.change(
|
225 |
fn=update_search_mode,
|
|
|
227 |
outputs=advanced_search_options,
|
228 |
)
|
229 |
|
230 |
+
df.select(fn=df_row_selected, outputs=[abstract_modal, title, abstract])
|
231 |
+
|
232 |
inputs = [
|
233 |
search_mode,
|
234 |
search_query,
|
style.css
CHANGED
@@ -2,3 +2,18 @@ h1 {
|
|
2 |
text-align: center;
|
3 |
display: block;
|
4 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
text-align: center;
|
3 |
display: block;
|
4 |
}
|
5 |
+
|
6 |
+
#abstract-modal .modal-block {
|
7 |
+
position: fixed !important;
|
8 |
+
top: 50% !important;
|
9 |
+
left: 50% !important;
|
10 |
+
transform: translate(-50%, -50%) !important;
|
11 |
+
width: 80vw !important;
|
12 |
+
max-width: 900px !important;
|
13 |
+
margin: 0 !important;
|
14 |
+
}
|
15 |
+
|
16 |
+
#abstract-modal .modal-block,
|
17 |
+
#abstract-modal .modal-block * {
|
18 |
+
font-size: 1.0rem !important;
|
19 |
+
}
|