Skip to content

Commit 4e608be

Browse files
eugenio.segalaeugeniosegala
authored andcommitted
server : add flag to disable the web-ui
1 parent 26a8406 commit 4e608be

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

common/arg.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,13 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
17111711
params.public_path = value;
17121712
}
17131713
).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_STATIC_PATH"));
1714+
add_opt(common_arg(
1715+
{"--no-webui"},
1716+
"Disable the Web UI (default: enabled)",
1717+
[](common_params & params) {
1718+
params.webui = false;
1719+
}
1720+
).set_examples({LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_NO_WEBUI"));
17141721
add_opt(common_arg(
17151722
{"--embedding", "--embeddings"},
17161723
string_format("restrict to only support embedding use case; use only with dedicated embedding models (default: %s)", params.embedding ? "enabled" : "disabled"),

examples/server/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ The project is under active development, and we are [looking for feedback and co
146146
| `--host HOST` | ip address to listen (default: 127.0.0.1)<br/>(env: LLAMA_ARG_HOST) |
147147
| `--port PORT` | port to listen (default: 8080)<br/>(env: LLAMA_ARG_PORT) |
148148
| `--path PATH` | path to serve static files from (default: )<br/>(env: LLAMA_ARG_STATIC_PATH) |
149+
| `--no-webui` | disable the Web UI<br/>(env: LLAMA_ARG_NO_WEBUI) |
149150
| `--embedding, --embeddings` | restrict to only support embedding use case; use only with dedicated embedding models (default: disabled)<br/>(env: LLAMA_ARG_EMBEDDINGS) |
150151
| `--reranking, --rerank` | enable reranking endpoint on server (default: disabled)<br/>(env: LLAMA_ARG_RERANKING) |
151152
| `--api-key KEY` | API key to use for authentication (default: none)<br/>(env: LLAMA_API_KEY) |

examples/server/server.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,20 +3815,24 @@ int main(int argc, char ** argv) {
38153815
// Router
38163816
//
38173817

3818-
// register static assets routes
3819-
if (!params.public_path.empty()) {
3820-
// Set the base directory for serving static files
3821-
bool is_found = svr->set_mount_point("/", params.public_path);
3822-
if (!is_found) {
3823-
LOG_ERR("%s: static assets path not found: %s\n", __func__, params.public_path.c_str());
3824-
return 1;
3825-
}
3818+
if (!params.webui) {
3819+
LOG_INF("Web UI is %s\n", params.webui ? "enabled" : "disabled");
38263820
} else {
3827-
// using embedded static index.html
3828-
svr->Get("/", [](const httplib::Request &, httplib::Response & res) {
3829-
res.set_content(reinterpret_cast<const char*>(index_html), index_html_len, "text/html; charset=utf-8");
3830-
return false;
3831-
});
3821+
// register static assets routes
3822+
if (!params.public_path.empty()) {
3823+
// Set the base directory for serving static files
3824+
bool is_found = svr->set_mount_point("/", params.public_path);
3825+
if (!is_found) {
3826+
LOG_ERR("%s: static assets path not found: %s\n", __func__, params.public_path.c_str());
3827+
return 1;
3828+
}
3829+
} else {
3830+
// 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");
3833+
return false;
3834+
});
3835+
}
38323836
}
38333837

38343838
// register API routes

0 commit comments

Comments
 (0)