File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 4747#define LLAMA_MAX_URL_LENGTH 2084 // Maximum URL Length in Chrome: 2083
4848
4949using json = nlohmann::ordered_json;
50+ using namespace common_arg_utils ;
5051
5152static std::initializer_list<enum llama_example> mmproj_examples = {
5253 LLAMA_EXAMPLE_MTMD,
@@ -756,15 +757,15 @@ static std::string list_builtin_chat_templates() {
756757 return msg.str ();
757758}
758759
759- static bool is_truthy (const std::string & value) {
760+ bool common_arg_utils:: is_truthy (const std::string & value) {
760761 return value == " on" || value == " enabled" || value == " 1" ;
761762}
762763
763- static bool is_falsey (const std::string & value) {
764+ bool common_arg_utils:: is_falsey (const std::string & value) {
764765 return value == " off" || value == " disabled" || value == " 0" ;
765766}
766767
767- static bool is_autoy (const std::string & value) {
768+ bool common_arg_utils:: is_autoy (const std::string & value) {
768769 return value == " auto" || value == " -1" ;
769770}
770771
Original file line number Diff line number Diff line change @@ -82,6 +82,12 @@ struct common_arg {
8282 }
8383};
8484
85+ namespace common_arg_utils {
86+ bool is_truthy (const std::string & value);
87+ bool is_falsey (const std::string & value);
88+ bool is_autoy (const std::string & value);
89+ }
90+
8591struct common_params_context {
8692 enum llama_example ex = LLAMA_EXAMPLE_COMMON;
8793 common_params & params;
Original file line number Diff line number Diff line change @@ -20,11 +20,18 @@ std::vector<std::string> common_preset::to_args() const {
2020
2121 for (const auto & [opt, value] : options) {
2222 args.push_back (opt.args .back ()); // use the last arg as the main arg
23+ if (opt.value_hint == nullptr && opt.value_hint_2 == nullptr ) {
24+ // flag option, no value
25+ if (common_arg_utils::is_falsey (value)) {
26+ // skip the flag
27+ args.pop_back ();
28+ }
29+ }
2330 if (opt.value_hint != nullptr ) {
2431 // single value
2532 args.push_back (value);
2633 }
27- if (opt.value_hint_2 != nullptr ) {
34+ if (opt.value_hint != nullptr && opt. value_hint_2 != nullptr ) {
2835 throw std::runtime_error (string_format (
2936 " common_preset::to_args(): option '%s' has two values, which is not supported yet" ,
3037 opt.args .back ()
You can’t perform that action at this time.
0 commit comments