@@ -119,29 +119,33 @@ std::string common_arg::to_string() {
119119// utils
120120//
121121
122- static void common_params_handle_model_default (common_params & params) {
123- if (!params.hf_repo .empty ()) {
122+ static void common_params_handle_model_default (
123+ std::string & model,
124+ std::string & model_url,
125+ std::string & hf_repo,
126+ std::string & hf_file) {
127+ if (!hf_repo.empty ()) {
124128 // short-hand to avoid specifying --hf-file -> default it to --model
125- if (params. hf_file .empty ()) {
126- if (params. model .empty ()) {
129+ if (hf_file.empty ()) {
130+ if (model.empty ()) {
127131 throw std::invalid_argument (" error: --hf-repo requires either --hf-file or --model\n " );
128132 }
129- params. hf_file = params. model ;
130- } else if (params. model .empty ()) {
133+ hf_file = model;
134+ } else if (model.empty ()) {
131135 // this is to avoid different repo having same file name, or same file name in different subdirs
132- std::string filename = params. hf_repo + " _" + params. hf_file ;
136+ std::string filename = hf_repo + " _" + hf_file;
133137 // to make sure we don't have any slashes in the filename
134138 string_replace_all (filename, " /" , " _" );
135- params. model = fs_get_cache_file (filename);
139+ model = fs_get_cache_file (filename);
136140 }
137- } else if (!params. model_url .empty ()) {
138- if (params. model .empty ()) {
139- auto f = string_split<std::string>(params. model_url , ' #' ).front ();
141+ } else if (!model_url.empty ()) {
142+ if (model.empty ()) {
143+ auto f = string_split<std::string>(model_url, ' #' ).front ();
140144 f = string_split<std::string>(f, ' ?' ).front ();
141- params. model = fs_get_cache_file (string_split<std::string>(f, ' /' ).back ());
145+ model = fs_get_cache_file (string_split<std::string>(f, ' /' ).back ());
142146 }
143- } else if (params. model .empty ()) {
144- params. model = DEFAULT_MODEL_PATH;
147+ } else if (model.empty ()) {
148+ model = DEFAULT_MODEL_PATH;
145149 }
146150}
147151
@@ -276,7 +280,9 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
276280 throw std::invalid_argument (" error: --prompt-cache-all not supported in interactive mode yet\n " );
277281 }
278282
279- common_params_handle_model_default (params);
283+ // TODO: refactor model params in a common struct
284+ common_params_handle_model_default (params.model , params.model_url , params.hf_repo , params.hf_file );
285+ common_params_handle_model_default (params.vocoder .model , params.vocoder .model_url , params.vocoder .hf_repo , params.vocoder .hf_file );
280286
281287 if (params.escape ) {
282288 string_process_escapes (params.prompt );
@@ -842,7 +848,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
842848 }
843849 ).set_sparam ());
844850 add_opt (common_arg (
845- {" --sampling-seq" }, " SEQUENCE" ,
851+ {" --sampling-seq" , " --sampler-seq " }, " SEQUENCE" ,
846852 string_format (" simplified sequence for samplers that will be used (default: %s)" , sampler_type_chars.c_str ()),
847853 [](common_params & params, const std::string & value) {
848854 params.sampling .samplers = common_sampler_types_from_chars (value);
@@ -1581,6 +1587,20 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
15811587 params.hf_file = value;
15821588 }
15831589 ).set_env (" LLAMA_ARG_HF_FILE" ));
1590+ add_opt (common_arg (
1591+ {" -hfrv" , " --hf-repo-v" }, " REPO" ,
1592+ " Hugging Face model repository for the vocoder model (default: unused)" ,
1593+ [](common_params & params, const std::string & value) {
1594+ params.vocoder .hf_repo = value;
1595+ }
1596+ ).set_env (" LLAMA_ARG_HF_REPO_V" ));
1597+ add_opt (common_arg (
1598+ {" -hffv" , " --hf-file-v" }, " FILE" ,
1599+ " Hugging Face model file for the vocoder model (default: unused)" ,
1600+ [](common_params & params, const std::string & value) {
1601+ params.vocoder .hf_file = value;
1602+ }
1603+ ).set_env (" LLAMA_ARG_HF_FILE_V" ));
15841604 add_opt (common_arg (
15851605 {" -hft" , " --hf-token" }, " TOKEN" ,
15861606 " Hugging Face access token (default: value from HF_TOKEN environment variable)" ,
@@ -2178,5 +2198,13 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
21782198 }
21792199 ).set_examples ({LLAMA_EXAMPLE_SPECULATIVE, LLAMA_EXAMPLE_SERVER}).set_env (" LLAMA_ARG_MODEL_DRAFT" ));
21802200
2201+ add_opt (common_arg (
2202+ {" -mv" , " --model-vocoder" }, " FNAME" ,
2203+ " vocoder model for audio generation (default: unused)" ,
2204+ [](common_params & params, const std::string & value) {
2205+ params.vocoder .model = value;
2206+ }
2207+ ).set_examples ({LLAMA_EXAMPLE_TTS, LLAMA_EXAMPLE_SERVER}));
2208+
21812209 return ctx_arg;
21822210}
0 commit comments