Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,7 +35,14 @@ st.set_page_config(page_title="PDF Assistant", page_icon="π", layout="wide")
|
|
| 35 |
# ---------------- CSS ----------------
|
| 36 |
st.markdown("""
|
| 37 |
<style>
|
| 38 |
-
/* 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
header[data-testid="stHeader"] {
|
| 40 |
display: none;
|
| 41 |
}
|
|
@@ -43,25 +50,26 @@ footer {
|
|
| 43 |
display: none;
|
| 44 |
}
|
| 45 |
|
| 46 |
-
/*
|
| 47 |
[data-testid="stSidebar"] {
|
| 48 |
position: fixed;
|
| 49 |
-
overflow-y: hidden !important;
|
| 50 |
-
height: 100vh;
|
| 51 |
-
z-index: 99999; /* Very high z-index to sit on top */
|
| 52 |
top: 0;
|
| 53 |
left: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
-
/*
|
| 57 |
.fixed-header {
|
| 58 |
position: fixed;
|
| 59 |
top: 0;
|
| 60 |
left: 0;
|
| 61 |
width: 100%;
|
| 62 |
-
height:
|
| 63 |
background-color: #0e1117;
|
| 64 |
-
z-index: 99998;
|
| 65 |
display: flex;
|
| 66 |
flex-direction: column;
|
| 67 |
justify-content: center;
|
|
@@ -69,15 +77,23 @@ footer {
|
|
| 69 |
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
| 70 |
}
|
| 71 |
|
| 72 |
-
/*
|
| 73 |
.main .block-container {
|
| 74 |
-
margin-top:
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
padding-bottom: 5rem;
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
}
|
| 79 |
|
| 80 |
-
/*
|
| 81 |
[data-testid="stSidebar"] .stButton button {
|
| 82 |
width: 100%;
|
| 83 |
border-radius: 8px;
|
|
@@ -85,12 +101,15 @@ footer {
|
|
| 85 |
margin-bottom: 6px;
|
| 86 |
}
|
| 87 |
|
| 88 |
-
/*
|
| 89 |
section[data-testid="stFileUploader"] ul {
|
| 90 |
display: none;
|
| 91 |
}
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
/*
|
| 94 |
.chat-user {
|
| 95 |
background: #2d3748;
|
| 96 |
padding: 12px;
|
|
@@ -117,15 +136,15 @@ section[data-testid="stFileUploader"] ul {
|
|
| 117 |
padding-top: 5px;
|
| 118 |
}
|
| 119 |
|
| 120 |
-
/*
|
| 121 |
.title-text {
|
| 122 |
-
font-size: 2.
|
| 123 |
font-weight: 800;
|
| 124 |
margin: 0;
|
| 125 |
line-height: 1.2;
|
| 126 |
}
|
| 127 |
.creator-text {
|
| 128 |
-
font-size:
|
| 129 |
font-weight: 500;
|
| 130 |
color: #cccccc;
|
| 131 |
}
|
|
@@ -134,7 +153,7 @@ section[data-testid="stFileUploader"] ul {
|
|
| 134 |
text-decoration: none;
|
| 135 |
}
|
| 136 |
|
| 137 |
-
/*
|
| 138 |
[data-testid="stForm"] {
|
| 139 |
border: none;
|
| 140 |
padding: 0;
|
|
@@ -143,12 +162,11 @@ section[data-testid="stFileUploader"] ul {
|
|
| 143 |
""", unsafe_allow_html=True)
|
| 144 |
|
| 145 |
# ---------------- FIXED HEADER ----------------
|
| 146 |
-
# Added high z-index in CSS to ensure it sits on top of everything except sidebar
|
| 147 |
st.markdown("""
|
| 148 |
<div class="fixed-header">
|
| 149 |
<div class="title-text">π PDF Assistant</div>
|
| 150 |
<div class="creator-text">
|
| 151 |
-
<a href="https://www.linkedin.com/in/abhishek-iitr/" target="_blank">Abhishek Saxena</a>
|
| 152 |
</div>
|
| 153 |
</div>
|
| 154 |
""", unsafe_allow_html=True)
|
|
@@ -273,7 +291,7 @@ with st.sidebar:
|
|
| 273 |
else:
|
| 274 |
st.error("β Failed.")
|
| 275 |
else:
|
| 276 |
-
st.success(f"
|
| 277 |
else:
|
| 278 |
st.warning("β¬οΈ Upload a PDF to start chatting!")
|
| 279 |
|
|
@@ -305,7 +323,6 @@ if submit_btn and user_question:
|
|
| 305 |
st.rerun()
|
| 306 |
|
| 307 |
# ---------------- CHAT HISTORY (REVERSED) ----------------
|
| 308 |
-
# Newest message comes FIRST (at the top, just below input)
|
| 309 |
if st.session_state.chat:
|
| 310 |
st.markdown("---")
|
| 311 |
for role, msg in reversed(st.session_state.chat):
|
|
|
|
| 35 |
# ---------------- CSS ----------------
|
| 36 |
st.markdown("""
|
| 37 |
<style>
|
| 38 |
+
/* 1. GLOBAL RESET & SCROLL LOCK */
|
| 39 |
+
html, body {
|
| 40 |
+
overflow: hidden;
|
| 41 |
+
height: 100%;
|
| 42 |
+
margin: 0;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/* 2. HIDE DEFAULT STREAMLIT ELEMENTS */
|
| 46 |
header[data-testid="stHeader"] {
|
| 47 |
display: none;
|
| 48 |
}
|
|
|
|
| 50 |
display: none;
|
| 51 |
}
|
| 52 |
|
| 53 |
+
/* 3. SIDEBAR STYLING (FROZEN LEFT PANEL) */
|
| 54 |
[data-testid="stSidebar"] {
|
| 55 |
position: fixed;
|
|
|
|
|
|
|
|
|
|
| 56 |
top: 0;
|
| 57 |
left: 0;
|
| 58 |
+
height: 100vh;
|
| 59 |
+
width: 20rem;
|
| 60 |
+
overflow: hidden !important;
|
| 61 |
+
z-index: 99999;
|
| 62 |
}
|
| 63 |
|
| 64 |
+
/* 4. FIXED HEADER STYLING */
|
| 65 |
.fixed-header {
|
| 66 |
position: fixed;
|
| 67 |
top: 0;
|
| 68 |
left: 0;
|
| 69 |
width: 100%;
|
| 70 |
+
height: 6rem;
|
| 71 |
background-color: #0e1117;
|
| 72 |
+
z-index: 99998;
|
| 73 |
display: flex;
|
| 74 |
flex-direction: column;
|
| 75 |
justify-content: center;
|
|
|
|
| 77 |
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
| 78 |
}
|
| 79 |
|
| 80 |
+
/* 5. MAIN CONTENT SCROLLING (INDEPENDENT RIGHT PANEL) */
|
| 81 |
.main .block-container {
|
| 82 |
+
margin-top: 6rem;
|
| 83 |
+
height: calc(100vh - 6rem);
|
| 84 |
+
overflow-y: auto;
|
| 85 |
+
padding-top: 1rem;
|
| 86 |
padding-bottom: 5rem;
|
| 87 |
+
}
|
| 88 |
+
.main .block-container::-webkit-scrollbar {
|
| 89 |
+
width: 8px;
|
| 90 |
+
}
|
| 91 |
+
.main .block-container::-webkit-scrollbar-thumb {
|
| 92 |
+
background: #2d3748;
|
| 93 |
+
border-radius: 4px;
|
| 94 |
}
|
| 95 |
|
| 96 |
+
/* 6. SIDEBAR BUTTON STYLING */
|
| 97 |
[data-testid="stSidebar"] .stButton button {
|
| 98 |
width: 100%;
|
| 99 |
border-radius: 8px;
|
|
|
|
| 101 |
margin-bottom: 6px;
|
| 102 |
}
|
| 103 |
|
| 104 |
+
/* 7. HIDE UPLOADED FILE LIST */
|
| 105 |
section[data-testid="stFileUploader"] ul {
|
| 106 |
display: none;
|
| 107 |
}
|
| 108 |
+
section[data-testid="stFileUploader"] small {
|
| 109 |
+
display: none;
|
| 110 |
+
}
|
| 111 |
|
| 112 |
+
/* 8. CHAT BUBBLES */
|
| 113 |
.chat-user {
|
| 114 |
background: #2d3748;
|
| 115 |
padding: 12px;
|
|
|
|
| 136 |
padding-top: 5px;
|
| 137 |
}
|
| 138 |
|
| 139 |
+
/* 9. TITLE TEXT */
|
| 140 |
.title-text {
|
| 141 |
+
font-size: 2.5rem;
|
| 142 |
font-weight: 800;
|
| 143 |
margin: 0;
|
| 144 |
line-height: 1.2;
|
| 145 |
}
|
| 146 |
.creator-text {
|
| 147 |
+
font-size: 1rem;
|
| 148 |
font-weight: 500;
|
| 149 |
color: #cccccc;
|
| 150 |
}
|
|
|
|
| 153 |
text-decoration: none;
|
| 154 |
}
|
| 155 |
|
| 156 |
+
/* 10. INPUT FORM STYLING */
|
| 157 |
[data-testid="stForm"] {
|
| 158 |
border: none;
|
| 159 |
padding: 0;
|
|
|
|
| 162 |
""", unsafe_allow_html=True)
|
| 163 |
|
| 164 |
# ---------------- FIXED HEADER ----------------
|
|
|
|
| 165 |
st.markdown("""
|
| 166 |
<div class="fixed-header">
|
| 167 |
<div class="title-text">π PDF Assistant</div>
|
| 168 |
<div class="creator-text">
|
| 169 |
+
by <a href="https://www.linkedin.com/in/abhishek-iitr/" target="_blank">Abhishek Saxena</a>
|
| 170 |
</div>
|
| 171 |
</div>
|
| 172 |
""", unsafe_allow_html=True)
|
|
|
|
| 291 |
else:
|
| 292 |
st.error("β Failed.")
|
| 293 |
else:
|
| 294 |
+
st.success(f"β
**Active:** `{uploaded.name}`")
|
| 295 |
else:
|
| 296 |
st.warning("β¬οΈ Upload a PDF to start chatting!")
|
| 297 |
|
|
|
|
| 323 |
st.rerun()
|
| 324 |
|
| 325 |
# ---------------- CHAT HISTORY (REVERSED) ----------------
|
|
|
|
| 326 |
if st.session_state.chat:
|
| 327 |
st.markdown("---")
|
| 328 |
for role, msg in reversed(st.session_state.chat):
|