common_log_set_file(common_log_main(), value.c_str());
}
).set_env("LLAMA_ARG_LOG_FILE"));
+ add_opt(common_arg(
+ {"--log-prompts-dir"}, "PATH",
+ "Log prompts to directory (only used for debugging, default: disabled)",
+ [](common_params & params, const std::string & value) {
+ params.path_prompts_log_dir = value;
+ }
+ ).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}));
add_opt(common_arg(
{"--log-colors"}, "[on|off|auto]",
"Set colored logging ('on', 'off', or 'auto', default: 'auto')\n"
std::string input_prefix = ""; // string to prefix user inputs with // NOLINT
std::string input_suffix = ""; // string to suffix user inputs with // NOLINT
std::string logits_file = ""; // file for saving *all* logits // NOLINT
+ std::string path_prompts_log_dir = ""; // directory with logged prompts // NOLINT
// llama-debug specific options
std::string logits_output_dir = "data"; // directory for saving logits output files // NOLINT
#include <memory>
#include <filesystem>
#include <utility>
+#include <fstream>
// fix problem with std::min and std::max
#if defined(_WIN32)
// TODO: this log can become very long, put it behind a flag or think about a more compact format
//SRV_DBG("Prompt: %s\n", prompt.is_string() ? prompt.get<std::string>().c_str() : prompt.dump(2).c_str());
+ if (!params.path_prompts_log_dir.empty()) {
+ const auto file_path = std::filesystem::path(params.path_prompts_log_dir) / string_format("%012" PRId64 ".txt", ggml_time_ms());
+ std::ofstream f(file_path);
+ if (f) {
+ f << (prompt.is_string() ? prompt.get<std::string>().c_str() : prompt.dump(2).c_str());
+ } else {
+ SRV_ERR("failed to create %s\n", file_path.string().c_str());
+ }
+ }
+
// process prompt
std::vector<server_tokens> inputs;