update
Browse files- src/streamlit_app.py +54 -9
src/streamlit_app.py
CHANGED
|
@@ -1,42 +1,54 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from datasets import load_dataset
|
| 3 |
|
| 4 |
-
st.set_page_config(page_title="
|
| 5 |
|
| 6 |
# 1. Initialize Session States
|
| 7 |
if 'current_view' not in st.session_state:
|
| 8 |
-
st.session_state.current_view = "trending"
|
| 9 |
if 'page_number' not in st.session_state:
|
| 10 |
st.session_state.page_number = 0
|
| 11 |
|
| 12 |
-
# --- 2.
|
| 13 |
nav_container = st.container()
|
| 14 |
with nav_container:
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
with col1:
|
| 18 |
st.markdown("### π PWC")
|
| 19 |
with col2:
|
| 20 |
-
# When clicked, this button sets the view to "trending"
|
| 21 |
if st.button("π₯ Trending", use_container_width=True):
|
| 22 |
st.session_state.current_view = "trending"
|
|
|
|
|
|
|
| 23 |
with col3:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
if st.button("π Browse SOTA", use_container_width=True):
|
| 25 |
st.session_state.current_view = "sota"
|
| 26 |
-
|
|
|
|
| 27 |
if st.button("π Datasets", use_container_width=True):
|
| 28 |
st.session_state.current_view = "datasets"
|
| 29 |
-
|
|
|
|
| 30 |
if st.button("π§© Methods", use_container_width=True):
|
| 31 |
st.session_state.current_view = "methods"
|
|
|
|
| 32 |
|
| 33 |
st.divider()
|
| 34 |
|
| 35 |
# --- 3. View Logic ---
|
| 36 |
|
|
|
|
| 37 |
if st.session_state.current_view == "trending":
|
| 38 |
-
st.subheader("Trending Papers")
|
| 39 |
-
|
| 40 |
# Pagination UI
|
| 41 |
PAGE_SIZE = 10
|
| 42 |
c1, c2, c3 = st.columns([1, 2, 1])
|
|
@@ -66,7 +78,40 @@ if st.session_state.current_view == "trending":
|
|
| 66 |
if p.get('arxiv_id'):
|
| 67 |
st.link_button("View on ArXiv", f"https://arxiv.org/abs/{p['arxiv_id']}")
|
| 68 |
st.divider()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
|
|
|
| 70 |
elif st.session_state.current_view == "sota":
|
| 71 |
st.title("π State-of-the-Art")
|
| 72 |
st.info("Leaderboards coming soon! This page will show rankings for different ML tasks.")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
from datasets import load_dataset
|
| 4 |
|
| 5 |
+
st.set_page_config(page_title="PWC Explorer", layout="wide")
|
| 6 |
|
| 7 |
# 1. Initialize Session States
|
| 8 |
if 'current_view' not in st.session_state:
|
| 9 |
+
st.session_state.current_view = "trending"
|
| 10 |
if 'page_number' not in st.session_state:
|
| 11 |
st.session_state.page_number = 0
|
| 12 |
|
| 13 |
+
# --- 2. Top Navigation Bar ---
|
| 14 |
nav_container = st.container()
|
| 15 |
with nav_container:
|
| 16 |
+
# We added a 6th column to balance the layout
|
| 17 |
+
col1, col2, col3, col4, col5 = st.columns([1, 1, 1, 1.5, 1])
|
| 18 |
|
| 19 |
with col1:
|
| 20 |
st.markdown("### π PWC")
|
| 21 |
with col2:
|
|
|
|
| 22 |
if st.button("π₯ Trending", use_container_width=True):
|
| 23 |
st.session_state.current_view = "trending"
|
| 24 |
+
st.session_state.page_number = 0 # Reset page when switching
|
| 25 |
+
st.rerun()
|
| 26 |
with col3:
|
| 27 |
+
if st.button("π Search", use_container_width=True):
|
| 28 |
+
st.session_state.current_view = "search"
|
| 29 |
+
st.session_state.page_number = 0
|
| 30 |
+
st.rerun()
|
| 31 |
+
with col4:
|
| 32 |
if st.button("π Browse SOTA", use_container_width=True):
|
| 33 |
st.session_state.current_view = "sota"
|
| 34 |
+
st.rerun()
|
| 35 |
+
with col5:
|
| 36 |
if st.button("π Datasets", use_container_width=True):
|
| 37 |
st.session_state.current_view = "datasets"
|
| 38 |
+
st.rerun()
|
| 39 |
+
with col6:
|
| 40 |
if st.button("π§© Methods", use_container_width=True):
|
| 41 |
st.session_state.current_view = "methods"
|
| 42 |
+
st.rerun()
|
| 43 |
|
| 44 |
st.divider()
|
| 45 |
|
| 46 |
# --- 3. View Logic ---
|
| 47 |
|
| 48 |
+
# --- VIEW: TRENDING ---
|
| 49 |
if st.session_state.current_view == "trending":
|
| 50 |
+
st.subheader("π₯ Trending Research Papers")
|
| 51 |
+
|
| 52 |
# Pagination UI
|
| 53 |
PAGE_SIZE = 10
|
| 54 |
c1, c2, c3 = st.columns([1, 2, 1])
|
|
|
|
| 78 |
if p.get('arxiv_id'):
|
| 79 |
st.link_button("View on ArXiv", f"https://arxiv.org/abs/{p['arxiv_id']}")
|
| 80 |
st.divider()
|
| 81 |
+
|
| 82 |
+
# --- VIEW: SEARCH (The New Section) ---
|
| 83 |
+
elif st.session_state.current_view == "search":
|
| 84 |
+
st.subheader("π Global Archive Search")
|
| 85 |
+
st.info("Search through the entire 1GB archive of 500,000+ papers.")
|
| 86 |
+
|
| 87 |
+
query = st.text_input("Enter keywords (e.g., 'Diffusion Models', 'LLM')", key="global_search")
|
| 88 |
+
|
| 89 |
+
if query:
|
| 90 |
+
PAGE_SIZE = 10
|
| 91 |
+
offset = st.session_state.page_number * PAGE_SIZE
|
| 92 |
+
|
| 93 |
+
search_url = f"https://datasets-server.huggingface.co/search?dataset=pwc-archive/papers-with-abstracts&split=train&query={query}&offset={offset}&length={PAGE_SIZE}"
|
| 94 |
+
|
| 95 |
+
with st.spinner("Searching..."):
|
| 96 |
+
response = requests.get(search_url)
|
| 97 |
+
if response.status_code == 200:
|
| 98 |
+
data = response.json()
|
| 99 |
+
papers = [item['row'] for item in data['rows']]
|
| 100 |
+
|
| 101 |
+
if not papers:
|
| 102 |
+
st.warning("No matches found.")
|
| 103 |
+
|
| 104 |
+
for p in papers:
|
| 105 |
+
with st.expander(p['title']):
|
| 106 |
+
st.write(p['abstract'])
|
| 107 |
+
if p.get('arxiv_id'):
|
| 108 |
+
st.link_button("ArXiv", f"https://arxiv.org/abs/{p['arxiv_id']}")
|
| 109 |
+
else:
|
| 110 |
+
st.error("The search service is currently unavailable.")
|
| 111 |
+
else:
|
| 112 |
+
st.write("Type something above to begin your search.")
|
| 113 |
|
| 114 |
+
# --- VIEW: SOTA ---
|
| 115 |
elif st.session_state.current_view == "sota":
|
| 116 |
st.title("π State-of-the-Art")
|
| 117 |
st.info("Leaderboards coming soon! This page will show rankings for different ML tasks.")
|