Skip to content

Commit 58a7dcb

Browse files
server : address review feedback from ggerganov
1 parent 987c507 commit 58a7dcb

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

common/common.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <vector>
1313
#include <map>
1414

15-
#include <nlohmann/json.hpp>
16-
1715
#if defined(_WIN32) && !defined(_WIN32_WINNT)
1816
#define _WIN32_WINNT 0x0A00
1917
#endif
@@ -485,7 +483,7 @@ struct common_params {
485483
// "advanced" endpoints are disabled by default for better security
486484
bool webui = true;
487485
std::string webui_config_file;
488-
nlohmann::ordered_json webui_config = nlohmann::ordered_json::object();
486+
std::string webui_config_json;
489487
bool endpoint_slots = true;
490488
bool endpoint_props = false; // only control POST requests, not GET
491489
bool endpoint_metrics = false;

tools/server/server-context.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3104,6 +3104,8 @@ void server_routes::init_routes() {
31043104
}
31053105

31063106
// this endpoint is publicly available, please only return what is safe to be exposed
3107+
json webui_settings = params.webui_config_json.empty() ? json::object() : json::parse(params.webui_config_json);
3108+
31073109
json data = {
31083110
{ "default_generation_settings", default_generation_settings_for_props },
31093111
{ "total_slots", ctx_server.params_base.n_parallel },
@@ -3117,7 +3119,7 @@ void server_routes::init_routes() {
31173119
{ "endpoint_props", params.endpoint_props },
31183120
{ "endpoint_metrics", params.endpoint_metrics },
31193121
{ "webui", params.webui },
3120-
{ "webui_settings", params.webui_config },
3122+
{ "webui_settings", webui_settings },
31213123
{ "chat_template", common_chat_templates_source(ctx_server.chat_templates.get()) },
31223124
{ "bos_token", common_token_to_piece(ctx_server.ctx, llama_vocab_bos(ctx_server.vocab), /* special= */ true)},
31233125
{ "eos_token", common_token_to_piece(ctx_server.ctx, llama_vocab_eos(ctx_server.vocab), /* special= */ true)},

tools/server/server-models.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ void server_models_routes::init_routes() {
811811
if (name.empty()) {
812812
// main instance
813813
auto res = std::make_unique<server_http_res>();
814+
json webui_settings = params.webui_config_json.empty() ? json::object() : json::parse(params.webui_config_json);
814815
res_ok(res, {
815816
// TODO: add support for this on web UI
816817
{"role", "router"},
@@ -822,7 +823,7 @@ void server_models_routes::init_routes() {
822823
{"params", json{}},
823824
{"n_ctx", 0},
824825
}},
825-
{"webui_settings", params.webui_config},
826+
{"webui_settings", webui_settings},
826827
});
827828
return res;
828829
}

tools/server/server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int main(int argc, char ** argv, char ** envp) {
103103
}
104104
}
105105

106-
params.webui_config = std::move(webui_settings);
106+
params.webui_config_json = webui_settings.dump();
107107

108108
// TODO: should we have a separate n_parallel parameter for the server?
109109
// https://github.com/ggml-org/llama.cpp/pull/16736#discussion_r2483763177

0 commit comments

Comments
 (0)