@@ -132,28 +132,6 @@ static std::string show_default_thought_tags(void)
132132 return tags;
133133}
134134
135- static bool is_same_command_option (const char *a, const char *b)
136- {
137- while (*a && *b)
138- {
139- char ca = *a;
140- char cb = *b;
141- if (ca == ' -' ) ca = ' _' ;
142- if (cb == ' -' ) cb = ' _' ;
143- if (ca != cb)
144- return false ;
145- a++;
146- b++;
147- }
148-
149- return *a == *b;
150- }
151-
152- bool is_same_command_option (const std::string &a, const std::string &b)
153- {
154- return is_same_command_option (a.c_str (), b.c_str ());
155- }
156-
157135void usage (const std::string &prog)
158136{
159137 Args args;
@@ -309,31 +287,31 @@ static size_t parse_args(Args &args, const std::vector<std::string> &argv)
309287 const size_t argc = argv.size ();
310288
311289 #define handle_para0 (fmt1, field, f ) \
312- else if ((is_same_command_option (arg, fmt1))) \
290+ else if ((utils:: is_same_command_option (arg, fmt1))) \
313291 { \
314292 c++; \
315293 if (c < argc) \
316294 args.field = f (argv[c].c_str ()); \
317295 }
318296
319297 #define handle_param (fmt1, fmt2, field, f ) \
320- else if ((is_same_command_option (arg, fmt1)) || (is_same_command_option (arg, fmt2))) \
298+ else if ((utils:: is_same_command_option (arg, fmt1)) || (utils:: is_same_command_option (arg, fmt2))) \
321299 { \
322300 c++; \
323301 if (c < argc) \
324302 args.field = f (argv[c].c_str ()); \
325303 }
326304
327305 #define append_param (fmt1, field, f ) \
328- else if ((is_same_command_option (arg, fmt1))) \
306+ else if ((utils:: is_same_command_option (arg, fmt1))) \
329307 { \
330308 c++; \
331309 if (c < argc) \
332310 args.field .push_back (f (argv[c].c_str ())); \
333311 }
334312
335313 #define handle_flag (field ) \
336- else if ((is_same_command_option (arg, " +" #field)) || (is_same_command_option (arg, " --" #field))) \
314+ else if ((utils:: is_same_command_option (arg, " +" #field)) || (utils:: is_same_command_option (arg, " --" #field))) \
337315 { \
338316 args.field = true ; \
339317 }
@@ -345,19 +323,21 @@ static size_t parse_args(Args &args, const std::vector<std::string> &argv)
345323 while (c < argc)
346324 {
347325 const char *arg = argv[c].c_str ();
348- if ((is_same_command_option (arg, " --help" )) || (is_same_command_option (arg, " -h" )) || (is_same_command_option (arg, " -?" )))
326+ if ((utils::is_same_command_option (arg, " --help" ))
327+ || (utils::is_same_command_option (arg, " -h" ))
328+ || (utils::is_same_command_option (arg, " -?" )))
349329 {
350330 args.show_help = true ;
351331 }
352- else if ((strcmp (arg, " --interactive" ) == 0 ) || (strcmp (arg, " -i" ) == 0 ))
332+ else if ((utils::is_same_command_option (arg, " --interactive" )) || (strcmp (arg, " -i" ) == 0 ))
353333 {
354334 args.interactive = true ;
355335 }
356- else if (is_same_command_option (arg, " --multi" ))
336+ else if (utils:: is_same_command_option (arg, " --multi" ))
357337 {
358338 args.multi_line = true ;
359339 }
360- else if (is_same_command_option (arg, " --hide_banner" ))
340+ else if (utils:: is_same_command_option (arg, " --hide_banner" ))
361341 {
362342 args.show_banner = false ;
363343 }
@@ -370,7 +350,7 @@ static size_t parse_args(Args &args, const std::vector<std::string> &argv)
370350 handle_flag (rerank_rewrite)
371351 handle_flag (moe_on_cpu)
372352 handle_flag (detect_thoughts)
373- else if (is_same_command_option (arg, " --format" ))
353+ else if (utils:: is_same_command_option (arg, " --format" ))
374354 {
375355 c++;
376356 if (c < argc)
@@ -383,7 +363,7 @@ static size_t parse_args(Args &args, const std::vector<std::string> &argv)
383363 args.format = chatllm::ChatFormat::CHAT;
384364 }
385365 }
386- else if (is_same_command_option (arg, " --save_session" ))
366+ else if (utils:: is_same_command_option (arg, " --save_session" ))
387367 {
388368 c++;
389369 if (c + 1 < argc)
@@ -393,15 +373,15 @@ static size_t parse_args(Args &args, const std::vector<std::string> &argv)
393373 c++;
394374 }
395375 }
396- else if (is_same_command_option (arg, " --kv" ))
376+ else if (utils:: is_same_command_option (arg, " --kv" ))
397377 {
398378 while (c + 2 < argc)
399379 {
400380 args.additional .insert_or_assign (argv[c + 1 ], argv[c + 2 ]);
401381 c += 2 ;
402382 }
403383 }
404- else if (is_same_command_option (arg, " --vector_store" ))
384+ else if (utils:: is_same_command_option (arg, " --vector_store" ))
405385 {
406386 c++;
407387 if (c < argc)
@@ -414,7 +394,7 @@ static size_t parse_args(Args &args, const std::vector<std::string> &argv)
414394 args.vector_stores .at (args.cur_vs_name ).push_back (argv[c]);
415395 }
416396 }
417- else if (is_same_command_option (arg, " --thought_tags" ))
397+ else if (utils:: is_same_command_option (arg, " --thought_tags" ))
418398 {
419399 if (c + 2 < argc)
420400 {
@@ -424,7 +404,7 @@ static size_t parse_args(Args &args, const std::vector<std::string> &argv)
424404 args.detect_thoughts = true ;
425405 }
426406 }
427- else if (is_same_command_option (arg, " --multimedia_file_tags" ))
407+ else if (utils:: is_same_command_option (arg, " --multimedia_file_tags" ))
428408 {
429409 if (c + 2 < argc)
430410 {
@@ -433,23 +413,23 @@ static size_t parse_args(Args &args, const std::vector<std::string> &argv)
433413 c += 2 ;
434414 }
435415 }
436- else if (is_same_command_option (arg, " --set" ))
416+ else if (utils:: is_same_command_option (arg, " --set" ))
437417 {
438418 if (c + 2 < argc)
439419 {
440420 args.additional [argv[c + 1 ]] = argv[c + 2 ];
441421 c += 2 ;
442422 }
443423 }
444- else if (is_same_command_option (arg, " -mgl" ) || is_same_command_option (arg, " --model_gpu_layers" ))
424+ else if (utils:: is_same_command_option (arg, " -mgl" ) || utils:: is_same_command_option (arg, " --model_gpu_layers" ))
445425 {
446426 if (c + 2 < argc)
447427 {
448428 args.model_n_gpu_layers [argv[c + 1 ]] = argv[c + 2 ];
449429 c += 2 ;
450430 }
451431 }
452- else if (is_same_command_option (arg, " -ngl" ) || is_same_command_option (arg, " --n_gpu_layers" ))
432+ else if (utils:: is_same_command_option (arg, " -ngl" ) || utils:: is_same_command_option (arg, " --n_gpu_layers" ))
453433 {
454434 c++;
455435 if (c < argc)
0 commit comments