Skip to content

Distribute and run LLMs with a single file.

Add ability to override chat template in web gui

Justine Tunneyda5cbe450f2a
diff --git a/llama.cpp/server/public/history-template.txt b/llama.cpp/server/public/history-template.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/llama.cpp/server/public/index.html b/llama.cpp/server/public/index.html
index 18ecf8d7..96bbc0f0 100644
--- a/llama.cpp/server/public/index.html
+++ b/llama.cpp/server/public/index.html
@@ -750,8 +750,9 @@
<div>
<label for="template">Chat history template</label>
- <textarea id="template" name="historyTemplate" value="${session.value.historyTemplate}" rows=1 oninput=${updateSession}/>
+ <textarea id="historyTemplate" name="historyTemplate" value="${session.value.historyTemplate}" rows=1 oninput=${updateSession}/>
</div>
+
${GrammarControl()}
</fieldset>
`
@@ -1285,14 +1286,31 @@
render(h(App), document.querySelector('#container'));
</script>
-</head>
<body>
- <div id="container">
- <input type="file" id="fileInput" accept="image/*" style="display: none;">
- </div>
- <div id="portal"></div>
-</body>
-</html>
+<div id="container">
+ <input type="file" id="fileInput" accept="image/*" style="display: none;">
+</div>
+<div id="portal"></div>
+
+<script>
+
+function load_config(id, url) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200 && xhr.responseText.trim())
+ document.getElementById(id).value = xhr.responseText.trim();
+ };
+ xhr.open('GET', url, true);
+ xhr.send();
+}
+
+function on_load() {
+ load_config('template', '/prompt-template.txt');
+ load_config('historyTemplate', '/history-template.txt');
+}
+
+document.addEventListener('DOMContentLoaded', on_load);
+</script>
diff --git a/llama.cpp/server/public/prompt-template.txt b/llama.cpp/server/public/prompt-template.txt
new file mode 100644
index 00000000..e69de29b