| 1635 | printf("Thinking mode: %s.\n", active ? "max" : "high (ctx below 393216)"); |
| 1636 | } else if (!strcmp(cmd, "/nothink")) { |
| 1637 | cfg->gen.think_mode = DS4_THINK_NONE; |
| 1638 | repl_chat_apply_think_prefix(engine, &chat, DS4_THINK_NONE); |
| 1639 | puts("Thinking mode: none."); |
| 1640 | } else if (!strncmp(cmd, "/power", 6) && (cmd[6] == '\0' || isspace((unsigned char)cmd[6]))) { |
| 1641 | char *arg = trim_inplace(cmd + 6); |
| 1642 | if (!arg[0]) { |
| 1643 | printf("Power: %d%%.\n", ds4_session_power(chat.session)); |
| 1644 | } else { |
| 1645 | int power = 0; |
| 1646 | if (!parse_power_percent(arg, &power)) { |
| 1647 | fprintf(stderr, "ds4: /power must be between 1 and 100\n"); |
| 1648 | } else if (ds4_session_set_power(chat.session, power) != 0) { |
| 1649 | fprintf(stderr, "ds4: failed to set /power\n"); |
| 1650 | } else { |
| 1651 | cfg->engine.power_percent = power; |
| 1652 | printf("Power: %d%%.\n", power); |
| 1653 | } |
| 1654 | } |
| 1655 | } else if (!strncmp(cmd, "/ctx", 4) && (cmd[4] == '\0' || isspace((unsigned char)cmd[4]))) { |
| 1656 | char *arg = trim_inplace(cmd + 4); |
| 1657 | if (!arg[0]) { |
| 1658 | fprintf(stderr, "ds4: /ctx needs a positive integer\n"); |
| 1659 | } else { |
| 1660 | cfg->gen.ctx_size = parse_int(arg, "/ctx"); |
| 1661 | log_context_memory(cfg->engine.backend, |
| 1662 | cfg->gen.ctx_size, |
| 1663 | ds4_engine_prefill_chunk(engine), |
| 1664 | cfg->engine.ssd_streaming); |
| 1665 | rc = repl_chat_set_ctx(engine, &chat, cfg->gen.ctx_size); |
| 1666 | if (rc != 0) { |
| 1667 | linenoiseFree(line); |
| 1668 | break; |
| 1669 | } |
| 1670 | ds4_think_mode effective = ds4_think_mode_for_context(cfg->gen.think_mode, |
| 1671 | chat.ctx_size); |
| 1672 | repl_chat_apply_think_prefix(engine, &chat, effective); |
| 1673 | cli_warn_think_max_downgraded(&cfg->gen, "/ctx"); |
| 1674 | } |
| 1675 | } else if (!strcmp(cmd, "/quit") || !strcmp(cmd, "/exit")) { |
| 1676 | linenoiseFree(line); |
| 1677 | break; |
| 1678 | } else if (!strncmp(cmd, "/read", 5) && (cmd[5] == '\0' || isspace((unsigned char)cmd[5]))) { |
| 1679 | char *path = trim_inplace(cmd + 5); |
| 1680 | if (!path[0]) { |
| 1681 | fprintf(stderr, "ds4: /read needs a file path\n"); |
| 1682 | } else { |
| 1683 | char *prompt = read_prompt_file(path, false); |
| 1684 | if (prompt) { |
| 1685 | rc = run_chat_turn(engine, cfg, &chat, prompt); |
| 1686 | free(prompt); |
| 1687 | } |
| 1688 | } |
| 1689 | } else if (cmd[0] == '/') { |
| 1690 | fprintf(stderr, "ds4: unknown command: %s\n", cmd); |
| 1691 | fprintf(stderr, "ds4: type /help for commands\n"); |
| 1692 | } else { |
| 1693 | rc = run_chat_turn(engine, cfg, &chat, cmd); |
| 1694 | } |
nothing calls this directly
no test coverage detected