Spaces:
Sleeping
Sleeping
Update components/sidebar.py
Browse files- components/sidebar.py +37 -31
components/sidebar.py
CHANGED
|
@@ -1,36 +1,42 @@
|
|
| 1 |
-
#
|
| 2 |
-
# File: components/sidebar.py
|
| 3 |
-
import streamlit as st
|
| 4 |
|
|
|
|
| 5 |
|
| 6 |
def render_sidebar():
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
"""
|
| 25 |
-
Display a list of papers with titles, authors, and abstracts.
|
| 26 |
-
Args:
|
| 27 |
-
papers (List[dict]): Each dict should have 'id', 'title', 'authors', 'abstract'.
|
| 28 |
-
"""
|
| 29 |
-
st.header("๐ Papers Found")
|
| 30 |
-
if not papers:
|
| 31 |
-
st.info("No papers found for this query.")
|
| 32 |
-
return
|
| 33 |
-
for paper in papers:
|
| 34 |
-
with st.expander(paper.get("title", "Unknown Title")):
|
| 35 |
-
st.markdown(f"**Authors:** {', '.join(paper.get('authors', []))}")
|
| 36 |
-
st.write(paper.get("abstract", "No abstract available."))
|
|
|
|
| 1 |
+
#components/sidebar.py
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
import streamlit as st
|
| 4 |
|
| 5 |
def render_sidebar():
|
| 6 |
+
"""
|
| 7 |
+
Render the sidebar controls for the research companion app.
|
| 8 |
+
|
| 9 |
+
Returns:
|
| 10 |
+
query (str): The user's search query.
|
| 11 |
+
num_results (int): Maximum number of papers to display.
|
| 12 |
+
theme (str): UI theme selection ('Light' or 'Dark').
|
| 13 |
+
search_clicked (bool): True if the Search button was pressed.
|
| 14 |
+
"""
|
| 15 |
+
st.sidebar.title("๐ Research Companion")
|
| 16 |
+
|
| 17 |
+
# Input for research topic
|
| 18 |
+
query = st.sidebar.text_input(
|
| 19 |
+
label="Enter your research topic:",
|
| 20 |
+
value="",
|
| 21 |
+
placeholder="e.g. CRISPR delivery"
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# Slider for number of results
|
| 25 |
+
num_results = st.sidebar.slider(
|
| 26 |
+
label="Max papers to display",
|
| 27 |
+
min_value=1,
|
| 28 |
+
max_value=20,
|
| 29 |
+
value=5
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# Theme selection
|
| 33 |
+
theme = st.sidebar.selectbox(
|
| 34 |
+
label="Theme:",
|
| 35 |
+
options=["Light", "Dark"],
|
| 36 |
+
index=0
|
| 37 |
+
)
|
| 38 |
|
| 39 |
+
# Search action
|
| 40 |
+
search_clicked = st.sidebar.button("Search")
|
| 41 |
|
| 42 |
+
return query, num_results, theme, search_clicked
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|