Mpavan45 commited on
Commit
de9f07e
Β·
verified Β·
1 Parent(s): 1441e1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -39
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
- # Custom CSS for UI enhancements
52
- st.markdown("""
53
- <style>
54
- /* Style for the title animation */
55
- .title-text {
56
- text-align: center;
57
- font-size: 30px;
58
- font-weight: bold;
59
- color: #FF4500;
60
- margin-bottom: 20px;
61
- }
62
-
63
- /* Keep input field fixed at the bottom */
64
- .stTextInput {
65
- position: fixed;
66
- bottom: 10px;
67
- width: 80%;
68
- left: 10%;
69
- z-index: 999;
70
- }
71
- </style>
72
- """, unsafe_allow_html=True)
73
-
74
- # πŸ”Ή **Animated Title Function**
75
- def animated_text(text, speed=0.05):
76
- placeholder = st.empty()
77
- displayed_text = ""
78
-
79
- for letter in text:
80
- displayed_text += letter
81
- placeholder.markdown(f"""
82
- <h1 style="text-align:center; color: #00D1FF;">{displayed_text} πŸš€</h1>
83
- """, unsafe_allow_html=True) # Corrected f-string formatting
84
- time.sleep(speed)
85
-
86
-
87
- # πŸ”Ή **Display Animated Welcome Message**
88
- animated_text('Conversational AI Data Science Tutor')
 
 
 
 
 
 
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