Spaces:
Running
Running
Commit ·
eeb49e0
1
Parent(s): 5a3f2f9
Tighter intro bubble + Clear restores default
Browse filesIntro: moved out of static HTML into a JS constant rendered via the
same addMessage path used for all other bubbles. Source-HTML whitespace
between <div class="bubble"> and <p> was being preserved by the
bubble's white-space:pre-wrap and showing as extra vertical padding;
JS rendering produces clean markup without that.
Clear button: re-renders the intro message instead of writing
'Conversation cleared. How can I help next?'.
- app.js +11 -5
- index.html +1 -8
app.js
CHANGED
|
@@ -32,6 +32,10 @@ const SYSTEM_PROMPT =
|
|
| 32 |
"Be concise, accurate, and well-structured. If a question is outside your knowledge, say so. " +
|
| 33 |
"When the user asks about medical, legal, or financial topics, remind them once that you are not a substitute for a qualified professional, then answer the question helpfully.";
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
// Default generation parameters. Mirrored by the UI sliders and persisted to
|
| 36 |
// localStorage. Each entry: [defaultValue, decimalsForDisplay].
|
| 37 |
const PARAM_DEFAULTS = {
|
|
@@ -660,15 +664,16 @@ document.addEventListener("drop", (e) => {
|
|
| 660 |
if (e.dataTransfer?.files?.length) handleFiles(e.dataTransfer.files);
|
| 661 |
});
|
| 662 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 663 |
clearBtn.addEventListener("click", () => {
|
| 664 |
state.history = [{ role: "system", content: SYSTEM_PROMPT }];
|
| 665 |
state.attachments = [];
|
| 666 |
renderAttachments();
|
| 667 |
-
|
| 668 |
-
addMessage(
|
| 669 |
-
"assistant",
|
| 670 |
-
"Conversation cleared. How can I help next?",
|
| 671 |
-
);
|
| 672 |
});
|
| 673 |
|
| 674 |
bannerCloseBtn.addEventListener("click", () => {
|
|
@@ -679,6 +684,7 @@ bannerCloseBtn.addEventListener("click", () => {
|
|
| 679 |
detectDevice().then((d) => (backendEl.textContent = d.toUpperCase()));
|
| 680 |
autoResize();
|
| 681 |
initParamUI();
|
|
|
|
| 682 |
|
| 683 |
// If we've successfully loaded this same model before in this browser, the
|
| 684 |
// weights are already in the HTTP cache — surface a one-tap resume so the
|
|
|
|
| 32 |
"Be concise, accurate, and well-structured. If a question is outside your knowledge, say so. " +
|
| 33 |
"When the user asks about medical, legal, or financial topics, remind them once that you are not a substitute for a qualified professional, then answer the question helpfully.";
|
| 34 |
|
| 35 |
+
// Shown in the chat at boot and again every time the user clicks Clear.
|
| 36 |
+
const INTRO_MESSAGE =
|
| 37 |
+
"Hi — I'm an AI assistant running entirely in your browser. Ask a question, paste notes, or attach a document and tell me what to do with it.";
|
| 38 |
+
|
| 39 |
// Default generation parameters. Mirrored by the UI sliders and persisted to
|
| 40 |
// localStorage. Each entry: [defaultValue, decimalsForDisplay].
|
| 41 |
const PARAM_DEFAULTS = {
|
|
|
|
| 664 |
if (e.dataTransfer?.files?.length) handleFiles(e.dataTransfer.files);
|
| 665 |
});
|
| 666 |
|
| 667 |
+
function renderIntro() {
|
| 668 |
+
chat.innerHTML = "";
|
| 669 |
+
addMessage("assistant", INTRO_MESSAGE);
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
clearBtn.addEventListener("click", () => {
|
| 673 |
state.history = [{ role: "system", content: SYSTEM_PROMPT }];
|
| 674 |
state.attachments = [];
|
| 675 |
renderAttachments();
|
| 676 |
+
renderIntro();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
});
|
| 678 |
|
| 679 |
bannerCloseBtn.addEventListener("click", () => {
|
|
|
|
| 684 |
detectDevice().then((d) => (backendEl.textContent = d.toUpperCase()));
|
| 685 |
autoResize();
|
| 686 |
initParamUI();
|
| 687 |
+
renderIntro();
|
| 688 |
|
| 689 |
// If we've successfully loaded this same model before in this browser, the
|
| 690 |
// weights are already in the HTTP cache — surface a one-tap resume so the
|
index.html
CHANGED
|
@@ -45,14 +45,7 @@
|
|
| 45 |
</div>
|
| 46 |
</div>
|
| 47 |
|
| 48 |
-
<div class="chat" id="chat" aria-live="polite">
|
| 49 |
-
<div class="msg assistant">
|
| 50 |
-
<div class="avatar">AI</div>
|
| 51 |
-
<div class="bubble">
|
| 52 |
-
<p>Hi — I'm an AI assistant running entirely in your browser. Ask a question, paste notes, or attach a document and tell me what to do with it.</p>
|
| 53 |
-
</div>
|
| 54 |
-
</div>
|
| 55 |
-
</div>
|
| 56 |
|
| 57 |
<div class="attachments" id="attachments" hidden></div>
|
| 58 |
|
|
|
|
| 45 |
</div>
|
| 46 |
</div>
|
| 47 |
|
| 48 |
+
<div class="chat" id="chat" aria-live="polite"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
<div class="attachments" id="attachments" hidden></div>
|
| 51 |
|