Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -142,19 +142,23 @@ HTML_TEMPLATE = """
|
|
| 142 |
}
|
| 143 |
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
|
| 144 |
|
| 145 |
-
body, html
|
| 146 |
-
margin: 0; padding: 0; height:
|
| 147 |
background: var(--bg); color: var(--text); font-family: 'Outfit', sans-serif;
|
| 148 |
overflow: hidden;
|
| 149 |
font-size: 17px;
|
| 150 |
-
-webkit-user-select: none;
|
| 151 |
}
|
| 152 |
|
| 153 |
-
textarea, input {
|
| 154 |
-
-webkit-user-select: text !important;
|
| 155 |
}
|
| 156 |
|
| 157 |
-
#app-container {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
header {
|
| 160 |
height: 70px; padding: 0 20px;
|
|
@@ -189,7 +193,6 @@ HTML_TEMPLATE = """
|
|
| 189 |
|
| 190 |
.history-label { color: var(--dim); font-size: 13px; font-weight: 600; margin-bottom: 10px; letter-spacing: 1px; text-transform: uppercase; }
|
| 191 |
|
| 192 |
-
/* --- UPDATED HISTORY STYLES --- */
|
| 193 |
#history-list {
|
| 194 |
flex: 1; overflow-y: auto; padding: 10px 0;
|
| 195 |
}
|
|
@@ -201,7 +204,6 @@ HTML_TEMPLATE = """
|
|
| 201 |
}
|
| 202 |
.history-item:last-child { margin-bottom: 0; }
|
| 203 |
.history-item:active { background: #222; color: #fff; border-color: #444; }
|
| 204 |
-
/* --------------------------- */
|
| 205 |
|
| 206 |
.h-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
|
| 207 |
.h-actions { display: none; gap: 15px; }
|
|
@@ -212,22 +214,53 @@ HTML_TEMPLATE = """
|
|
| 212 |
.brand-name { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 12px; color: var(--dim); letter-spacing: 2px; margin-bottom: 10px; opacity: 0.6; }
|
| 213 |
.logout-btn { color: #ef4444; cursor: pointer; font-size: 15px; font-weight: 600; padding: 10px; }
|
| 214 |
|
|
|
|
| 215 |
#chat-box {
|
| 216 |
-
flex: 1;
|
| 217 |
-
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
}
|
| 220 |
|
| 221 |
-
.msg {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
@keyframes fadeInstant { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
| 223 |
|
| 224 |
-
.user-msg {
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
|
| 229 |
-
.ai-msg {
|
| 230 |
-
.ai-content {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
.ai-content strong { color: #fff; font-weight: 700; }
|
| 232 |
.ai-content h1, .ai-content h2 { margin-top: 20px; color: #fff; font-weight: 700; }
|
| 233 |
|
|
@@ -376,7 +409,10 @@ HTML_TEMPLATE = """
|
|
| 376 |
|
| 377 |
function scrollToBottom() {
|
| 378 |
const box = document.getElementById('chat-box');
|
| 379 |
-
|
|
|
|
|
|
|
|
|
|
| 380 |
}
|
| 381 |
|
| 382 |
async function send() {
|
|
@@ -505,7 +541,10 @@ HTML_TEMPLATE = """
|
|
| 505 |
window.mermaid.init(undefined, element.querySelectorAll('.mermaid'));
|
| 506 |
}
|
| 507 |
element.style.opacity = 0; element.style.transition = 'opacity 0.4s';
|
| 508 |
-
setTimeout(() =>
|
|
|
|
|
|
|
|
|
|
| 509 |
}
|
| 510 |
|
| 511 |
function toggleSidebar() { document.getElementById('sidebar').classList.toggle('open'); }
|
|
@@ -536,6 +575,10 @@ HTML_TEMPLATE = """
|
|
| 536 |
box.scrollTop = box.scrollHeight;
|
| 537 |
}
|
| 538 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 539 |
checkLogin();
|
| 540 |
</script>
|
| 541 |
</body>
|
|
@@ -605,7 +648,6 @@ def chat():
|
|
| 605 |
save_db(user_db)
|
| 606 |
return jsonify({"response": reply, "new_title": new_title})
|
| 607 |
|
| 608 |
-
# --- MANIFEST FOR APP LOGO ---
|
| 609 |
@app.route('/manifest.json')
|
| 610 |
def manifest():
|
| 611 |
data = {
|
|
@@ -618,12 +660,12 @@ def manifest():
|
|
| 618 |
"theme_color": "#09090b",
|
| 619 |
"icons": [
|
| 620 |
{
|
| 621 |
-
"src": "https://
|
| 622 |
"sizes": "192x192",
|
| 623 |
"type": "image/png"
|
| 624 |
},
|
| 625 |
{
|
| 626 |
-
"src": "https://
|
| 627 |
"sizes": "512x512",
|
| 628 |
"type": "image/png"
|
| 629 |
}
|
|
@@ -633,3 +675,4 @@ def manifest():
|
|
| 633 |
|
| 634 |
if __name__ == '__main__':
|
| 635 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
|
|
| 142 |
}
|
| 143 |
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
|
| 144 |
|
| 145 |
+
body, html {
|
| 146 |
+
margin: 0; padding: 0; height: 100dvh; width: 100%;
|
| 147 |
background: var(--bg); color: var(--text); font-family: 'Outfit', sans-serif;
|
| 148 |
overflow: hidden;
|
| 149 |
font-size: 17px;
|
| 150 |
+
-webkit-user-select: none; user-select: none;
|
| 151 |
}
|
| 152 |
|
| 153 |
+
textarea, input, .user-content, .ai-content, code {
|
| 154 |
+
-webkit-user-select: text !important; user-select: text !important;
|
| 155 |
}
|
| 156 |
|
| 157 |
+
#app-container {
|
| 158 |
+
display: flex; flex-direction: column;
|
| 159 |
+
height: 100dvh; /* Critical Fix for Full Screen */
|
| 160 |
+
position: relative;
|
| 161 |
+
}
|
| 162 |
|
| 163 |
header {
|
| 164 |
height: 70px; padding: 0 20px;
|
|
|
|
| 193 |
|
| 194 |
.history-label { color: var(--dim); font-size: 13px; font-weight: 600; margin-bottom: 10px; letter-spacing: 1px; text-transform: uppercase; }
|
| 195 |
|
|
|
|
| 196 |
#history-list {
|
| 197 |
flex: 1; overflow-y: auto; padding: 10px 0;
|
| 198 |
}
|
|
|
|
| 204 |
}
|
| 205 |
.history-item:last-child { margin-bottom: 0; }
|
| 206 |
.history-item:active { background: #222; color: #fff; border-color: #444; }
|
|
|
|
| 207 |
|
| 208 |
.h-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
|
| 209 |
.h-actions { display: none; gap: 15px; }
|
|
|
|
| 214 |
.brand-name { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 12px; color: var(--dim); letter-spacing: 2px; margin-bottom: 10px; opacity: 0.6; }
|
| 215 |
.logout-btn { color: #ef4444; cursor: pointer; font-size: 15px; font-weight: 600; padding: 10px; }
|
| 216 |
|
| 217 |
+
/* --- CHAT BOX FIXES --- */
|
| 218 |
#chat-box {
|
| 219 |
+
flex: 1;
|
| 220 |
+
overflow-y: auto;
|
| 221 |
+
padding: 20px 5%;
|
| 222 |
+
padding-bottom: 120px; /* EXTRA SPACE FOR SCROLLING */
|
| 223 |
+
display: flex;
|
| 224 |
+
flex-direction: column;
|
| 225 |
+
gap: 25px;
|
| 226 |
+
-webkit-overflow-scrolling: touch;
|
| 227 |
+
overscroll-behavior-y: contain;
|
| 228 |
+
min-height: 0; /* Important for Flexbox scrolling */
|
| 229 |
}
|
| 230 |
|
| 231 |
+
.msg {
|
| 232 |
+
width: 100%;
|
| 233 |
+
line-height: 1.7;
|
| 234 |
+
font-size: 17px;
|
| 235 |
+
opacity: 0;
|
| 236 |
+
animation: fadeInstant 0.3s forwards;
|
| 237 |
+
/* REMOVED height: 100% to fix big box issue */
|
| 238 |
+
display: flex;
|
| 239 |
+
flex-direction: column;
|
| 240 |
+
}
|
| 241 |
@keyframes fadeInstant { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
| 242 |
|
| 243 |
+
.user-msg { align-items: flex-end; }
|
| 244 |
+
|
| 245 |
+
/* --- FIXED USER CONTENT BOX SIZE --- */
|
| 246 |
+
.user-content {
|
| 247 |
+
display: inline-block;
|
| 248 |
+
width: fit-content; /* THIS FIXES THE HUGE BOX */
|
| 249 |
+
max-width: 85%;
|
| 250 |
+
background: var(--user-msg);
|
| 251 |
+
padding: 10px 16px;
|
| 252 |
+
border-radius: 18px 18px 4px 18px;
|
| 253 |
+
text-align: left;
|
| 254 |
+
color: #fff;
|
| 255 |
+
word-wrap: break-word;
|
| 256 |
+
}
|
| 257 |
|
| 258 |
+
.ai-msg { align-items: flex-start; }
|
| 259 |
+
.ai-content {
|
| 260 |
+
width: 100%;
|
| 261 |
+
color: #d4d4d8;
|
| 262 |
+
word-wrap: break-word;
|
| 263 |
+
}
|
| 264 |
.ai-content strong { color: #fff; font-weight: 700; }
|
| 265 |
.ai-content h1, .ai-content h2 { margin-top: 20px; color: #fff; font-weight: 700; }
|
| 266 |
|
|
|
|
| 409 |
|
| 410 |
function scrollToBottom() {
|
| 411 |
const box = document.getElementById('chat-box');
|
| 412 |
+
// Timeout ensures scroll happens AFTER content renders
|
| 413 |
+
setTimeout(() => {
|
| 414 |
+
box.scrollTo({ top: box.scrollHeight, behavior: 'smooth' });
|
| 415 |
+
}, 100);
|
| 416 |
}
|
| 417 |
|
| 418 |
async function send() {
|
|
|
|
| 541 |
window.mermaid.init(undefined, element.querySelectorAll('.mermaid'));
|
| 542 |
}
|
| 543 |
element.style.opacity = 0; element.style.transition = 'opacity 0.4s';
|
| 544 |
+
setTimeout(() => {
|
| 545 |
+
element.style.opacity = 1;
|
| 546 |
+
scrollToBottom(); // Scroll fix after render
|
| 547 |
+
}, 50);
|
| 548 |
}
|
| 549 |
|
| 550 |
function toggleSidebar() { document.getElementById('sidebar').classList.toggle('open'); }
|
|
|
|
| 575 |
box.scrollTop = box.scrollHeight;
|
| 576 |
}
|
| 577 |
|
| 578 |
+
// --- MANIFEST FOR APP LOGO (Remember to replace link) ---
|
| 579 |
+
// Neenga upload panna logo link inga varanum
|
| 580 |
+
// Example: "src": "https://huggingface.co/..."
|
| 581 |
+
|
| 582 |
checkLogin();
|
| 583 |
</script>
|
| 584 |
</body>
|
|
|
|
| 648 |
save_db(user_db)
|
| 649 |
return jsonify({"response": reply, "new_title": new_title})
|
| 650 |
|
|
|
|
| 651 |
@app.route('/manifest.json')
|
| 652 |
def manifest():
|
| 653 |
data = {
|
|
|
|
| 660 |
"theme_color": "#09090b",
|
| 661 |
"icons": [
|
| 662 |
{
|
| 663 |
+
"src": "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
|
| 664 |
"sizes": "192x192",
|
| 665 |
"type": "image/png"
|
| 666 |
},
|
| 667 |
{
|
| 668 |
+
"src": "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
|
| 669 |
"sizes": "512x512",
|
| 670 |
"type": "image/png"
|
| 671 |
}
|
|
|
|
| 675 |
|
| 676 |
if __name__ == '__main__':
|
| 677 |
app.run(host='0.0.0.0', port=7860)
|
| 678 |
+
|