IAMTFRMZA commited on
Commit
e3583dd
·
verified ·
1 Parent(s): b49b60b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -6
app.py CHANGED
@@ -3,7 +3,6 @@ from openai import OpenAI
3
  import time
4
  import datetime
5
  import os
6
- from streamlit_extras.stylable_container import stylable_container
7
 
8
  # Securely get credentials
9
  generated_user = os.getenv("User")
@@ -15,6 +14,26 @@ st.set_page_config(page_title="Carfind.co.za AI Assistant", layout="wide")
15
  st.title("🚗 Carfind.co.za AI Assistant")
16
  st.caption("Chat with Carfind.co.za and find your next car fast")
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  # Initialize authentication state
19
  if "authenticated" not in st.session_state:
20
  st.session_state.authenticated = False
@@ -41,13 +60,15 @@ else:
41
  if "messages" not in st.session_state:
42
  st.session_state["messages"] = []
43
 
44
- # Chat display with smooth scrolling
45
- with stylable_container("chat-container", css="overflow-y: auto; height: 70vh; padding: 10px;"):
46
- for message in st.session_state.messages:
 
47
  with st.chat_message(message["role"]):
48
  st.markdown(message["content"], unsafe_allow_html=True)
 
49
 
50
- # Input row with Clear button as an icon
51
  col_input, col_clear = st.columns([8, 1])
52
 
53
  with col_input:
@@ -112,4 +133,4 @@ else:
112
  st.error(f"An error occurred: {str(e)}")
113
 
114
  else:
115
- st.error("OpenAI key not found. Please ensure it is set as a Hugging Face secret.")
 
3
  import time
4
  import datetime
5
  import os
 
6
 
7
  # Securely get credentials
8
  generated_user = os.getenv("User")
 
14
  st.title("🚗 Carfind.co.za AI Assistant")
15
  st.caption("Chat with Carfind.co.za and find your next car fast")
16
 
17
+ # Custom CSS for scrollable chat container
18
+ st.markdown(
19
+ """
20
+ <style>
21
+ .chat-container {
22
+ overflow-y: auto;
23
+ max-height: 70vh;
24
+ padding: 10px;
25
+ border-radius: 10px;
26
+ border: 1px solid #444;
27
+ background-color: #111;
28
+ }
29
+ .element-container:has(> .stChatMessage) {
30
+ margin-bottom: 20px;
31
+ }
32
+ </style>
33
+ """,
34
+ unsafe_allow_html=True
35
+ )
36
+
37
  # Initialize authentication state
38
  if "authenticated" not in st.session_state:
39
  st.session_state.authenticated = False
 
60
  if "messages" not in st.session_state:
61
  st.session_state["messages"] = []
62
 
63
+ # Scrollable chat display
64
+ with st.container():
65
+ st.markdown('<div class="chat-container">', unsafe_allow_html=True)
66
+ for message in st.session_state["messages"]:
67
  with st.chat_message(message["role"]):
68
  st.markdown(message["content"], unsafe_allow_html=True)
69
+ st.markdown('</div>', unsafe_allow_html=True)
70
 
71
+ # Input and clear button
72
  col_input, col_clear = st.columns([8, 1])
73
 
74
  with col_input:
 
133
  st.error(f"An error occurred: {str(e)}")
134
 
135
  else:
136
+ st.error("OpenAI key not found. Please ensure it is set as a Hugging Face secret.")