Update app.py
Browse files
app.py
CHANGED
@@ -170,191 +170,202 @@ def init_page_config():
|
|
170 |
|
171 |
def apply_custom_css():
|
172 |
"""
|
173 |
-
Aplica estilos CSS
|
174 |
-
|
175 |
"""
|
176 |
st.markdown("""
|
177 |
<style>
|
178 |
-
/*
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
--background-light: #1F2937; /* Fundo secundário */
|
184 |
-
--text-primary: #F9FAFB; /* Texto principal */
|
185 |
-
--text-secondary: #D1D5DB; /* Texto secundário */
|
186 |
-
--accent-color: #818CF8; /* Cor de destaque */
|
187 |
-
--error-color: #EF4444; /* Vermelho para erros */
|
188 |
-
--success-color: #10B981; /* Verde para sucesso */
|
189 |
}
|
190 |
|
191 |
-
/*
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
195 |
}
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
-webkit-background-clip: text;
|
201 |
-
-webkit-text-fill-color: transparent;
|
202 |
-
font-size: 2.5em;
|
203 |
-
font-weight: 800;
|
204 |
-
margin-bottom: 1.5rem;
|
205 |
-
padding: 0.5rem 0;
|
206 |
}
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
|
213 |
-
|
|
|
|
|
|
|
|
|
214 |
.chat-message {
|
215 |
-
padding: 1.
|
216 |
-
border-radius: 0.
|
217 |
margin-bottom: 1rem;
|
218 |
-
|
219 |
-
|
220 |
-
background-color:
|
221 |
}
|
222 |
|
223 |
-
/* Mensagens do usuário vs assistente */
|
224 |
.user-message {
|
225 |
-
|
226 |
-
border-left: 4px solid var(--primary-color);
|
227 |
}
|
228 |
|
229 |
.assistant-message {
|
230 |
-
|
231 |
-
border-left: 4px solid var(--secondary-color);
|
232 |
}
|
233 |
|
234 |
-
/* Cabeçalho das mensagens */
|
235 |
.chat-header {
|
|
|
236 |
font-weight: 600;
|
237 |
-
|
238 |
-
|
239 |
-
font-size: 1.1em;
|
240 |
}
|
241 |
|
242 |
-
/* Conteúdo das mensagens */
|
243 |
.chat-content {
|
244 |
-
color:
|
245 |
-
line-height: 1.
|
246 |
-
|
247 |
}
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
padding
|
253 |
-
border-
|
254 |
-
|
255 |
-
|
256 |
}
|
257 |
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
border-radius: 8px;
|
264 |
-
padding: 0.5rem 1.5rem;
|
265 |
-
font-weight: 600;
|
266 |
-
transition: all 0.3s ease;
|
267 |
-
}
|
268 |
-
|
269 |
-
.stButton > button:hover {
|
270 |
-
opacity: 0.9;
|
271 |
-
transform: translateY(-1px);
|
272 |
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
273 |
}
|
274 |
|
275 |
-
/*
|
276 |
.stTextInput > div > div > input {
|
277 |
-
background-color:
|
278 |
-
color:
|
279 |
-
border: 1px solid
|
280 |
-
border-radius: 8px;
|
281 |
-
padding: 0.75rem;
|
282 |
-
transition: all 0.3s ease;
|
283 |
}
|
284 |
|
285 |
.stTextInput > div > div > input:focus {
|
286 |
-
border-color:
|
287 |
-
box-shadow: 0 0 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
}
|
289 |
|
290 |
-
/*
|
291 |
.stUploadedFileData {
|
292 |
-
background-color:
|
293 |
-
color:
|
294 |
-
|
295 |
-
|
296 |
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
297 |
}
|
298 |
|
299 |
-
/*
|
300 |
.stProgress > div > div > div > div {
|
301 |
-
background
|
302 |
}
|
303 |
|
304 |
-
/*
|
305 |
.stAlert {
|
306 |
-
background-color:
|
307 |
-
color:
|
308 |
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
309 |
-
border-radius: 8px;
|
310 |
padding: 1rem;
|
|
|
311 |
}
|
312 |
|
313 |
-
/* Info icon
|
314 |
.stTooltipIcon {
|
315 |
-
color:
|
316 |
}
|
317 |
|
318 |
-
/*
|
319 |
-
|
320 |
-
color:
|
321 |
-
|
322 |
-
|
|
|
|
|
323 |
}
|
324 |
|
325 |
-
|
326 |
-
|
327 |
-
|
|
|
328 |
}
|
329 |
|
330 |
-
/*
|
331 |
-
.
|
332 |
-
color:
|
333 |
-
font-size: 0.9em;
|
334 |
-
margin-top: 1rem;
|
335 |
-
padding-top: 0.75rem;
|
336 |
-
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
337 |
}
|
338 |
|
339 |
-
|
340 |
-
|
341 |
-
display: none;
|
342 |
}
|
343 |
|
344 |
-
|
345 |
-
|
346 |
-
line-height: 1.6;
|
347 |
}
|
348 |
|
349 |
-
/*
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
|
|
|
|
|
355 |
.chat-message {
|
356 |
padding: 1rem;
|
357 |
}
|
|
|
|
|
|
|
|
|
358 |
}
|
359 |
</style>
|
360 |
""", unsafe_allow_html=True)
|
@@ -611,8 +622,10 @@ def main():
|
|
611 |
apply_custom_css()
|
612 |
create_sidebar()
|
613 |
|
614 |
-
# Título principal
|
615 |
-
st.markdown(
|
|
|
|
|
616 |
|
617 |
# Campos de API em duas colunas
|
618 |
col1, col2 = st.columns(2)
|
|
|
170 |
|
171 |
def apply_custom_css():
|
172 |
"""
|
173 |
+
Aplica estilos CSS personalizados à interface.
|
174 |
+
Compatível com Streamlit e HuggingFace.
|
175 |
"""
|
176 |
st.markdown("""
|
177 |
<style>
|
178 |
+
/* Base */
|
179 |
+
.stApp {
|
180 |
+
max-width: 100%;
|
181 |
+
padding-top: 2rem;
|
182 |
+
background-color: #0e1117;
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
}
|
184 |
|
185 |
+
/* Headers */
|
186 |
+
h1 {
|
187 |
+
color: #ff8c00 !important;
|
188 |
+
font-size: 32px !important;
|
189 |
+
font-weight: 600 !important;
|
190 |
+
padding: 0.5rem 0 !important;
|
191 |
}
|
192 |
|
193 |
+
h2, h3 {
|
194 |
+
color: #fafafa !important;
|
195 |
+
padding: 0.5rem 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
197 |
|
198 |
+
/* Text and Links */
|
199 |
+
p, li {
|
200 |
+
color: #fafafa;
|
201 |
+
}
|
202 |
+
|
203 |
+
a {
|
204 |
+
color: #4c8bf5 !important;
|
205 |
+
text-decoration: none;
|
206 |
}
|
207 |
|
208 |
+
a:hover {
|
209 |
+
text-decoration: underline;
|
210 |
+
}
|
211 |
+
|
212 |
+
/* Chat Messages */
|
213 |
.chat-message {
|
214 |
+
padding: 1.5rem;
|
215 |
+
border-radius: 0.5rem;
|
216 |
margin-bottom: 1rem;
|
217 |
+
display: flex;
|
218 |
+
flex-direction: column;
|
219 |
+
background-color: #1a1c23;
|
220 |
}
|
221 |
|
|
|
222 |
.user-message {
|
223 |
+
border-left: 4px solid #4c8bf5;
|
|
|
224 |
}
|
225 |
|
226 |
.assistant-message {
|
227 |
+
border-left: 4px solid #00cc89;
|
|
|
228 |
}
|
229 |
|
|
|
230 |
.chat-header {
|
231 |
+
color: #fafafa;
|
232 |
font-weight: 600;
|
233 |
+
margin-bottom: 0.5rem;
|
234 |
+
font-size: 1rem;
|
|
|
235 |
}
|
236 |
|
|
|
237 |
.chat-content {
|
238 |
+
color: #fafafa;
|
239 |
+
line-height: 1.5;
|
240 |
+
margin-left: 0.5rem;
|
241 |
}
|
242 |
|
243 |
+
/* Code Blocks */
|
244 |
+
code {
|
245 |
+
background-color: #262730;
|
246 |
+
padding: 0.2em 0.4em;
|
247 |
+
border-radius: 3px;
|
248 |
+
font-size: 85%;
|
249 |
+
color: #ff8c00;
|
250 |
}
|
251 |
|
252 |
+
pre {
|
253 |
+
background-color: #262730;
|
254 |
+
padding: 1rem;
|
255 |
+
border-radius: 5px;
|
256 |
+
overflow-x: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
|
259 |
+
/* Input Elements */
|
260 |
.stTextInput > div > div > input {
|
261 |
+
background-color: #262730;
|
262 |
+
color: #fafafa;
|
263 |
+
border: 1px solid #4c4c4c;
|
|
|
|
|
|
|
264 |
}
|
265 |
|
266 |
.stTextInput > div > div > input:focus {
|
267 |
+
border-color: #4c8bf5;
|
268 |
+
box-shadow: 0 0 0 1px #4c8bf5;
|
269 |
+
}
|
270 |
+
|
271 |
+
/* Buttons */
|
272 |
+
.stButton > button {
|
273 |
+
background-color: #262730;
|
274 |
+
color: #4c8bf5;
|
275 |
+
border: 1px solid #4c8bf5;
|
276 |
+
padding: 0.5rem 1rem;
|
277 |
+
border-radius: 0.5rem;
|
278 |
+
font-weight: 600;
|
279 |
+
transition: all 0.2s ease;
|
280 |
+
}
|
281 |
+
|
282 |
+
.stButton > button:hover {
|
283 |
+
background-color: #4c8bf5;
|
284 |
+
color: #ffffff;
|
285 |
}
|
286 |
|
287 |
+
/* File Uploader */
|
288 |
.stUploadedFileData {
|
289 |
+
background-color: #262730 !important;
|
290 |
+
color: #fafafa !important;
|
291 |
+
padding: 1rem !important;
|
292 |
+
border-radius: 0.5rem !important;
|
|
|
293 |
}
|
294 |
|
295 |
+
/* Progress Bar */
|
296 |
.stProgress > div > div > div > div {
|
297 |
+
background-color: #4c8bf5;
|
298 |
}
|
299 |
|
300 |
+
/* Alerts and Messages */
|
301 |
.stAlert {
|
302 |
+
background-color: #262730;
|
303 |
+
color: #fafafa;
|
|
|
|
|
304 |
padding: 1rem;
|
305 |
+
border-radius: 0.5rem;
|
306 |
}
|
307 |
|
308 |
+
/* Info icon */
|
309 |
.stTooltipIcon {
|
310 |
+
color: #4c8bf5 !important;
|
311 |
}
|
312 |
|
313 |
+
/* Token Information */
|
314 |
+
.token-info {
|
315 |
+
color: #808080;
|
316 |
+
font-size: 0.9rem;
|
317 |
+
margin-top: 0.5rem;
|
318 |
+
padding-top: 0.5rem;
|
319 |
+
border-top: 1px solid #4c4c4c;
|
320 |
}
|
321 |
|
322 |
+
/* Hide elements */
|
323 |
+
div[data-testid="stToolbar"],
|
324 |
+
.stDeployButton {
|
325 |
+
display: none;
|
326 |
}
|
327 |
|
328 |
+
/* Success/Warning/Error Colors */
|
329 |
+
.success {
|
330 |
+
color: #00cc89;
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
|
333 |
+
.warning {
|
334 |
+
color: #ff8c00;
|
|
|
335 |
}
|
336 |
|
337 |
+
.error {
|
338 |
+
color: #ff4c4c;
|
|
|
339 |
}
|
340 |
|
341 |
+
/* Scrollbars */
|
342 |
+
::-webkit-scrollbar {
|
343 |
+
width: 8px;
|
344 |
+
height: 8px;
|
345 |
+
}
|
346 |
+
|
347 |
+
::-webkit-scrollbar-track {
|
348 |
+
background: #1a1c23;
|
349 |
+
}
|
350 |
+
|
351 |
+
::-webkit-scrollbar-thumb {
|
352 |
+
background: #4c4c4c;
|
353 |
+
border-radius: 4px;
|
354 |
+
}
|
355 |
+
|
356 |
+
::-webkit-scrollbar-thumb:hover {
|
357 |
+
background: #666666;
|
358 |
+
}
|
359 |
|
360 |
+
/* Mobile Responsiveness */
|
361 |
+
@media (max-width: 768px) {
|
362 |
.chat-message {
|
363 |
padding: 1rem;
|
364 |
}
|
365 |
+
|
366 |
+
h1 {
|
367 |
+
font-size: 24px !important;
|
368 |
+
}
|
369 |
}
|
370 |
</style>
|
371 |
""", unsafe_allow_html=True)
|
|
|
622 |
apply_custom_css()
|
623 |
create_sidebar()
|
624 |
|
625 |
+
# Título principal - Nova implementação
|
626 |
+
st.markdown("""
|
627 |
+
# 📚 Chatbot com modelo de IA especializado em Português do Brasil - entrevista PDFs
|
628 |
+
""")
|
629 |
|
630 |
# Campos de API em duas colunas
|
631 |
col1, col2 = st.columns(2)
|