cli: add --output option (#25484)

This commit is contained in:
Xuan-Son Nguyen
2026-07-09 19:37:39 +02:00
committed by GitHub
parent fb30ba9a6c
commit 3de7dd4c8f
3 changed files with 60 additions and 8 deletions

View File

@@ -9,6 +9,7 @@
#include <memory>
#include <optional>
#include <string>
#include <fstream>
struct cli_timings {
double prompt_per_second = 0.0;
@@ -32,6 +33,8 @@ struct cli_context {
bool has_audio = false;
bool has_video = false;
std::optional<std::ofstream> output_file;
cli_context(const common_params & params);
~cli_context();
@@ -49,7 +52,11 @@ struct cli_context {
static std::atomic<bool> & interrupted();
private:
bool generate_completion(std::string & assistant_content, cli_timings & timings);
struct generated_content {
std::string reasoning;
std::string content;
};
bool generate_completion(generated_content & content_out, cli_timings & timings);
void fetch_server_props();
void add_system_prompt();
void push_user_message(const std::string & text);
@@ -62,5 +69,8 @@ private:
// "image", "audio", "video"; returns false if the file cannot be read
bool stage_media_file(const std::string & fname, const std::string & type);
// no-op if output file is not set
void write_output_file(const std::string & content);
std::unique_ptr<cli_context_impl> impl;
};