@@ -119,29 +119,33 @@ std::string common_arg::to_string() {
119
119
// utils
120
120
//
121
121
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 ()) {
124
128
// 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 ()) {
127
131
throw std::invalid_argument (" error: --hf-repo requires either --hf-file or --model\n " );
128
132
}
129
- params. hf_file = params. model ;
130
- } else if (params. model .empty ()) {
133
+ hf_file = model;
134
+ } else if (model.empty ()) {
131
135
// 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;
133
137
// to make sure we don't have any slashes in the filename
134
138
string_replace_all (filename, " /" , " _" );
135
- params. model = fs_get_cache_file (filename);
139
+ model = fs_get_cache_file (filename);
136
140
}
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 ();
140
144
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 ());
142
146
}
143
- } else if (params. model .empty ()) {
144
- params. model = DEFAULT_MODEL_PATH;
147
+ } else if (model.empty ()) {
148
+ model = DEFAULT_MODEL_PATH;
145
149
}
146
150
}
147
151
@@ -276,7 +280,9 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
276
280
throw std::invalid_argument (" error: --prompt-cache-all not supported in interactive mode yet\n " );
277
281
}
278
282
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 );
280
286
281
287
if (params.escape ) {
282
288
string_process_escapes (params.prompt );
@@ -842,7 +848,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
842
848
}
843
849
).set_sparam ());
844
850
add_opt (common_arg (
845
- {" --sampling-seq" }, " SEQUENCE" ,
851
+ {" --sampling-seq" , " --sampler-seq " }, " SEQUENCE" ,
846
852
string_format (" simplified sequence for samplers that will be used (default: %s)" , sampler_type_chars.c_str ()),
847
853
[](common_params & params, const std::string & value) {
848
854
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
1581
1587
params.hf_file = value;
1582
1588
}
1583
1589
).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" ));
1584
1604
add_opt (common_arg (
1585
1605
{" -hft" , " --hf-token" }, " TOKEN" ,
1586
1606
" 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
2178
2198
}
2179
2199
).set_examples ({LLAMA_EXAMPLE_SPECULATIVE, LLAMA_EXAMPLE_SERVER}).set_env (" LLAMA_ARG_MODEL_DRAFT" ));
2180
2200
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
+
2181
2209
return ctx_arg;
2182
2210
}
0 commit comments