Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +23 -47
src/streamlit_app.py
CHANGED
|
@@ -34,11 +34,9 @@ if "code" in st.query_params and not st.session_state.user_email:
|
|
| 34 |
cookies.save(); st.rerun()
|
| 35 |
except: pass
|
| 36 |
|
| 37 |
-
# ИСПРАВЛЕННЫЙ LOGOUT
|
| 38 |
def logout():
|
| 39 |
for key in ["saved_email", "saved_name"]:
|
| 40 |
-
if key in cookies:
|
| 41 |
-
del cookies[key]
|
| 42 |
cookies.save()
|
| 43 |
st.session_state.user_email = None
|
| 44 |
st.session_state.user_name = "Пользователь"
|
|
@@ -68,7 +66,6 @@ MODELS_CONFIG = {
|
|
| 68 |
"✨ HiperAI v1.1.3 (Stable)": {"engine": "openai", "model": "gpt-4o-mini", "identity": "HiperAI v1.1.3."},
|
| 69 |
}
|
| 70 |
|
| 71 |
-
# --- НОВЫЙ ДИЗАЙН И CSS ---
|
| 72 |
st.set_page_config(page_title="HiperDouble AI", page_icon="🧬", layout="wide")
|
| 73 |
|
| 74 |
if "chats" not in st.session_state: st.session_state.chats = load_chats()
|
|
@@ -76,15 +73,14 @@ if "current_chat" not in st.session_state or st.session_state.current_chat not i
|
|
| 76 |
st.session_state.current_chat = list(st.session_state.chats.keys())[0]
|
| 77 |
if "edit_mode" not in st.session_state: st.session_state.edit_mode = None
|
| 78 |
|
|
|
|
| 79 |
st.markdown("""
|
| 80 |
<style>
|
| 81 |
-
/* ФОН С ГРАДИЕНТОМ */
|
| 82 |
html, body, [data-testid="stAppViewContainer"] {
|
| 83 |
background: radial-gradient(circle at top right, #1a0b2e, #020205);
|
| 84 |
background-attachment: fixed;
|
| 85 |
}
|
| 86 |
|
| 87 |
-
/* НЕОНОВЫЙ ЗАГОЛОВОК */
|
| 88 |
.main-title {
|
| 89 |
font-size: clamp(2.3rem, 8vw, 4rem);
|
| 90 |
font-weight: 900;
|
|
@@ -95,59 +91,39 @@ st.markdown("""
|
|
| 95 |
-webkit-text-fill-color: transparent;
|
| 96 |
animation: shine 4s linear infinite;
|
| 97 |
padding: 20px 0;
|
| 98 |
-
text-shadow: 0px 10px 20px rgba(115, 103, 240, 0.3);
|
| 99 |
}
|
| 100 |
@keyframes shine { to { background-position: 200% center; } }
|
| 101 |
|
| 102 |
-
/* КОНТЕЙНЕР С
|
| 103 |
.main .block-container {
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
| 105 |
}
|
| 106 |
|
| 107 |
-
/* СТИЛЬ ПУЗЫРЕЙ ЧАТА */
|
| 108 |
-
.chat-bubble {
|
| 109 |
-
padding: 18px 22px;
|
| 110 |
-
border-radius: 20px;
|
| 111 |
-
margin-bottom: 18px;
|
| 112 |
-
background: rgba(255, 255, 255, 0.05);
|
| 113 |
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 114 |
-
backdrop-filter: blur(5px);
|
| 115 |
-
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
|
| 116 |
-
color: #e0e0e0;
|
| 117 |
-
}
|
| 118 |
-
.user-bubble {
|
| 119 |
-
border-left: 5px solid #ff00cc;
|
| 120 |
-
background: rgba(255, 0, 204, 0.08);
|
| 121 |
-
box-shadow: 0 4px 15px rgba(255, 0, 204, 0.1);
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
/* ПАНЕЛЬ ВВОДА */
|
| 125 |
[data-testid="stBottom"] {
|
| 126 |
position: fixed !important;
|
| 127 |
bottom: 0px !important;
|
| 128 |
-
background: rgba(10, 10, 20, 0.
|
| 129 |
-
backdrop-filter: blur(
|
| 130 |
z-index: 100 !important;
|
| 131 |
-
padding:
|
| 132 |
border-top: 1px solid rgba(115, 103, 240, 0.3);
|
| 133 |
}
|
| 134 |
|
| 135 |
-
|
| 136 |
-
[data-testid="stSidebar"] {
|
| 137 |
-
background-color: #0a0a15 !important;
|
| 138 |
-
border-right: 1px solid rgba(255,255,255,0.05);
|
| 139 |
-
}
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
border-radius:
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
color: #
|
| 149 |
-
transform: translateY(-2px);
|
| 150 |
}
|
|
|
|
| 151 |
</style>
|
| 152 |
""", unsafe_allow_html=True)
|
| 153 |
|
|
@@ -189,15 +165,15 @@ with st.sidebar:
|
|
| 189 |
save_chats(st.session_state.chats); st.session_state.edit_mode = None; st.session_state.current_chat = new_n; st.rerun()
|
| 190 |
|
| 191 |
# --- ЭКРАН ---
|
|
|
|
| 192 |
st.markdown('<p class="main-title">HiperDouble AI</p>', unsafe_allow_html=True)
|
| 193 |
|
| 194 |
if st.session_state.current_chat in st.session_state.chats:
|
| 195 |
messages = st.session_state.chats[st.session_state.current_chat]
|
| 196 |
-
|
|
|
|
| 197 |
r_name, r_class = ("Вы", "user-bubble") if m['role'] == 'user' else ("HiperAi", "")
|
| 198 |
st.markdown(f"<div class='chat-bubble {r_class}'><b>{r_name}:</b><br>{m['content']}</div>", unsafe_allow_html=True)
|
| 199 |
-
|
| 200 |
-
st.markdown("<div style='height: 100px;'></div>", unsafe_allow_html=True)
|
| 201 |
|
| 202 |
# ПОЛЕ ВВОДА
|
| 203 |
u_input = st.chat_input(T['in'])
|
|
|
|
| 34 |
cookies.save(); st.rerun()
|
| 35 |
except: pass
|
| 36 |
|
|
|
|
| 37 |
def logout():
|
| 38 |
for key in ["saved_email", "saved_name"]:
|
| 39 |
+
if key in cookies: del cookies[key]
|
|
|
|
| 40 |
cookies.save()
|
| 41 |
st.session_state.user_email = None
|
| 42 |
st.session_state.user_name = "Пользователь"
|
|
|
|
| 66 |
"✨ HiperAI v1.1.3 (Stable)": {"engine": "openai", "model": "gpt-4o-mini", "identity": "HiperAI v1.1.3."},
|
| 67 |
}
|
| 68 |
|
|
|
|
| 69 |
st.set_page_config(page_title="HiperDouble AI", page_icon="🧬", layout="wide")
|
| 70 |
|
| 71 |
if "chats" not in st.session_state: st.session_state.chats = load_chats()
|
|
|
|
| 73 |
st.session_state.current_chat = list(st.session_state.chats.keys())[0]
|
| 74 |
if "edit_mode" not in st.session_state: st.session_state.edit_mode = None
|
| 75 |
|
| 76 |
+
# --- ГЛАВНЫЙ ФИКС CSS ---
|
| 77 |
st.markdown("""
|
| 78 |
<style>
|
|
|
|
| 79 |
html, body, [data-testid="stAppViewContainer"] {
|
| 80 |
background: radial-gradient(circle at top right, #1a0b2e, #020205);
|
| 81 |
background-attachment: fixed;
|
| 82 |
}
|
| 83 |
|
|
|
|
| 84 |
.main-title {
|
| 85 |
font-size: clamp(2.3rem, 8vw, 4rem);
|
| 86 |
font-weight: 900;
|
|
|
|
| 91 |
-webkit-text-fill-color: transparent;
|
| 92 |
animation: shine 4s linear infinite;
|
| 93 |
padding: 20px 0;
|
|
|
|
| 94 |
}
|
| 95 |
@keyframes shine { to { background-position: 200% center; } }
|
| 96 |
|
| 97 |
+
/* ФИКС КОНТЕЙНЕРА: Сообщения теперь растут СНИЗУ ВВЕРХ */
|
| 98 |
.main .block-container {
|
| 99 |
+
display: flex !important;
|
| 100 |
+
flex-direction: column-reverse !important; /* НОВЫЕ СВЕРХУ, СТАРЫЕ ВНИЗУ */
|
| 101 |
+
padding-bottom: 150px !important;
|
| 102 |
+
padding-top: 20px !important;
|
| 103 |
}
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
[data-testid="stBottom"] {
|
| 106 |
position: fixed !important;
|
| 107 |
bottom: 0px !important;
|
| 108 |
+
background: rgba(10, 10, 20, 0.98) !important;
|
| 109 |
+
backdrop-filter: blur(15px);
|
| 110 |
z-index: 100 !important;
|
| 111 |
+
padding: 10px 5% 40px 5% !important;
|
| 112 |
border-top: 1px solid rgba(115, 103, 240, 0.3);
|
| 113 |
}
|
| 114 |
|
| 115 |
+
[data-testid="stSidebar"] { background-color: #0a0a15 !important; z-index: 999999 !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
+
.chat-bubble {
|
| 118 |
+
padding: 18px 22px;
|
| 119 |
+
border-radius: 20px;
|
| 120 |
+
margin-top: 15px; /* Теперь margin-top, т.к. порядок обратный */
|
| 121 |
+
background: rgba(255, 255, 255, 0.05);
|
| 122 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 123 |
+
backdrop-filter: blur(5px);
|
| 124 |
+
color: #e0e0e0;
|
|
|
|
| 125 |
}
|
| 126 |
+
.user-bubble { border-left: 5px solid #ff00cc; background: rgba(255, 0, 204, 0.08); }
|
| 127 |
</style>
|
| 128 |
""", unsafe_allow_html=True)
|
| 129 |
|
|
|
|
| 165 |
save_chats(st.session_state.chats); st.session_state.edit_mode = None; st.session_state.current_chat = new_n; st.rerun()
|
| 166 |
|
| 167 |
# --- ЭКРАН ---
|
| 168 |
+
# Заголовок теперь ВНИЗУ списка (так как контейнер перевернут, он окажется сверху)
|
| 169 |
st.markdown('<p class="main-title">HiperDouble AI</p>', unsafe_allow_html=True)
|
| 170 |
|
| 171 |
if st.session_state.current_chat in st.session_state.chats:
|
| 172 |
messages = st.session_state.chats[st.session_state.current_chat]
|
| 173 |
+
# ВАЖНО: Мы НЕ используем reversed(), так как column-reverse сделает это за нас!
|
| 174 |
+
for m in messages:
|
| 175 |
r_name, r_class = ("Вы", "user-bubble") if m['role'] == 'user' else ("HiperAi", "")
|
| 176 |
st.markdown(f"<div class='chat-bubble {r_class}'><b>{r_name}:</b><br>{m['content']}</div>", unsafe_allow_html=True)
|
|
|
|
|
|
|
| 177 |
|
| 178 |
# ПОЛЕ ВВОДА
|
| 179 |
u_input = st.chat_input(T['in'])
|