Skip to content

Commit ecf0efa

Browse files
VJHackngxson
authored andcommitted
server: (UI) add syntax highlighting and latex math rendering (ggml-org#10808)
* add code highlighting and math formatting * code cleanup * build public/index.html * rebuild public/index.html * fixed coding style * fixed coding style * style fixes * highlight: smaller bundle size, fix light & dark theme * remove katex * add bundle size check * add more languages * add php * reuse some langs * use gzip * Revert "remove katex" This reverts commit c0e5046. * use better maintained @vscode/markdown-it-katex * fix gzip non deterministic * ability to add a demo conversation for dev * fix latex rendering * add comment * latex codeblock as code --------- Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
1 parent 49de4e2 commit ecf0efa

File tree

14 files changed

+839
-444
lines changed

14 files changed

+839
-444
lines changed

examples/server/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(TARGET_SRCS
1515
httplib.h
1616
)
1717
set(PUBLIC_ASSETS
18-
index.html
18+
index.html.gz
1919
loading.html
2020
)
2121

examples/server/public/index.html

Lines changed: 0 additions & 389 deletions
This file was deleted.

examples/server/public/index.html.gz

1.15 MB
Binary file not shown.

examples/server/server.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define MIMETYPE_JSON "application/json; charset=utf-8"
1616

1717
// auto generated files (update with ./deps.sh)
18-
#include "index.html.hpp"
18+
#include "index.html.gz.hpp"
1919
#include "loading.html.hpp"
2020

2121
#include <atomic>
@@ -3828,8 +3828,13 @@ int main(int argc, char ** argv) {
38283828
}
38293829
} else {
38303830
// using embedded static index.html
3831-
svr->Get("/", [](const httplib::Request &, httplib::Response & res) {
3832-
res.set_content(reinterpret_cast<const char*>(index_html), index_html_len, "text/html; charset=utf-8");
3831+
svr->Get("/", [](const httplib::Request & req, httplib::Response & res) {
3832+
if (req.get_header_value("Accept-Encoding").find("gzip") == std::string::npos) {
3833+
res.set_content("Error: gzip is not supported by this browser", "text/plain");
3834+
} else {
3835+
res.set_header("Content-Encoding", "gzip");
3836+
res.set_content(reinterpret_cast<const char*>(index_html_gz), index_html_gz_len, "text/html; charset=utf-8");
3837+
}
38333838
return false;
38343839
});
38353840
}

examples/server/webui/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ <h3 class="text-lg font-bold mb-6">Settings</h3>
201201
<details class="collapse collapse-arrow bg-base-200 mb-2 overflow-visible">
202202
<summary class="collapse-title font-bold">Advanced config</summary>
203203
<div class="collapse-content">
204+
<div class="flex flex-row items-center mb-2" v-if="isDev">
205+
<!-- this button only shows in dev mode, used to import a demo conversation to test message rendering -->
206+
<button class="btn" @click="debugImportDemoConv()">(debug) Import demo conversation</button>
207+
</div>
204208
<div class="flex flex-row items-center mb-2">
205209
<input type="checkbox" class="checkbox" v-model="config.showTokensPerSecond" />
206210
<span class="ml-4">Show tokens per second</span>

0 commit comments

Comments
 (0)