Spaces:
Sleeping
Sleeping
Vedika commited on
Update index.html
Browse files- index.html +27 -15
index.html
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
<!DOCTYPE html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
|
@@ -118,7 +116,7 @@
|
|
| 118 |
.main-area { flex: 1; display: flex; flex-direction: column; position: relative; transition: 0.3s; height: 100%; overflow: hidden; }
|
| 119 |
|
| 120 |
.chat-container {
|
| 121 |
-
flex: 1; overflow-y: auto; padding: 60px 20px 180px;
|
| 122 |
display: flex; flex-direction: column; align-items: center;
|
| 123 |
scroll-behavior: smooth;
|
| 124 |
}
|
|
@@ -148,7 +146,7 @@
|
|
| 148 |
word-wrap: break-word; overflow-wrap: break-word;
|
| 149 |
}
|
| 150 |
|
| 151 |
-
/* ---------- BUG FIX: VERTICAL TEXT ---------- */
|
| 152 |
.bot-message {
|
| 153 |
align-self: flex-start;
|
| 154 |
max-width: 100%;
|
|
@@ -172,8 +170,9 @@
|
|
| 172 |
|
| 173 |
.bot-content-wrapper {
|
| 174 |
flex: 1 1 0%;
|
| 175 |
-
min-width: 0;
|
| 176 |
width: 100%;
|
|
|
|
| 177 |
}
|
| 178 |
|
| 179 |
.bot-content {
|
|
@@ -181,27 +180,30 @@
|
|
| 181 |
line-height: 1.7;
|
| 182 |
color: var(--text-primary);
|
| 183 |
word-wrap: break-word;
|
| 184 |
-
overflow-wrap:
|
| 185 |
-
word-break:
|
| 186 |
-
white-space: normal;
|
|
|
|
|
|
|
| 187 |
}
|
| 188 |
|
|
|
|
| 189 |
.bot-content p { margin-bottom: 16px; }
|
| 190 |
.bot-content p:last-child { margin-bottom: 0; }
|
| 191 |
.bot-content strong { font-weight: 600; color: #000; }
|
| 192 |
-
.bot-content code { font-family: var(--font-code); background: rgba(31,31,31,0.05); padding: 3px 6px; border-radius: 6px; font-size: 0.9em; color: #0284c7; }
|
| 193 |
|
| 194 |
.bot-content pre {
|
| 195 |
background: #0d1117; padding: 40px 16px 16px; border-radius: var(--radius-md);
|
| 196 |
overflow-x: auto; margin: 16px 0; box-shadow: 0 4px 16px rgba(0,0,0,0.1);
|
| 197 |
-
position: relative; white-space: pre;
|
| 198 |
}
|
| 199 |
.bot-content pre::before {
|
| 200 |
content: ''; position: absolute; top: 14px; left: 16px;
|
| 201 |
width: 12px; height: 12px; border-radius: 50%;
|
| 202 |
background: #ff5f56; box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
|
| 203 |
}
|
| 204 |
-
.bot-content pre code { background: none; padding: 0; color: #e2e8f0; font-size: 13.5px; text-shadow: none; white-space: pre;}
|
| 205 |
|
| 206 |
.chat-attachment-container { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
|
| 207 |
.chat-file-pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.8); backdrop-filter: blur(8px); border: 1px solid var(--border-light); padding: 8px 14px; border-radius: var(--radius-lg); font-size: 13px; font-weight: 500; box-shadow: 0 2px 6px rgba(0,0,0,0.03); }
|
|
@@ -860,7 +862,7 @@
|
|
| 860 |
TTSManager.autoPrepare(msgId, msg.content, botObj.listenBtn);
|
| 861 |
}
|
| 862 |
}
|
| 863 |
-
setTimeout(UI.scrollToBottom, 200);
|
| 864 |
if(window.innerWidth <= 900) UI.toggleSidebar();
|
| 865 |
}
|
| 866 |
} catch(e) {}
|
|
@@ -1098,17 +1100,27 @@
|
|
| 1098 |
signal: State.abortController.signal
|
| 1099 |
});
|
| 1100 |
if(!res.ok) throw new Error("API Offline");
|
|
|
|
| 1101 |
const reader = res.body.getReader(), decoder = new TextDecoder();
|
|
|
|
|
|
|
| 1102 |
while(true) {
|
| 1103 |
const {done, value} = await reader.read();
|
| 1104 |
if(done) break;
|
| 1105 |
-
|
| 1106 |
-
const lines =
|
|
|
|
|
|
|
| 1107 |
for(let line of lines) {
|
| 1108 |
if(line.startsWith('data: ')) {
|
| 1109 |
const dataStr = line.substring(6).trim();
|
| 1110 |
if(dataStr === '[DONE]') continue;
|
| 1111 |
-
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1112 |
catch(e) {}
|
| 1113 |
Chat.parseAndRender(fullText, false, true, botObj.contentDiv);
|
| 1114 |
UI.scrollToBottom();
|
|
|
|
|
|
|
|
|
|
| 1 |
<html lang="en">
|
| 2 |
<head>
|
| 3 |
<meta charset="UTF-8">
|
|
|
|
| 116 |
.main-area { flex: 1; display: flex; flex-direction: column; position: relative; transition: 0.3s; height: 100%; overflow: hidden; }
|
| 117 |
|
| 118 |
.chat-container {
|
| 119 |
+
flex: 1; overflow-x: hidden; overflow-y: auto; padding: 60px 20px 180px;
|
| 120 |
display: flex; flex-direction: column; align-items: center;
|
| 121 |
scroll-behavior: smooth;
|
| 122 |
}
|
|
|
|
| 146 |
word-wrap: break-word; overflow-wrap: break-word;
|
| 147 |
}
|
| 148 |
|
| 149 |
+
/* ---------- CRITICAL BUG FIX: VERTICAL TEXT ---------- */
|
| 150 |
.bot-message {
|
| 151 |
align-self: flex-start;
|
| 152 |
max-width: 100%;
|
|
|
|
| 170 |
|
| 171 |
.bot-content-wrapper {
|
| 172 |
flex: 1 1 0%;
|
| 173 |
+
min-width: 0; /* Prevents flexbox shrinking issues */
|
| 174 |
width: 100%;
|
| 175 |
+
overflow: hidden; /* Contains any overflowing elements */
|
| 176 |
}
|
| 177 |
|
| 178 |
.bot-content {
|
|
|
|
| 180 |
line-height: 1.7;
|
| 181 |
color: var(--text-primary);
|
| 182 |
word-wrap: break-word;
|
| 183 |
+
overflow-wrap: break-word;
|
| 184 |
+
word-break: break-word;
|
| 185 |
+
white-space: normal; /* CRITICAL: Using 'normal' instead of 'pre-wrap' prevents ladder effect */
|
| 186 |
+
width: 100%;
|
| 187 |
+
max-width: 100%;
|
| 188 |
}
|
| 189 |
|
| 190 |
+
.bot-content * { max-width: 100%; }
|
| 191 |
.bot-content p { margin-bottom: 16px; }
|
| 192 |
.bot-content p:last-child { margin-bottom: 0; }
|
| 193 |
.bot-content strong { font-weight: 600; color: #000; }
|
| 194 |
+
.bot-content code { font-family: var(--font-code); background: rgba(31,31,31,0.05); padding: 3px 6px; border-radius: 6px; font-size: 0.9em; color: #0284c7; white-space: pre-wrap; word-break: break-word; }
|
| 195 |
|
| 196 |
.bot-content pre {
|
| 197 |
background: #0d1117; padding: 40px 16px 16px; border-radius: var(--radius-md);
|
| 198 |
overflow-x: auto; margin: 16px 0; box-shadow: 0 4px 16px rgba(0,0,0,0.1);
|
| 199 |
+
position: relative; white-space: pre-wrap; word-break: break-word;
|
| 200 |
}
|
| 201 |
.bot-content pre::before {
|
| 202 |
content: ''; position: absolute; top: 14px; left: 16px;
|
| 203 |
width: 12px; height: 12px; border-radius: 50%;
|
| 204 |
background: #ff5f56; box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
|
| 205 |
}
|
| 206 |
+
.bot-content pre code { background: none; padding: 0; color: #e2e8f0; font-size: 13.5px; text-shadow: none; white-space: pre-wrap; }
|
| 207 |
|
| 208 |
.chat-attachment-container { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
|
| 209 |
.chat-file-pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.8); backdrop-filter: blur(8px); border: 1px solid var(--border-light); padding: 8px 14px; border-radius: var(--radius-lg); font-size: 13px; font-weight: 500; box-shadow: 0 2px 6px rgba(0,0,0,0.03); }
|
|
|
|
| 862 |
TTSManager.autoPrepare(msgId, msg.content, botObj.listenBtn);
|
| 863 |
}
|
| 864 |
}
|
| 865 |
+
setTimeout(() => UI.scrollToBottom(true), 200);
|
| 866 |
if(window.innerWidth <= 900) UI.toggleSidebar();
|
| 867 |
}
|
| 868 |
} catch(e) {}
|
|
|
|
| 1100 |
signal: State.abortController.signal
|
| 1101 |
});
|
| 1102 |
if(!res.ok) throw new Error("API Offline");
|
| 1103 |
+
|
| 1104 |
const reader = res.body.getReader(), decoder = new TextDecoder();
|
| 1105 |
+
let buffer = '';
|
| 1106 |
+
|
| 1107 |
while(true) {
|
| 1108 |
const {done, value} = await reader.read();
|
| 1109 |
if(done) break;
|
| 1110 |
+
buffer += decoder.decode(value, {stream: true});
|
| 1111 |
+
const lines = buffer.split('\n');
|
| 1112 |
+
buffer = lines.pop(); // Keep incomplete lines in the buffer
|
| 1113 |
+
|
| 1114 |
for(let line of lines) {
|
| 1115 |
if(line.startsWith('data: ')) {
|
| 1116 |
const dataStr = line.substring(6).trim();
|
| 1117 |
if(dataStr === '[DONE]') continue;
|
| 1118 |
+
try {
|
| 1119 |
+
const json = JSON.parse(dataStr);
|
| 1120 |
+
if(json.choices && json.choices[0].delta.content) {
|
| 1121 |
+
fullText += json.choices[0].delta.content;
|
| 1122 |
+
}
|
| 1123 |
+
}
|
| 1124 |
catch(e) {}
|
| 1125 |
Chat.parseAndRender(fullText, false, true, botObj.contentDiv);
|
| 1126 |
UI.scrollToBottom();
|