LLAMA_SERVER_NO_WEBUI → LLAMA_BUILD_WEBUI

This commit is contained in:
kushagharahi 2026-03-06 00:24:24 -06:00
parent 9b4a763f56
commit f6f5715a86
3 changed files with 7 additions and 7 deletions

View File

@ -108,7 +108,7 @@ option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE})
option(LLAMA_BUILD_TOOLS "llama: build tools" ${LLAMA_STANDALONE}) option(LLAMA_BUILD_TOOLS "llama: build tools" ${LLAMA_STANDALONE})
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE}) option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE}) option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE})
option(LLAMA_SERVER_NO_WEBUI "llama: disable the embedded Web UI in server" OFF) option(LLAMA_BUILD_WEBUI "llama: build the embedded Web UI for server" ${LLAMA_STANDALONE})
option(LLAMA_TOOLS_INSTALL "llama: install tools" ${LLAMA_TOOLS_INSTALL_DEFAULT}) option(LLAMA_TOOLS_INSTALL "llama: install tools" ${LLAMA_TOOLS_INSTALL_DEFAULT})
option(LLAMA_TESTS_INSTALL "llama: install tests" ON) option(LLAMA_TESTS_INSTALL "llama: install tests" ON)

View File

@ -36,9 +36,9 @@ set(TARGET_SRCS
server-models.h server-models.h
) )
option(LLAMA_SERVER_NO_WEBUI "Disable the embedded Web UI" OFF) option(LLAMA_BUILD_WEBUI "Build the embedded Web UI" ${LLAMA_STANDALONE})
if (NOT LLAMA_SERVER_NO_WEBUI) if (LLAMA_BUILD_WEBUI)
set(PUBLIC_ASSETS set(PUBLIC_ASSETS
index.html.gz index.html.gz
loading.html loading.html
@ -55,8 +55,8 @@ if (NOT LLAMA_SERVER_NO_WEBUI)
) )
set_source_files_properties(${output} PROPERTIES GENERATED TRUE) set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
endforeach() endforeach()
add_definitions(-DLLAMA_BUILD_WEBUI)
else() else()
add_definitions(-DLLAMA_SERVER_NO_WEBUI)
endif() endif()
add_executable(${TARGET} ${TARGET_SRCS}) add_executable(${TARGET} ${TARGET_SRCS})

View File

@ -8,7 +8,7 @@
#include <string> #include <string>
#include <thread> #include <thread>
#ifndef LLAMA_SERVER_NO_WEBUI #ifdef LLAMA_BUILD_WEBUI
// auto generated files (see README.md for details) // auto generated files (see README.md for details)
#include "index.html.gz.hpp" #include "index.html.gz.hpp"
#include "loading.html.hpp" #include "loading.html.hpp"
@ -183,7 +183,7 @@ bool server_http_context::init(const common_params & params) {
auto middleware_server_state = [this](const httplib::Request & req, httplib::Response & res) { auto middleware_server_state = [this](const httplib::Request & req, httplib::Response & res) {
bool ready = is_ready.load(); bool ready = is_ready.load();
if (!ready) { if (!ready) {
#ifndef LLAMA_SERVER_NO_WEBUI #ifdef LLAMA_BUILD_WEBUI
auto tmp = string_split<std::string>(req.path, '.'); auto tmp = string_split<std::string>(req.path, '.');
if (req.path == "/" || tmp.back() == "html") { if (req.path == "/" || tmp.back() == "html") {
res.status = 503; res.status = 503;
@ -254,7 +254,7 @@ bool server_http_context::init(const common_params & params) {
return 1; return 1;
} }
} else { } else {
#ifndef LLAMA_SERVER_NO_WEBUI #ifdef LLAMA_BUILD_WEBUI
// using embedded static index.html // using embedded static index.html
srv->Get(params.api_prefix + "/", [](const httplib::Request & req, httplib::Response & res) { srv->Get(params.api_prefix + "/", [](const httplib::Request & req, httplib::Response & res) {
if (req.get_header_value("Accept-Encoding").find("gzip") == std::string::npos) { if (req.get_header_value("Accept-Encoding").find("gzip") == std::string::npos) {