mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-07-23 11:10:55 -05:00
cli: add --output option (#25484)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user