Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,37 +35,49 @@ st.set_page_config(page_title="PDF Assistant", page_icon="π", layout="wide")
|
|
| 35 |
# ---------------- CSS ----------------
|
| 36 |
st.markdown("""
|
| 37 |
<style>
|
| 38 |
-
/* 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
[data-testid="stSidebar"] {
|
| 40 |
position: fixed;
|
| 41 |
overflow-y: hidden !important;
|
| 42 |
height: 100vh;
|
| 43 |
-
z-index:
|
|
|
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
-
/*
|
| 47 |
-
/* This pins the title to the top and adds a background so chat flows under it */
|
| 48 |
.fixed-header {
|
| 49 |
position: fixed;
|
| 50 |
top: 0;
|
| 51 |
left: 0;
|
| 52 |
width: 100%;
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
| 59 |
}
|
| 60 |
|
| 61 |
-
/*
|
| 62 |
.main .block-container {
|
| 63 |
-
margin-top:
|
|
|
|
| 64 |
padding-bottom: 5rem;
|
| 65 |
-
overflow-y: auto;
|
| 66 |
}
|
| 67 |
|
| 68 |
-
/*
|
| 69 |
[data-testid="stSidebar"] .stButton button {
|
| 70 |
width: 100%;
|
| 71 |
border-radius: 8px;
|
|
@@ -73,12 +85,12 @@ st.markdown("""
|
|
| 73 |
margin-bottom: 6px;
|
| 74 |
}
|
| 75 |
|
| 76 |
-
/*
|
| 77 |
section[data-testid="stFileUploader"] ul {
|
| 78 |
display: none;
|
| 79 |
}
|
| 80 |
|
| 81 |
-
/*
|
| 82 |
.chat-user {
|
| 83 |
background: #2d3748;
|
| 84 |
padding: 12px;
|
|
@@ -105,14 +117,15 @@ section[data-testid="stFileUploader"] ul {
|
|
| 105 |
padding-top: 5px;
|
| 106 |
}
|
| 107 |
|
| 108 |
-
/*
|
| 109 |
.title-text {
|
| 110 |
-
font-size: 2.
|
| 111 |
font-weight: 800;
|
| 112 |
margin: 0;
|
|
|
|
| 113 |
}
|
| 114 |
.creator-text {
|
| 115 |
-
font-size:
|
| 116 |
font-weight: 500;
|
| 117 |
color: #cccccc;
|
| 118 |
}
|
|
@@ -121,7 +134,7 @@ section[data-testid="stFileUploader"] ul {
|
|
| 121 |
text-decoration: none;
|
| 122 |
}
|
| 123 |
|
| 124 |
-
/*
|
| 125 |
[data-testid="stForm"] {
|
| 126 |
border: none;
|
| 127 |
padding: 0;
|
|
@@ -130,6 +143,7 @@ section[data-testid="stFileUploader"] ul {
|
|
| 130 |
""", unsafe_allow_html=True)
|
| 131 |
|
| 132 |
# ---------------- FIXED HEADER ----------------
|
|
|
|
| 133 |
st.markdown("""
|
| 134 |
<div class="fixed-header">
|
| 135 |
<div class="title-text">π PDF Assistant</div>
|
|
@@ -288,10 +302,10 @@ if submit_btn and user_question:
|
|
| 288 |
st.session_state.chat.append(("bot", bot_msg))
|
| 289 |
else:
|
| 290 |
st.session_state.chat.append(("bot", f"π΄ **Error:** {error}"))
|
| 291 |
-
st.rerun()
|
| 292 |
|
| 293 |
# ---------------- CHAT HISTORY (REVERSED) ----------------
|
| 294 |
-
#
|
| 295 |
if st.session_state.chat:
|
| 296 |
st.markdown("---")
|
| 297 |
for role, msg in reversed(st.session_state.chat):
|
|
|
|
| 35 |
# ---------------- CSS ----------------
|
| 36 |
st.markdown("""
|
| 37 |
<style>
|
| 38 |
+
/* 1. HIDE DEFAULT STREAMLIT HEADER & FOOTER */
|
| 39 |
+
header[data-testid="stHeader"] {
|
| 40 |
+
display: none;
|
| 41 |
+
}
|
| 42 |
+
footer {
|
| 43 |
+
display: none;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/* 2. SCROLL FIX FOR SIDEBAR */
|
| 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 |
+
/* 3. FIXED HEADER STYLING */
|
|
|
|
| 57 |
.fixed-header {
|
| 58 |
position: fixed;
|
| 59 |
top: 0;
|
| 60 |
left: 0;
|
| 61 |
width: 100%;
|
| 62 |
+
height: 5rem; /* Fixed height */
|
| 63 |
+
background-color: #0e1117;
|
| 64 |
+
z-index: 99998; /* Just below sidebar, above content */
|
| 65 |
+
display: flex;
|
| 66 |
+
flex-direction: column;
|
| 67 |
+
justify-content: center;
|
| 68 |
+
align-items: center;
|
| 69 |
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
| 70 |
}
|
| 71 |
|
| 72 |
+
/* 4. ADJUST MAIN CONTENT TO ACCOUNT FOR FIXED HEADER */
|
| 73 |
.main .block-container {
|
| 74 |
+
margin-top: 4rem; /* Push content down */
|
| 75 |
+
padding-top: 2rem;
|
| 76 |
padding-bottom: 5rem;
|
| 77 |
+
overflow-y: auto;
|
| 78 |
}
|
| 79 |
|
| 80 |
+
/* 5. SIDEBAR BUTTON STYLING */
|
| 81 |
[data-testid="stSidebar"] .stButton button {
|
| 82 |
width: 100%;
|
| 83 |
border-radius: 8px;
|
|
|
|
| 85 |
margin-bottom: 6px;
|
| 86 |
}
|
| 87 |
|
| 88 |
+
/* 6. HIDE UPLOADED FILE LIST */
|
| 89 |
section[data-testid="stFileUploader"] ul {
|
| 90 |
display: none;
|
| 91 |
}
|
| 92 |
|
| 93 |
+
/* 7. CHAT BUBBLES */
|
| 94 |
.chat-user {
|
| 95 |
background: #2d3748;
|
| 96 |
padding: 12px;
|
|
|
|
| 117 |
padding-top: 5px;
|
| 118 |
}
|
| 119 |
|
| 120 |
+
/* 8. TITLE TEXT */
|
| 121 |
.title-text {
|
| 122 |
+
font-size: 2.2rem;
|
| 123 |
font-weight: 800;
|
| 124 |
margin: 0;
|
| 125 |
+
line-height: 1.2;
|
| 126 |
}
|
| 127 |
.creator-text {
|
| 128 |
+
font-size: 0.9rem;
|
| 129 |
font-weight: 500;
|
| 130 |
color: #cccccc;
|
| 131 |
}
|
|
|
|
| 134 |
text-decoration: none;
|
| 135 |
}
|
| 136 |
|
| 137 |
+
/* 9. INPUT FORM STYLING */
|
| 138 |
[data-testid="stForm"] {
|
| 139 |
border: none;
|
| 140 |
padding: 0;
|
|
|
|
| 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>
|
|
|
|
| 302 |
st.session_state.chat.append(("bot", bot_msg))
|
| 303 |
else:
|
| 304 |
st.session_state.chat.append(("bot", f"π΄ **Error:** {error}"))
|
| 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):
|