Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Improve small and touch screen experience
corebonts17c4c7a483cb
diff --git a/llamafile/server/www/chatbot.css b/llamafile/server/www/chatbot.cssindex 2a14197a..4715c0bd 100644--- a/llamafile/server/www/chatbot.css+++ b/llamafile/server/www/chatbot.css@@ -4,6 +4,12 @@box-sizing: border-box;}+html {+ --small-spacing: 0.5rem;+ --medium-spacing: 0.75rem;+ --large-spacing: 1.0rem;+}+html,body {height: 100%;@@ -19,7 +25,7 @@ body {flex-direction: column;align-items: center;justify-content: flex-start;- padding: 1rem;+ padding: var(--large-spacing);}p {@@ -38,7 +44,7 @@ p {}.chat-header {- padding: 1rem;+ padding: var(--large-spacing);background: #f8f9fa;border-bottom: 1px solid #e9ecef;border-radius: 12px 12px 0 0;@@ -60,7 +66,7 @@ p {.chat-messages {flex: 1;overflow-y: auto;- padding: 1rem;+ padding: var(--large-spacing);position: relative;}@@ -96,7 +102,7 @@ ul li:first-child {}.message {- padding: 0.75rem;+ padding: var(--medium-spacing);border-radius: 8px;word-wrap: break-word;background: var(--message-background);@@ -106,6 +112,7 @@ ul li:first-child {--message-background: #e9ecef;margin-left: auto;max-width: 80%;+ width: max-content;}.message-wrapper.assistant {@@ -171,15 +178,15 @@ ul li:first-child {}.chat-input-container {- padding: 1rem;+ padding: var(--large-spacing);border-top: 1px solid #e9ecef;display: flex;- gap: 0.5rem;+ gap: var(--small-spacing);}.chat-input {flex: 1;- padding: 0.75rem;+ padding: var(--medium-spacing);border: 1px solid #dee2e6;border-radius: 6px;font-size: 1rem;@@ -242,13 +249,16 @@ ul li:first-child {border-radius: 6px;cursor: pointer;transition: color 0.2s;+ box-sizing: content-box;+ min-width: 24px;+ min-height: 24px;}.chat-input-button-container {display: flex;flex-direction: column;align-self: flex-end;- gap: 0.5em;+ gap: var(--small-spacing);}.chat-input-button-container button img,@@ -260,32 +270,32 @@ ul li:first-child {.chat-input-button-row {display: flex;- gap: 0.5rem;+ gap: var(--small-spacing);}.chat-input-button-row button,.menu-trigger,-.completions-controls button {- padding: 0.5rem .5rem;+.completions-controls .settings-button {+ padding: var(--small-spacing);background: #9299a0;}.chat-input-button-row button:hover,.menu-trigger:hover,-.completions-controls button:hover {+.completions-controls settings-button:hover {background: #5c636a;}.send-button,button.complete-button {padding: 0.75rem 1.5rem;- background: #0d6efd;+ background-color: #0d6efd;font-size: 1rem;}.send-button:hover,button.complete-button:hover {- background: #0b5ed7;+ background-color: #0b5ed7;}.send-button:disabled,@@ -296,12 +306,12 @@ button.complete-button:disabled {.stop-button {padding: 0.75rem 1.5rem;- background: #dc3545;+ background-color: #dc3545;font-size: 1rem;}.stop-button:hover {- background: #bb2d3b;+ background-color: #bb2d3b;}.stop-button:disabled {@@ -341,8 +351,8 @@ button.complete-button:disabled {pre .copy-button {position: absolute;- top: 0.5rem;- right: 0.5rem;+ top: var(--small-spacing);+ right: var(--small-spacing);z-index: 1;}@@ -368,7 +378,10 @@ pre .copy-button {padding: 20px;border-radius: 8px;max-width: 500px;- width: 90%;+ width: calc(100% - var(--large-spacing));+ max-height: calc(100% - var(--large-spacing));+ display: flex;+ flex-direction: column;}.settings-header {@@ -378,6 +391,12 @@ pre .copy-button {margin-bottom: 20px;}+.settings-content {+ width: 100%;+ height: 100%;+ overflow: auto;+}+.settings-header button {background: none;border: none;@@ -503,13 +522,13 @@ pre .copy-button {flex: 1;display: flex;flex-direction: column;- padding: 1rem;+ padding: var(--large-spacing);}#completions-input {flex: 1;- padding: 1rem;- margin-bottom: 1rem;+ padding: var(--large-spacing);+ margin-bottom: var(--large-spacing);border: 1px solid #dee2e6;border-radius: 6px;font-size: 1rem;@@ -520,7 +539,7 @@ pre .copy-button {.completions-controls {display: flex;- gap: 0.5rem;+ gap: var(--small-spacing);}.mode-dropdown {@@ -686,3 +705,75 @@ pre .copy-button {vertical-align: middle;margin-left: 0.2rem;}++@media (max-width: 768px) {+ html {+ --large-spacing: 0.5rem;+ --medium-spacing: 0.45rem;+ --small-spacing: 0.4rem;+ }++ body {+ padding: 0;+ background: white;+ }++ .chat-container {+ border-radius: 0;+ box-shadow: none;+ height: 100%;+ }++ .chat-header h1 {+ font-size: 1rem;+ }++ .chat-header img.logo {+ width: calc(24px + 2* 0.25rem);+ height: calc(24px + 2* 0.25rem);+ }++ .message-wrapper.user {+ max-width: 90%;+ }++ .message-wrapper.assistant {+ max-width: 100%;+ }++ .chat-input {+ line-height: 1.25;+ }++ .chat-input-button-container {+ display: grid;+ grid-template-columns: 1fr 1fr;+ }++ .chat-input-button-row {+ display: contents;+ }++ .chat-input-container .send-button,+ .chat-input-container .stop-button {+ padding: 0.25rem;+ font-size: 0;+ color: transparent !important;+ background-size: 24px;+ background-position: center;+ background-repeat: no-repeat;+ }++ .chat-input-container .send-button {+ background-image: url('./send.svg');+ }++ .chat-input-container .stop-button {+ background-image: url('./stop.svg');+ }++ .completions-controls .complete-button,+ .completions-controls .stop-button {+ padding: var(--small-spacing) var(--large-spacing);+ }+}diff --git a/llamafile/server/www/chatbot.js b/llamafile/server/www/chatbot.jsindex d4427ecd..8bf390d2 100644--- a/llamafile/server/www/chatbot.js+++ b/llamafile/server/www/chatbot.js@@ -117,8 +117,10 @@ function createMessageElement(content) {}function scrollToBottom() {- if (!disableAutoScroll)- document.getElementById("bottom").scrollIntoView({behavior: "instant"});+ if (!disableAutoScroll) {+ document.getElementById("bottom").scrollIntoView({ behavior: "instant" });+ chatMessages.scrollTop = chatMessages.scrollHeight;+ }}function onChatInput() {@@ -140,7 +142,7 @@ function cleanupAfterMessage() {}function onWheel(e) {- if (e.deltaY < 0)+ if (e.deltaY == undefined || e.deltaY < 0)disableAutoScroll = true;}@@ -507,7 +509,7 @@ function updateModelInfo() {document.getElementById("model-completions").textContent = modelName;}if (!flagz.nologo) {- document.getElementById("logo").style.display = "inline-block";+ document.querySelectorAll(".logo").forEach(logo => logo.style.display = "inline-block");}}@@ -816,6 +818,7 @@ async function chatbot() {redoButton.addEventListener("click", onRedo);chatInput.addEventListener("input", onChatInput);chatInput.addEventListener("keydown", onKeyDown);+ chatMessages.addEventListener("touchmove", onWheel);document.addEventListener("wheel", onWheel);document.addEventListener("dragenter", onDragBegin);document.addEventListener("dragover", onDragBegin);diff --git a/llamafile/server/www/index.html b/llamafile/server/www/index.htmlindex 1694c366..7b414a0c 100644--- a/llamafile/server/www/index.html+++ b/llamafile/server/www/index.html@@ -11,7 +11,7 @@<h1><img src="chatbot.png"width="64" height="64"- id="logo" style="display:none"+ class="logo" style="display:none"alt="[llamafile]" title="llamafile"><span id="model">loading...</span></h1>@@ -50,7 +50,7 @@<div class="completions-container" id="completions-interface" style="display:none"><div class="chat-header"><h1>- <img src="chatbot.png" alt="[llamafile]" title="llamafile" width="64" height="64">+ <img src="chatbot.png" class="logo" alt="[llamafile]" title="llamafile" width="64" height="64"><span id="model-completions">llamafile</span></h1><div class="menu-dropdown">@@ -76,25 +76,27 @@<h2>Model Settings</h2><button id="close-settings"><img src="close.svg" alt="[x]" width="24" height="24"></button></div>- <div class="setting-item">- <label>temperature = <span id="temp-value">0.8</span></label>- <input type="range" id="temperature" min="0" max="2" step="0.01" value="0.8">- <p class="setting-description">How much randomness to use during sampling. Higher values improve improvisation, and lower values result in determinism.</p>- </div>- <div class="setting-item">- <label>top_p = <span id="top-p-value">0.95</span></label>- <input type="range" id="top-p" min="0.01" max="1" step="0.01" value="0.95">- <p class="setting-description">Controls diversity via nucleus sampling. Reduces the probability mass from which to sample.</p>- </div>- <div class="setting-item">- <label>presence_penalty = <span id="presence-value">0</span></label>- <input type="range" id="presence-penalty" class="penalty-range" min="-2" max="2" step="0.1" value="0">- <p class="setting-description">Positive values discourage repetition; negative values encourage it.</p>- </div>- <div class="setting-item">- <label>frequency_penalty = <span id="frequency-value">0</span></label>- <input type="range" id="frequency-penalty" class="penalty-range" min="-2" max="2" step="0.1" value="0">- <p class="setting-description">Penalizes new tokens based on their frequency in the text so far.</p>+ <div class="settings-content">+ <div class="setting-item">+ <label>temperature = <span id="temp-value">0.8</span></label>+ <input type="range" id="temperature" min="0" max="2" step="0.01" value="0.8">+ <p class="setting-description">How much randomness to use during sampling. Higher values improve improvisation, and lower values result in determinism.</p>+ </div>+ <div class="setting-item">+ <label>top_p = <span id="top-p-value">0.95</span></label>+ <input type="range" id="top-p" min="0.01" max="1" step="0.01" value="0.95">+ <p class="setting-description">Controls diversity via nucleus sampling. Reduces the probability mass from which to sample.</p>+ </div>+ <div class="setting-item">+ <label>presence_penalty = <span id="presence-value">0</span></label>+ <input type="range" id="presence-penalty" class="penalty-range" min="-2" max="2" step="0.1" value="0">+ <p class="setting-description">Positive values discourage repetition; negative values encourage it.</p>+ </div>+ <div class="setting-item">+ <label>frequency_penalty = <span id="frequency-value">0</span></label>+ <input type="range" id="frequency-penalty" class="penalty-range" min="-2" max="2" step="0.1" value="0">+ <p class="setting-description">Penalizes new tokens based on their frequency in the text so far.</p>+ </div></div></div></div>diff --git a/llamafile/server/www/send.svg b/llamafile/server/www/send.svgnew file mode 100644index 00000000..be5960fc--- /dev/null+++ b/llamafile/server/www/send.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="white"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480l0-83.6c0-4 1.5-7.8 4.2-10.8L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>\ No newline at end of filediff --git a/llamafile/server/www/stop.svg b/llamafile/server/www/stop.svgnew file mode 100644index 00000000..5fc81b93--- /dev/null+++ b/llamafile/server/www/stop.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" fill="white"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M0 128C0 92.7 28.7 64 64 64H320c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128z"/></svg>\ No newline at end of file