LLM inference in C/C++
C++ ggml
common: auto-create prompts-log-dir at argument parsing, so all tools using the flag benefit (#25322)
rankaiyxf296fdfbed71
diff --git a/common/arg.cpp b/common/arg.cppindex fdf58614b6..a260931992 100644--- a/common/arg.cpp+++ b/common/arg.cpp@@ -27,6 +27,7 @@#include <cinttypes>#include <climits>#include <cstdarg>+#include <filesystem>#include <fstream>#include <list>#include <regex>@@ -3451,9 +3452,14 @@ common_params_context common_params_parser_init(common_params & params, llama_ex).set_env("LLAMA_ARG_LOG_FILE"));add_opt(common_arg({"--log-prompts-dir"}, "PATH",- "Log prompts to directory (only used for debugging, default: disabled)",+ "Log prompts to directory (auto-created if not present; only used for debugging, default: disabled)",[](common_params & params, const std::string & value) {params.path_prompts_log_dir = value;+ std::error_code ec;+ std::filesystem::create_directories(value, ec);+ if (ec) {+ fprintf(stderr, "warning: failed to create prompts-log-dir '%s': %s\n", value.c_str(), ec.message().c_str());+ }}).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}));add_opt(common_arg(diff --git a/tools/server/README.md b/tools/server/README.mdindex 501b66123d..365a944659 100644--- a/tools/server/README.md+++ b/tools/server/README.md@@ -228,7 +228,7 @@ For the full list of features, please refer to [server's changelog](https://gith| `-sps, --slot-prompt-similarity SIMILARITY` | how much the prompt of a request must match the prompt of a slot in order to use that slot (default: 0.10, 0.0 = disabled) || `--lora-init-without-apply` | load LoRA adapters without applying them (apply later via POST /lora-adapters) (default: disabled) || `--sleep-idle-seconds SECONDS` | number of seconds of idleness after which the server will sleep (default: -1; -1 = disabled) |-| `--log-prompts-dir PATH` | Log prompts to directory (only used for debugging, default: disabled) |+| `--log-prompts-dir PATH` | Log prompts to directory (auto-created if not present; only used for debugging, default: disabled) || `--spec-draft-hf, -hfd, -hfrd, --hf-repo-draft <user>/<model>[:quant]` | Same as --hf-repo, but for the draft model (default: unused)<br/>(env: LLAMA_ARG_SPEC_DRAFT_HF_REPO) || `--spec-draft-threads, -td, --threads-draft N` | number of threads to use during generation (default: same as --threads) || `--spec-draft-threads-batch, -tbd, --threads-batch-draft N` | number of threads to use during batch and prompt processing (default: same as --threads-draft) |