IAMTFRMZA commited on
Commit
0bfec63
·
verified ·
1 Parent(s): d93083e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -26,22 +26,23 @@ if "user_id" not in st.session_state:
26
  st.session_state["user_id"] = str(uuid.uuid4())
27
  user_id = st.session_state["user_id"]
28
 
29
- # 🖼️ Branding + Styling
30
  st.markdown("""
31
  <style>
32
  .block-container {padding-top: 1rem; padding-bottom: 0rem;}
33
  header {visibility: hidden;}
34
  .stChatMessage { max-width: 85%; border-radius: 12px; padding: 8px; margin-bottom: 10px; }
35
  .stChatMessage[data-testid="stChatMessage-user"] { background: #f0f0f0; color: #000000; }
36
- .stChatMessage[data-testid="stChatMessage-assistant"] { background: #D6E9FE; color: #000000; }
 
37
  </style>
38
  """, unsafe_allow_html=True)
39
 
40
  st.markdown("""
41
  <div style='text-align: center; margin-top: 20px; margin-bottom: -10px;'>
42
  <span style='display: inline-flex; align-items: center; gap: 8px;'>
43
- <img src='https://www.carfind.co.za/images/Carfind-Icon.svg' width='28' class='carfind-logo'/>
44
- <span style='font-size: 12px; color: gray;'>Powered by Carfind</span>
45
  </span>
46
  </div>
47
  """, unsafe_allow_html=True)
@@ -68,13 +69,13 @@ def save_message(role, content):
68
  # 💬 Display chat history
69
  def display_chat_history():
70
  messages = db.collection("users").document(user_id).collection("messages").order_by("timestamp").stream()
71
- assistant_icon_html = "<img src='https://www.carfind.co.za/images/Carfind-Icon.svg' width='20' style='vertical-align:middle;'/>"
72
  for msg in list(messages)[::-1]:
73
  data = msg.to_dict()
74
  if data["role"] == "user":
75
  st.markdown(f"<div class='stChatMessage' data-testid='stChatMessage-user'>👤 <strong>You:</strong> {data['content']}</div>", unsafe_allow_html=True)
76
  else:
77
- st.markdown(f"<div class='stChatMessage' data-testid='stChatMessage-assistant'>{assistant_icon_html} <strong>Carfind Assistant:</strong> {data['content']}</div>", unsafe_allow_html=True)
78
 
79
  # 🚀 Main Chat UI
80
  input_col, clear_col = st.columns([9, 1])
@@ -97,6 +98,7 @@ thread_id = get_or_create_thread_id()
97
  display_chat_history()
98
 
99
  if user_input:
 
100
  client.beta.threads.messages.create(thread_id=thread_id, role="user", content=user_input)
101
  save_message("user", user_input)
102
 
 
26
  st.session_state["user_id"] = str(uuid.uuid4())
27
  user_id = st.session_state["user_id"]
28
 
29
+ # 🖼️ LOR Branding + Styling
30
  st.markdown("""
31
  <style>
32
  .block-container {padding-top: 1rem; padding-bottom: 0rem;}
33
  header {visibility: hidden;}
34
  .stChatMessage { max-width: 85%; border-radius: 12px; padding: 8px; margin-bottom: 10px; }
35
  .stChatMessage[data-testid="stChatMessage-user"] { background: #f0f0f0; color: #000000; }
36
+ .stChatMessage[data-testid="stChatMessage-assistant"] { background: #e3f2fd; color: #000000; }
37
+ .lor-logo { vertical-align: middle; }
38
  </style>
39
  """, unsafe_allow_html=True)
40
 
41
  st.markdown("""
42
  <div style='text-align: center; margin-top: 20px; margin-bottom: -10px;'>
43
  <span style='display: inline-flex; align-items: center; gap: 8px;'>
44
+ <img src='https://lortechnologies.com/wp-content/uploads/2023/03/LOR-Online-Logo.svg' width='100' class='lor-logo'/>
45
+ <span style='font-size: 12px; color: gray;'>Powered by LOR Technologies</span>
46
  </span>
47
  </div>
48
  """, unsafe_allow_html=True)
 
69
  # 💬 Display chat history
70
  def display_chat_history():
71
  messages = db.collection("users").document(user_id).collection("messages").order_by("timestamp").stream()
72
+ assistant_icon_html = "<img src='https://lortechnologies.com/wp-content/uploads/2023/03/LOR-Online-Logo.svg' width='20' style='vertical-align:middle;'/>"
73
  for msg in list(messages)[::-1]:
74
  data = msg.to_dict()
75
  if data["role"] == "user":
76
  st.markdown(f"<div class='stChatMessage' data-testid='stChatMessage-user'>👤 <strong>You:</strong> {data['content']}</div>", unsafe_allow_html=True)
77
  else:
78
+ st.markdown(f"<div class='stChatMessage' data-testid='stChatMessage-assistant'>{assistant_icon_html} <strong>LOR Assistant:</strong> {data['content']}</div>", unsafe_allow_html=True)
79
 
80
  # 🚀 Main Chat UI
81
  input_col, clear_col = st.columns([9, 1])
 
98
  display_chat_history()
99
 
100
  if user_input:
101
+ # Send user message to OpenAI thread
102
  client.beta.threads.messages.create(thread_id=thread_id, role="user", content=user_input)
103
  save_message("user", user_input)
104