Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,45 +47,51 @@ def chat_history(session_id):
|
|
| 47 |
# Generate unique session ID
|
| 48 |
if "session_id" not in st.session_state:
|
| 49 |
st.session_state.session_id = str(uuid.uuid4())
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
st.
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
.
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
# Get session ID
|
|
|
|
| 47 |
# Generate unique session ID
|
| 48 |
if "session_id" not in st.session_state:
|
| 49 |
st.session_state.session_id = str(uuid.uuid4())
|
| 50 |
+
col1, col2 = st.columns([4, 1])
|
| 51 |
+
with col2:
|
| 52 |
+
if st.button("π New Chat"):
|
| 53 |
+
st.session_state.session_id = str(uuid.uuid4()) # Generate new session
|
| 54 |
+
st.session_state.messages = [] # Clear chat history
|
| 55 |
+
st.rerun() # Refresh the app
|
| 56 |
+
with col1:
|
| 57 |
+
# Custom CSS for UI enhancements
|
| 58 |
+
st.markdown("""
|
| 59 |
+
<style>
|
| 60 |
+
/* Style for the title animation */
|
| 61 |
+
.title-text {
|
| 62 |
+
text-align: center;
|
| 63 |
+
font-size: 30px;
|
| 64 |
+
font-weight: bold;
|
| 65 |
+
color: #FF4500;
|
| 66 |
+
margin-bottom: 20px;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/* Keep input field fixed at the bottom */
|
| 70 |
+
.stTextInput {
|
| 71 |
+
position: fixed;
|
| 72 |
+
bottom: 10px;
|
| 73 |
+
width: 80%;
|
| 74 |
+
left: 10%;
|
| 75 |
+
z-index: 999;
|
| 76 |
+
}
|
| 77 |
+
</style>
|
| 78 |
+
""", unsafe_allow_html=True)
|
| 79 |
+
|
| 80 |
+
# πΉ **Animated Title Function**
|
| 81 |
+
def animated_text(text, speed=0.05):
|
| 82 |
+
placeholder = st.empty()
|
| 83 |
+
displayed_text = ""
|
| 84 |
+
|
| 85 |
+
for letter in text:
|
| 86 |
+
displayed_text += letter
|
| 87 |
+
placeholder.markdown(f"""
|
| 88 |
+
<h1 style="text-align:center; color: #00D1FF;">{displayed_text} π</h1>
|
| 89 |
+
""", unsafe_allow_html=True) # Corrected f-string formatting
|
| 90 |
+
time.sleep(speed)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
# πΉ **Display Animated Welcome Message**
|
| 94 |
+
animated_text('Conversational AI Data Science Tutor')
|
| 95 |
|
| 96 |
|
| 97 |
# Get session ID
|