Abobasnik commited on
Commit
08f0468
·
verified ·
1 Parent(s): 3820cc5

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +49 -21
src/streamlit_app.py CHANGED
@@ -34,11 +34,15 @@ if "code" in st.query_params and not st.session_state.user_email:
34
  cookies.save(); st.rerun()
35
  except: pass
36
 
 
37
  def logout():
 
 
 
 
38
  st.session_state.user_email = None
39
  st.session_state.user_name = "Пользователь"
40
- cookies["saved_email"], cookies["saved_name"] = None, None
41
- cookies.save(); st.rerun()
42
 
43
  def load_chats():
44
  u_id = st.session_state.user_email.replace('@','_').replace('.','_') if st.session_state.user_email else 'guest'
@@ -64,7 +68,7 @@ MODELS_CONFIG = {
64
  "✨ HiperAI v1.1.3 (Stable)": {"engine": "openai", "model": "gpt-4o-mini", "identity": "HiperAI v1.1.3."},
65
  }
66
 
67
- # --- UI И CSS ---
68
  st.set_page_config(page_title="HiperDouble AI", page_icon="🧬", layout="wide")
69
 
70
  if "chats" not in st.session_state: st.session_state.chats = load_chats()
@@ -74,13 +78,13 @@ if "edit_mode" not in st.session_state: st.session_state.edit_mode = None
74
 
75
  st.markdown("""
76
  <style>
 
77
  html, body, [data-testid="stAppViewContainer"] {
78
- background: #020205;
79
- background-image: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('https://w.wallhaven.cc/full/85/wallhaven-85m76y.png');
80
- background-size: cover;
81
  background-attachment: fixed;
82
  }
83
 
 
84
  .main-title {
85
  font-size: clamp(2.3rem, 8vw, 4rem);
86
  font-weight: 900;
@@ -91,33 +95,59 @@ st.markdown("""
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
- padding-bottom: 400px !important;
100
  }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  [data-testid="stBottom"] {
103
  position: fixed !important;
104
  bottom: 0px !important;
105
- background: #05050a !important;
 
106
  z-index: 100 !important;
107
  padding: 15px 5% 45px 5% !important;
108
- border-top: 1px solid rgba(255,255,255,0.1);
109
  }
110
 
111
- [data-testid="stSidebar"] { z-index: 999999 !important; background-color: #080810 !important; }
 
 
 
 
112
 
113
- .chat-bubble {
114
- padding: 15px 20px;
115
- border-radius: 18px;
116
- margin-bottom: 15px;
117
- background: rgba(255,255,255,0.08);
118
- border: 1px solid rgba(255,255,255,0.1);
 
 
 
119
  }
120
- .user-bubble { border-left: 5px solid #ff00cc; background: rgba(255, 0, 204, 0.04); }
121
  </style>
122
  """, unsafe_allow_html=True)
123
 
@@ -163,13 +193,11 @@ st.markdown('<p class="main-title">HiperDouble AI</p>', unsafe_allow_html=True)
163
 
164
  if st.session_state.current_chat in st.session_state.chats:
165
  messages = st.session_state.chats[st.session_state.current_chat]
166
- # Сообщения в обратном порядке (новые сверху)
167
  for m in reversed(messages):
168
  r_name, r_class = ("Вы", "user-bubble") if m['role'] == 'user' else ("HiperAi", "")
169
  st.markdown(f"<div class='chat-bubble {r_class}'><b>{r_name}:</b><br>{m['content']}</div>", unsafe_allow_html=True)
170
 
171
- # ПУСТОЙ БЛОК-БУФЕР В САМОМ НИЗУ (под всеми сообщениями)
172
- st.markdown("<div style='height: 150px;'></div>", unsafe_allow_html=True)
173
 
174
  # ПОЛЕ ВВОДА
175
  u_input = st.chat_input(T['in'])
 
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 = "Пользователь"
45
+ st.rerun()
 
46
 
47
  def load_chats():
48
  u_id = st.session_state.user_email.replace('@','_').replace('.','_') if st.session_state.user_email else 'guest'
 
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()
 
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
  -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
+ padding-bottom: 380px !important;
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.95) !important;
129
+ backdrop-filter: blur(10px);
130
  z-index: 100 !important;
131
  padding: 15px 5% 45px 5% !important;
132
+ border-top: 1px solid rgba(115, 103, 240, 0.3);
133
  }
134
 
135
+ /* SIDEBAR */
136
+ [data-testid="stSidebar"] {
137
+ background-color: #0a0a15 !important;
138
+ border-right: 1px solid rgba(255,255,255,0.05);
139
+ }
140
 
141
+ /* КНОПКИ */
142
+ .stButton>button {
143
+ border-radius: 10px !important;
144
+ transition: 0.3s !important;
145
+ }
146
+ .stButton>button:hover {
147
+ border-color: #7367f0 !important;
148
+ color: #7367f0 !important;
149
+ transform: translateY(-2px);
150
  }
 
151
  </style>
152
  """, unsafe_allow_html=True)
153
 
 
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
  for m in reversed(messages):
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'])