| 592 | } |
| 593 | |
| 594 | int main(int argc, char* argv[]) { |
| 595 | std::vector<const char*> args(argv, argv + argc); |
| 596 | std::vector<const char*> next_args; |
| 597 | |
| 598 | std::string checkpoint_dir = ""; // e.g. out/model.bin |
| 599 | // Options |
| 600 | std::string mode = "completion"; // completion, passkey, perplexity, or interactive |
| 601 | int context = 0; |
| 602 | bool lock_model_weights = false; |
| 603 | |
| 604 | if (args.size() >= 2) { |
| 605 | checkpoint_dir = args[1]; |
| 606 | } else { |
| 607 | error_usage(); |
| 608 | } |
| 609 | |
| 610 | // read in session args first, put everything else in next_args |
| 611 | for (size_t i = 2; i < args.size();) { |
| 612 | if (args[i][0] == '-' && strlen(args[i]) == 2) { |
| 613 | if (args[i][1] == 'h') { |
| 614 | error_usage(); |
| 615 | } else if (args[i][1] == 'L') { |
| 616 | lock_model_weights = true; |
| 617 | i += 1; |
| 618 | } else if (args[i][1] == 'm') { |
| 619 | if (i + 1 >= args.size()) { |
| 620 | error_usage(); |
| 621 | } |
| 622 | mode = args[i + 1]; |
| 623 | if (std::string("completion").starts_with(mode)) { |
| 624 | mode = "completion"; |
| 625 | } else if (std::string("passkey").starts_with(mode) && mode != "p") { |
| 626 | mode = "passkey"; |
| 627 | } else if (std::string("perplexity").starts_with(mode) && mode != "p") { |
| 628 | mode = "perplexity"; |
| 629 | } else if (std::string("interactive").starts_with(mode)) { |
| 630 | mode = "interactive"; |
| 631 | } else { |
| 632 | error_usage(); |
| 633 | } |
| 634 | i += 2; |
| 635 | } else if (args[i][1] == 'T') { |
| 636 | if (i + 1 >= args.size()) { |
| 637 | error_usage(); |
| 638 | } |
| 639 | context = std::stoi(args[i + 1]); |
| 640 | i += 2; |
| 641 | } else { |
| 642 | next_args.push_back(args[i]); |
| 643 | i += 1; |
| 644 | } |
| 645 | } else { |
| 646 | next_args.push_back(args[i]); |
| 647 | i += 1; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | if (mode == "completion") { |
nothing calls this directly
no test coverage detected