Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -91,28 +91,32 @@ def main():
|
|
| 91 |
initial_sidebar_state="expanded"
|
| 92 |
)
|
| 93 |
|
| 94 |
-
# Custom CSS for
|
| 95 |
st.markdown(
|
| 96 |
"""
|
| 97 |
<style>
|
| 98 |
.main {
|
| 99 |
-
background-color: #
|
| 100 |
padding: 20px;
|
| 101 |
border-radius: 10px;
|
|
|
|
| 102 |
}
|
| 103 |
.sidebar .sidebar-content {
|
| 104 |
-
background-color: #
|
| 105 |
-
color:
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
.sidebar .sidebar-content .title {
|
| 108 |
font-size: 24px;
|
| 109 |
font-weight: bold;
|
|
|
|
| 110 |
}
|
| 111 |
.sidebar .sidebar-content .button {
|
| 112 |
background-color: #3498db;
|
| 113 |
border: none;
|
| 114 |
color: white;
|
| 115 |
-
padding: 10px;
|
| 116 |
text-align: center;
|
| 117 |
text-decoration: none;
|
| 118 |
display: inline-block;
|
|
@@ -124,6 +128,22 @@ def main():
|
|
| 124 |
.sidebar .sidebar-content .button:hover {
|
| 125 |
background-color: #2980b9;
|
| 126 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
</style>
|
| 128 |
""",
|
| 129 |
unsafe_allow_html=True
|
|
@@ -133,8 +153,8 @@ def main():
|
|
| 133 |
with st.sidebar:
|
| 134 |
st.title("Menu")
|
| 135 |
pdf_docs = st.file_uploader(
|
| 136 |
-
"Upload your PDF files", accept_multiple_files=True)
|
| 137 |
-
if st.button("Submit & Process", key="submit_button"):
|
| 138 |
if pdf_docs:
|
| 139 |
try:
|
| 140 |
with st.spinner("Processing..."):
|
|
@@ -150,7 +170,7 @@ def main():
|
|
| 150 |
# Main content area for displaying chat messages
|
| 151 |
st.title("Gemini PDF Chatbot")
|
| 152 |
st.write("Welcome to the Gemini PDF Chatbot! Upload your PDFs and ask questions.")
|
| 153 |
-
st.sidebar.button('Clear Chat History', on_click=clear_chat_history)
|
| 154 |
|
| 155 |
# Initialize chat history
|
| 156 |
if "messages" not in st.session_state:
|
|
@@ -159,19 +179,20 @@ def main():
|
|
| 159 |
|
| 160 |
# Display chat messages
|
| 161 |
for message in st.session_state.messages:
|
| 162 |
-
|
|
|
|
| 163 |
st.write(message["content"])
|
| 164 |
|
| 165 |
# Chat input
|
| 166 |
if prompt := st.chat_input():
|
| 167 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 168 |
-
with st.
|
| 169 |
st.write(prompt)
|
| 170 |
|
| 171 |
# Generate bot response
|
| 172 |
if st.session_state.messages[-1]["role"] != "assistant":
|
| 173 |
try:
|
| 174 |
-
with st.
|
| 175 |
with st.spinner("Thinking..."):
|
| 176 |
response = user_input(prompt)
|
| 177 |
if response:
|
|
@@ -184,3 +205,4 @@ def main():
|
|
| 184 |
|
| 185 |
if __name__ == "__main__":
|
| 186 |
main()
|
|
|
|
|
|
| 91 |
initial_sidebar_state="expanded"
|
| 92 |
)
|
| 93 |
|
| 94 |
+
# Custom CSS for professional design
|
| 95 |
st.markdown(
|
| 96 |
"""
|
| 97 |
<style>
|
| 98 |
.main {
|
| 99 |
+
background-color: #f7f9fc;
|
| 100 |
padding: 20px;
|
| 101 |
border-radius: 10px;
|
| 102 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 103 |
}
|
| 104 |
.sidebar .sidebar-content {
|
| 105 |
+
background-color: #ffffff;
|
| 106 |
+
color: #2c3e50;
|
| 107 |
+
padding: 20px;
|
| 108 |
+
border-radius: 10px;
|
| 109 |
}
|
| 110 |
.sidebar .sidebar-content .title {
|
| 111 |
font-size: 24px;
|
| 112 |
font-weight: bold;
|
| 113 |
+
margin-bottom: 10px;
|
| 114 |
}
|
| 115 |
.sidebar .sidebar-content .button {
|
| 116 |
background-color: #3498db;
|
| 117 |
border: none;
|
| 118 |
color: white;
|
| 119 |
+
padding: 10px 20px;
|
| 120 |
text-align: center;
|
| 121 |
text-decoration: none;
|
| 122 |
display: inline-block;
|
|
|
|
| 128 |
.sidebar .sidebar-content .button:hover {
|
| 129 |
background-color: #2980b9;
|
| 130 |
}
|
| 131 |
+
.sidebar .sidebar-content .file-uploader {
|
| 132 |
+
margin-bottom: 20px;
|
| 133 |
+
}
|
| 134 |
+
.chat-message {
|
| 135 |
+
background-color: #ffffff;
|
| 136 |
+
padding: 15px;
|
| 137 |
+
border-radius: 10px;
|
| 138 |
+
margin-bottom: 10px;
|
| 139 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
| 140 |
+
}
|
| 141 |
+
.user-message {
|
| 142 |
+
background-color: #e0f7fa;
|
| 143 |
+
}
|
| 144 |
+
.assistant-message {
|
| 145 |
+
background-color: #e8eaf6;
|
| 146 |
+
}
|
| 147 |
</style>
|
| 148 |
""",
|
| 149 |
unsafe_allow_html=True
|
|
|
|
| 153 |
with st.sidebar:
|
| 154 |
st.title("Menu")
|
| 155 |
pdf_docs = st.file_uploader(
|
| 156 |
+
"Upload your PDF files", accept_multiple_files=True, className="file-uploader")
|
| 157 |
+
if st.button("Submit & Process", key="submit_button", className="button"):
|
| 158 |
if pdf_docs:
|
| 159 |
try:
|
| 160 |
with st.spinner("Processing..."):
|
|
|
|
| 170 |
# Main content area for displaying chat messages
|
| 171 |
st.title("Gemini PDF Chatbot")
|
| 172 |
st.write("Welcome to the Gemini PDF Chatbot! Upload your PDFs and ask questions.")
|
| 173 |
+
st.sidebar.button('Clear Chat History', on_click=clear_chat_history, className="button")
|
| 174 |
|
| 175 |
# Initialize chat history
|
| 176 |
if "messages" not in st.session_state:
|
|
|
|
| 179 |
|
| 180 |
# Display chat messages
|
| 181 |
for message in st.session_state.messages:
|
| 182 |
+
css_class = "user-message" if message["role"] == "user" else "assistant-message"
|
| 183 |
+
with st.container().className(f"chat-message {css_class}"):
|
| 184 |
st.write(message["content"])
|
| 185 |
|
| 186 |
# Chat input
|
| 187 |
if prompt := st.chat_input():
|
| 188 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 189 |
+
with st.container().className("chat-message user-message"):
|
| 190 |
st.write(prompt)
|
| 191 |
|
| 192 |
# Generate bot response
|
| 193 |
if st.session_state.messages[-1]["role"] != "assistant":
|
| 194 |
try:
|
| 195 |
+
with st.container().className("chat-message assistant-message"):
|
| 196 |
with st.spinner("Thinking..."):
|
| 197 |
response = user_input(prompt)
|
| 198 |
if response:
|
|
|
|
| 205 |
|
| 206 |
if __name__ == "__main__":
|
| 207 |
main()
|
| 208 |
+
|