MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / common_params_print_completion

Function common_params_print_completion

smallthinker/common/arg.cpp:1035–1136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1033}
1034
1035static void common_params_print_completion(common_params_context & ctx_arg) {
1036 std::vector<common_arg *> common_options;
1037 std::vector<common_arg *> sparam_options;
1038 std::vector<common_arg *> specific_options;
1039
1040 for (auto & opt : ctx_arg.options) {
1041 if (opt.is_sparam) {
1042 sparam_options.push_back(&opt);
1043 } else if (opt.in_example(ctx_arg.ex)) {
1044 specific_options.push_back(&opt);
1045 } else {
1046 common_options.push_back(&opt);
1047 }
1048 }
1049
1050 printf("_llama_completions() {\n");
1051 printf(" local cur prev opts\n");
1052 printf(" COMPREPLY=()\n");
1053 printf(" cur=\"${COMP_WORDS[COMP_CWORD]}\"\n");
1054 printf(" prev=\"${COMP_WORDS[COMP_CWORD-1]}\"\n\n");
1055
1056 printf(" opts=\"");
1057 auto print_options = [](const std::vector<common_arg *> & options) {
1058 for (const common_arg * opt : options) {
1059 for (const char * arg : opt->args) {
1060 printf("%s ", arg);
1061 }
1062 }
1063 };
1064
1065 print_options(common_options);
1066 print_options(sparam_options);
1067 print_options(specific_options);
1068 printf("\"\n\n");
1069
1070 printf(" case \"$prev\" in\n");
1071 printf(" --model)\n");
1072 printf(" COMPREPLY=( $(compgen -f -X '!*.gguf' -- \"$cur\") $(compgen -d -- \"$cur\") )\n");
1073 printf(" return 0\n");
1074 printf(" ;;\n");
1075 printf(" --grammar-file)\n");
1076 printf(" COMPREPLY=( $(compgen -f -X '!*.gbnf' -- \"$cur\") $(compgen -d -- \"$cur\") )\n");
1077 printf(" return 0\n");
1078 printf(" ;;\n");
1079 printf(" --chat-template-file)\n");
1080 printf(" COMPREPLY=( $(compgen -f -X '!*.jinja' -- \"$cur\") $(compgen -d -- \"$cur\") )\n");
1081 printf(" return 0\n");
1082 printf(" ;;\n");
1083 printf(" *)\n");
1084 printf(" COMPREPLY=( $(compgen -W \"${opts}\" -- \"$cur\") )\n");
1085 printf(" return 0\n");
1086 printf(" ;;\n");
1087 printf(" esac\n");
1088 printf("}\n\n");
1089
1090 std::set<std::string> executables = {
1091 "llama-batched",
1092 "llama-batched-bench",

Callers 1

common_params_parseFunction · 0.85

Calls 4

printfFunction · 0.85
in_exampleMethod · 0.80
push_backMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected