| 12 | } |
| 13 | |
| 14 | int main(int argc, char ** argv) { |
| 15 | std::setlocale(LC_NUMERIC, "C"); |
| 16 | |
| 17 | // path to the model gguf file |
| 18 | std::string model_path; |
| 19 | // prompt to generate text from |
| 20 | std::string prompt = "Hello my name is"; |
| 21 | // number of layers to offload to the GPU |
| 22 | int ngl = 99; |
| 23 | // number of tokens to predict |
| 24 | int n_predict = 32; |
| 25 | |
| 26 | // parse command line arguments |
| 27 | |
| 28 | { |
| 29 | int i = 1; |
| 30 | for (; i < argc; i++) { |
| 31 | if (strcmp(argv[i], "-m") == 0) { |
| 32 | if (i + 1 < argc) { |
| 33 | model_path = argv[++i]; |
| 34 | } else { |
| 35 | print_usage(argc, argv); |
| 36 | return 1; |
| 37 | } |
| 38 | } else if (strcmp(argv[i], "-n") == 0) { |
| 39 | if (i + 1 < argc) { |
| 40 | try { |
| 41 | n_predict = std::stoi(argv[++i]); |
| 42 | } catch (...) { |
| 43 | print_usage(argc, argv); |
| 44 | return 1; |
| 45 | } |
| 46 | } else { |
| 47 | print_usage(argc, argv); |
| 48 | return 1; |
| 49 | } |
| 50 | } else if (strcmp(argv[i], "-ngl") == 0) { |
| 51 | if (i + 1 < argc) { |
| 52 | try { |
| 53 | ngl = std::stoi(argv[++i]); |
| 54 | } catch (...) { |
| 55 | print_usage(argc, argv); |
| 56 | return 1; |
| 57 | } |
| 58 | } else { |
| 59 | print_usage(argc, argv); |
| 60 | return 1; |
| 61 | } |
| 62 | } else { |
| 63 | // prompt starts here |
| 64 | break; |
| 65 | } |
| 66 | } |
| 67 | if (model_path.empty()) { |
| 68 | print_usage(argc, argv); |
| 69 | return 1; |
| 70 | } |
| 71 | if (i < argc) { |
nothing calls this directly
no test coverage detected