Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -235,67 +235,53 @@ def process_question(user_question, app, config):
|
|
235 |
return events
|
236 |
|
237 |
# --- Streamlit UI ---
|
|
|
|
|
238 |
def main():
|
239 |
-
st.set_page_config(
|
240 |
-
|
241 |
-
""
|
242 |
-
|
243 |
-
.stApp { background-color: #f8f9fa; }
|
244 |
-
.stButton > button { width: 100%; margin-top: 20px; }
|
245 |
-
.data-box { padding: 20px; border-radius: 10px; margin: 10px 0; }
|
246 |
-
.research-box { background-color: #e3f2fd; border-left: 5px solid #1976d2; }
|
247 |
-
.dev-box { background-color: #e8f5e9; border-left: 5px solid #43a047; }
|
248 |
-
</style>
|
249 |
-
""", unsafe_allow_html=True
|
250 |
)
|
251 |
|
252 |
-
#
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
|
262 |
-
st.title("
|
263 |
-
st.markdown("
|
264 |
-
query = st.text_area("Enter your question:", height=100, placeholder="e.g., What is the latest advancement in AI research?")
|
265 |
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
if query:
|
270 |
-
with st.spinner('Processing your question...'):
|
271 |
-
events = process_question(query, app_workflow, {"configurable": {"thread_id": "1"}})
|
272 |
-
for event in events:
|
273 |
-
if 'agent' in event:
|
274 |
-
with st.expander("π Processing Step", expanded=True):
|
275 |
-
content = event['agent']['messages'][0].content
|
276 |
-
if "Results:" in content:
|
277 |
-
st.markdown("### π Retrieved Documents:")
|
278 |
-
docs = content[content.find("Results:"):]
|
279 |
-
st.info(docs)
|
280 |
-
elif 'generate' in event:
|
281 |
-
st.markdown("### β¨ Final Answer:")
|
282 |
-
st.success(event['generate']['messages'][0].content)
|
283 |
-
else:
|
284 |
-
st.warning("β οΈ Please enter a question first!")
|
285 |
-
with col2:
|
286 |
-
st.markdown(
|
287 |
-
"""
|
288 |
-
### π― How to Use
|
289 |
-
1. Type your question in the text box.
|
290 |
-
2. Click "Get Answer" to process.
|
291 |
-
3. View retrieved documents and the final answer.
|
292 |
-
|
293 |
-
### π‘ Example Questions
|
294 |
-
- What are the latest advancements in AI research?
|
295 |
-
- What is the status of Project A?
|
296 |
-
- What are the current trends in machine learning?
|
297 |
-
"""
|
298 |
-
)
|
299 |
|
300 |
if __name__ == "__main__":
|
301 |
main()
|
|
|
235 |
return events
|
236 |
|
237 |
# --- Streamlit UI ---
|
238 |
+
import streamlit as st
|
239 |
+
|
240 |
def main():
|
241 |
+
st.set_page_config(
|
242 |
+
page_title="Enhanced Contrast Chatbot",
|
243 |
+
layout="wide",
|
244 |
+
initial_sidebar_state="expanded"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
)
|
246 |
|
247 |
+
# Custom CSS to improve text visibility
|
248 |
+
st.markdown("""
|
249 |
+
<style>
|
250 |
+
/* Force a white background for the main app area */
|
251 |
+
.stApp {
|
252 |
+
background-color: #ffffff !important;
|
253 |
+
}
|
254 |
+
|
255 |
+
/* Make text darker for better contrast */
|
256 |
+
html, body, [class^="css"] {
|
257 |
+
color: #111111 !important;
|
258 |
+
}
|
259 |
+
|
260 |
+
/* Adjust label text (like "Enter your question") */
|
261 |
+
.stTextArea label {
|
262 |
+
color: #111111 !important;
|
263 |
+
}
|
264 |
+
|
265 |
+
/* Make sure sidebar text is also dark */
|
266 |
+
.css-1v3fvcr {
|
267 |
+
color: #111111 !important;
|
268 |
+
}
|
269 |
+
|
270 |
+
/* Example: You can also adjust the background color of
|
271 |
+
your "data-box" classes if needed */
|
272 |
+
.data-box {
|
273 |
+
background-color: #f0f0f0 !important;
|
274 |
+
color: #111111 !important;
|
275 |
+
}
|
276 |
+
</style>
|
277 |
+
""", unsafe_allow_html=True)
|
278 |
|
279 |
+
st.title("Enhanced Contrast Chatbot")
|
280 |
+
st.markdown("Try typing your question below to see if the text is clearer now:")
|
|
|
281 |
|
282 |
+
user_query = st.text_area("Enter your question here:")
|
283 |
+
if st.button("Submit"):
|
284 |
+
st.write("Your query:", user_query)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
if __name__ == "__main__":
|
287 |
main()
|