char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
60bc8866b
char/aliceai-t5-moe
1#include "arg.h" 2#include "common.h" 3#include "download.h" 4#include "log.h" 5 6#include <cstdio> 7#include <filesystem> 8 9static void print_usage (int /*argc*/ ,char ** argv ) { 10printf ( 11"\nexamples:\n" 12" %s -hf ggml-org/gemma-3-4b-it-qat-GGUF\n" 13" %s -hf ggml-org/gemma-3-4b-it-qat-GGUF:Q4_K_M\n" 14" %s -hf ggml-org/models -hff model.gguf\n" 15" %s -mu https://example.com/model.gguf -m model.gguf\n" 16"\n" , 17argv [0 ],argv [0 ],argv [0 ],argv [0 ] 18 ); 19} 20 21int llama_download (int argc ,char ** argv ); 22 23int llama_download (int argc ,char ** argv ) { 24common_init (); 25 26common_params params ; 27params .verbosity = LOG_LEVEL_ERROR ; 28 29if (!common_params_parse (argc ,argv ,params ,LLAMA_EXAMPLE_DOWNLOAD ,print_usage )) { 30return 1 ; 31 } 32 33const bool has_source = !params .model .hf_repo .empty ()|| !params .model .url .empty ()|| 34 !params .model .path .empty ()|| !params .model .docker_repo .empty (); 35if (!has_source ) { 36fprintf (stderr ,"error: no model source specified (use --hf-repo, --model-url, --model or --docker-repo)\n" ); 37return 1 ; 38 } 39 40try { 41common_models_handler handler = common_models_handler_init (params ,LLAMA_EXAMPLE_DOWNLOAD ); 42common_models_handler_apply (handler ,params ); 43 }catch (const std::exception & e ) { 44fprintf (stderr ,"error: %s\n" ,e .what ()); 45return 1 ; 46 } 47 48if (!params .models_preset .empty ()) { 49// -hf pointed at a preset repo: print the preset path and stop 50printf ("%s\n" ,params .models_preset .c_str ()); 51return 0 ; 52 } 53if (params .model .path .empty ()) { 54fprintf (stderr ,"error: model download failed\n" ); 55return 1 ; 56 } 57if (!std::filesystem::exists (params .model .path )) { 58fprintf (stderr ,"error: model file does not exist: %s\n" ,params .model .path .c_str ()); 59return 1 ; 60 } 61 62printf ("%s\n" ,params .model .path .c_str ()); 63if (!params .mmproj .path .empty ()) { 64printf ("%s\n" ,params .mmproj .path .c_str ()); 65 } 66if (!params .speculative .draft .mparams .path .empty ()) { 67printf ("%s\n" ,params .speculative .draft .mparams .path .c_str ()); 68 } 69 70return 0 ; 71}