Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
from openai import OpenAI
|
| 3 |
import time
|
| 4 |
import os
|
|
@@ -19,14 +19,14 @@ assistant_id = os.getenv("ASSISTANT_ID")
|
|
| 19 |
client = OpenAI(api_key=openai_key)
|
| 20 |
|
| 21 |
# π Streamlit Config
|
| 22 |
-
st.set_page_config(page_title="
|
| 23 |
|
| 24 |
# π― Session + User ID
|
| 25 |
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 |
-
# πΌοΈ
|
| 30 |
st.markdown("""
|
| 31 |
<style>
|
| 32 |
.block-container {padding-top: 1rem; padding-bottom: 0rem;}
|
|
@@ -34,15 +34,15 @@ st.markdown("""
|
|
| 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 |
-
.
|
| 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://
|
| 45 |
-
<span style='font-size: 12px; color: gray;'>Powered by
|
| 46 |
</span>
|
| 47 |
</div>
|
| 48 |
""", unsafe_allow_html=True)
|
|
@@ -69,13 +69,13 @@ def save_message(role, content):
|
|
| 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://
|
| 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>
|
| 79 |
|
| 80 |
# π Main Chat UI
|
| 81 |
input_col, clear_col = st.columns([9, 1])
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
from openai import OpenAI
|
| 3 |
import time
|
| 4 |
import os
|
|
|
|
| 19 |
client = OpenAI(api_key=openai_key)
|
| 20 |
|
| 21 |
# π Streamlit Config
|
| 22 |
+
st.set_page_config(page_title="LOR Technologies AI Assistant", layout="wide")
|
| 23 |
|
| 24 |
# π― Session + User ID
|
| 25 |
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 |
+
# πΌοΈ LOR Branding + Styling
|
| 30 |
st.markdown("""
|
| 31 |
<style>
|
| 32 |
.block-container {padding-top: 1rem; padding-bottom: 0rem;}
|
|
|
|
| 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])
|