This commit is contained in:
Xuan Son Nguyen
2026-07-07 21:56:44 +02:00
parent b9617e860a
commit a87b2d77cf
3 changed files with 44 additions and 30 deletions
+9 -9
View File
@@ -6,6 +6,7 @@
#include "cli-server.h"
#include <atomic>
#include <memory>
#include <optional>
#include <string>
@@ -14,8 +15,7 @@ struct cli_timings {
double predicted_per_second = 0.0;
};
// set by the SIGINT handler; cleared once the interrupt has been handled
extern std::atomic<bool> g_cli_interrupted;
struct cli_context_impl;
struct cli_context {
common_params params;
@@ -23,9 +23,6 @@ struct cli_context {
cli_client client; // always initialized
std::optional<cli_server> server; // only set when no --server-base is given
json messages = json::array();
json pending_media = json::array(); // staged multimodal content parts
// properties of the connected server
// will be populated by fetch_server_props()
std::string model_name;
@@ -35,10 +32,8 @@ struct cli_context {
bool has_audio = false;
bool has_video = false;
cli_context(const common_params & params) : params(params) {}
~cli_context() {
shutdown();
}
cli_context(const common_params & params);
~cli_context();
// connect to --server-base or spawn a local llama-server child;
// argc/argv are needed to forward the server-relevant args to the child
@@ -50,6 +45,9 @@ struct cli_context {
// stop the local server child (if any)
void shutdown();
// set by the SIGINT handler; cleared once the interrupt has been handled
static std::atomic<bool> & interrupted();
private:
bool generate_completion(std::string & assistant_content, cli_timings & timings);
void fetch_server_props();
@@ -63,4 +61,6 @@ private:
// read a file and stage it as a multimodal content part; type is one of
// "image", "audio", "video"; returns false if the file cannot be read
bool stage_media_file(const std::string & fname, const std::string & type);
std::unique_ptr<cli_context_impl> impl;
};