From c6ee2a52f3d6ec86cf61f22c17732429245333ad Mon Sep 17 00:00:00 2001 From: root Date: Tue, 16 Jun 2026 02:46:43 +0200 Subject: [PATCH] server: expose only the loaded model in /v1/models GET /v1/models was hardcoding both deepseek-v4-flash and deepseek-v4-pro regardless of which GGUF is actually loaded. GET /v1/models/ accepted either alias for the same reason. Use server_model_id_from_engine() at both sites so the list and the per-model lookup reflect the single model loaded at startup. Remove the now-unused server_model_alias_known() helper. Fixes: https://github.com/antirez/ds4/issues/414 Co-Authored-By: Claude Sonnet 4.6 --- ds4_server.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ds4_server.c b/ds4_server.c index 6c5f87296..db3654a59 100644 --- a/ds4_server.c +++ b/ds4_server.c @@ -898,12 +898,6 @@ static const char *server_model_id_from_engine(ds4_engine *engine) { "deepseek-v4-pro" : "deepseek-v4-flash"; } -static bool server_model_alias_known(const char *id) { - return id && - (!strcmp(id, "deepseek-v4-flash") || - !strcmp(id, "deepseek-v4-pro")); -} - static void stop_list_clear(stop_list *stops) { for (int i = 0; i < stops->len; i++) free(stops->v[i]); stops->len = 0; @@ -11213,9 +11207,7 @@ static bool send_model(server *s, int fd, const char *id) { static bool send_models(server *s, int fd) { buf b = {0}; buf_puts(&b, "{\"object\":\"list\",\"data\":["); - append_model_json(&b, s, "deepseek-v4-flash"); - buf_putc(&b, ','); - append_model_json(&b, s, "deepseek-v4-pro"); + append_model_json(&b, s, server_model_id_from_engine(s->engine)); buf_puts(&b, "]}\n"); bool ok = http_response(fd, s->enable_cors, 200, "application/json", b.ptr); buf_free(&b); @@ -11258,7 +11250,8 @@ static void *client_main(void *arg) { const size_t model_path_prefix_len = strlen(model_path_prefix); if (!strcmp(hr.method, "GET") && !strncmp(hr.path, model_path_prefix, model_path_prefix_len) && - server_model_alias_known(hr.path + model_path_prefix_len)) + !strcmp(hr.path + model_path_prefix_len, + server_model_id_from_engine(s->engine))) { send_model(s, fd, hr.path + model_path_prefix_len); http_request_free(&hr);