Entropic 2.9.4
Local-first agentic inference engine
Loading...
Searching...
No Matches
download.cpp File Reference

entropic download subcommand — fetch GGUF models to the canonical install path. More...

#include <entropic/config/bundled_models.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <string>
#include <sys/wait.h>
#include <unistd.h>
Include dependency graph for download.cpp:

Go to the source code of this file.

Classes

struct  entropic::cli::DownloadArgs
 

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Functions

static bool entropic::cli::match_value_flag (const std::string &arg, const char *flag, int &i, int argc, char *argv[], std::string &dst)
 Match a --flag VALUE pair and consume the value (gh#62).
 
static bool entropic::cli::match_any_value_flag (const std::string &arg, int &i, int argc, char *argv[], DownloadArgs &out)
 Try the gh#62 selector value-flags (–family/–size/–quant).
 
DownloadArgs entropic::cli::parse_download_args (int argc, char *argv[])
 Parse command-line args for entropic download.
 
std::string entropic::cli::resolve_selector_key (const DownloadArgs &args, const entropic::config::BundledModels &registry)
 Resolve the target model key from an explicit key or a --family/--size/--quant selector (gh#62).
 
const entropic::config::BundledModelEntryentropic::cli::resolve_entry (const entropic::config::BundledModels &registry, const std::string &key)
 Resolve a registry entry by key with user-friendly error output.
 
int entropic::cli::fetch_to (const entropic::config::BundledModelEntry &entry, const std::filesystem::path &target_dir, const std::string &key)
 Download one registry entry to a target directory.
 
int entropic::cli::fetch_mmproj_if_paired (const entropic::config::BundledModelEntry &entry, const entropic::config::BundledModels &registry, const std::filesystem::path &target_dir)
 Paired-mmproj follow-up fetch (gh#42, v2.1.8).
 
int entropic::cli::dispatch (const DownloadArgs &args, const entropic::config::BundledModels &registry)
 Handle entropic download subcommand.
 
int entropic::cli::run_download (int argc, char *argv[])
 Handle entropic download subcommand.
 

Detailed Description

entropic download subcommand — fetch GGUF models to the canonical install path.

Simulates what the Python wheel's cli_download.py does, for tarball consumers who don't have pip. Shells out to curl — always present on Linux targets, avoids linking libcurl or an SSL backend into the main library.

Usage: entropic download <model-key> # e.g., entropic download primary entropic download –list # list available keys entropic download –dir DIR <key> # override target directory

Target: $ENTROPIC_MODEL_DIR → ~/.entropic/models → /opt/entropic/models (first writable; default ~/.entropic/models). Skips the download if the target file already exists and is non-empty, so reruns are cheap.

Version
2.0.5

Definition in file download.cpp.

Function Documentation

◆ dispatch()

int entropic::cli::dispatch ( const DownloadArgs args,
const entropic::config::BundledModels registry 
)

Handle entropic download subcommand.

Parameters
argcargc-like count starting at subcommand name.
argvargv-like vector starting at subcommand name.
Returns
0 on success, non-zero on usage/runtime error.

Dispatch after args parsed + registry loaded. @utility

Returns
Subcommand exit code.
Version
2.8.0

Definition at line 329 of file download.cpp.

◆ fetch_mmproj_if_paired()

int entropic::cli::fetch_mmproj_if_paired ( const entropic::config::BundledModelEntry entry,
const entropic::config::BundledModels registry,
const std::filesystem::path &  target_dir 
)

Paired-mmproj follow-up fetch (gh#42, v2.1.8).

If entry.mmproj_key names a registry entry, downloads it into the same target_dir as the base model. Best-effort: missing paired key returns 0 (text-only mode still works); a failed download propagates the curl exit code so the caller surfaces it.

Parameters
entryAlready-downloaded base model entry.
registryBundled models registry.
target_dirDirectory the base GGUF landed in.
Returns
0 on success or no-pairing, non-zero on mmproj fetch error. @utility
Version
2.1.8

Definition at line 300 of file download.cpp.

◆ fetch_to()

int entropic::cli::fetch_to ( const entropic::config::BundledModelEntry entry,
const std::filesystem::path &  target_dir,
const std::string &  key 
)

Download one registry entry to a target directory.

@utility

Returns
0 on success (or already-present), non-zero on failure.
Version
1

Definition at line 248 of file download.cpp.

◆ match_any_value_flag()

static bool entropic::cli::match_any_value_flag ( const std::string &  arg,
int &  i,
int  argc,
char *  argv[],
DownloadArgs out 
)
static

Try the gh#62 selector value-flags (–family/–size/–quant).

Short-circuits so the first match consumes its value; grouping the three keeps parse_download_args under the knots cognitive gate. @utility

Returns
true if arg matched one selector flag and consumed its value.
Version
2.8.0

Definition at line 150 of file download.cpp.

◆ match_value_flag()

static bool entropic::cli::match_value_flag ( const std::string &  arg,
const char *  flag,
int &  i,
int  argc,
char *  argv[],
std::string &  dst 
)
static

Match a --flag VALUE pair and consume the value (gh#62).

Returns
true if arg matched flag and a value was consumed into dst. @utility
Version
2.8.0

Definition at line 131 of file download.cpp.

◆ parse_download_args()

DownloadArgs entropic::cli::parse_download_args ( int  argc,
char *  argv[] 
)

Parse command-line args for entropic download.

@utility

Returns
Parsed args with .error=true on malformed input.
Version
2.8.0

Definition at line 164 of file download.cpp.

◆ resolve_entry()

const entropic::config::BundledModelEntry * entropic::cli::resolve_entry ( const entropic::config::BundledModels registry,
const std::string &  key 
)

Resolve a registry entry by key with user-friendly error output.

@utility

Returns
Pointer to entry, or nullptr on failure (message printed).
Version
1

Definition at line 222 of file download.cpp.

◆ resolve_selector_key()

std::string entropic::cli::resolve_selector_key ( const DownloadArgs args,
const entropic::config::BundledModels registry 
)

Resolve the target model key from an explicit key or a --family/--size/--quant selector (gh#62).

Returns
Registry key, or "" if unresolved. A partial or unmatched selector prints a specific error; an absent selector is silent (caller prints usage). @utility
Version
2.8.0

Definition at line 191 of file download.cpp.

◆ run_download()

int entropic::cli::run_download ( int  argc,
char *  argv[] 
)

Handle entropic download subcommand.

Parameters
argcargc-like count starting at subcommand name.
argvargv-like vector starting at subcommand name.
Returns
0 on success, non-zero on usage/runtime error.

Definition at line 370 of file download.cpp.