\brief Run the runner
| 130 | |
| 131 | /// \brief Run the runner |
| 132 | void Runner::run() { |
| 133 | bool verbose = false; |
| 134 | this->system_prompt = ""; |
| 135 | this->auto_chat_engine->configure_parameter("system_prompt", this->system_prompt); |
| 136 | std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8conv; |
| 137 | wstream_buf obuf(std::cout); |
| 138 | std::ostream base_ostream(&obuf); |
| 139 | header_print("FLM", "Type /? for help"); |
| 140 | int empty_line_count = 0; |
| 141 | bool is_image = false; |
| 142 | bytes image; |
| 143 | while (true) { |
| 144 | std::string input = cli.get_interactive_input(); |
| 145 | is_image = false; |
| 146 | if (input.empty()) { |
| 147 | empty_line_count++; |
| 148 | if (empty_line_count > 2) { |
| 149 | header_print("FLM", "Type /? for help"); |
| 150 | empty_line_count = 0; |
| 151 | } |
| 152 | continue; |
| 153 | } |
| 154 | |
| 155 | // Convert line (UTF-8 bytes) → wide string (Unicode codepoints) |
| 156 | std::wstring winput = utf8conv.from_bytes(input); |
| 157 | |
| 158 | // Split on *any* Unicode whitespace |
| 159 | std::wistringstream wiss(winput); |
| 160 | std::wstring wtoken; |
| 161 | std::vector<std::string> input_list; |
| 162 | std::cout << std::endl; |
| 163 | |
| 164 | while (wiss >> wtoken) { |
| 165 | // Convert each token back → UTF-8 bytes |
| 166 | input_list.push_back(utf8conv.to_bytes(wtoken)); |
| 167 | } |
| 168 | |
| 169 | // now input_list contains your UTF-8 tokens |
| 170 | if (input_list.empty()) { |
| 171 | continue; |
| 172 | } |
| 173 | |
| 174 | // For commands, we only need to check the first token |
| 175 | std::string first_token = input_list[0]; |
| 176 | |
| 177 | |
| 178 | // Check if this is a command (starts with /) |
| 179 | bool is_command = (first_token[0] == '/'); |
| 180 | |
| 181 | if (is_command && first_token != "/input") { |
| 182 | if (first_token == "/bye") { |
| 183 | break; |
| 184 | } |
| 185 | else if (first_token == "/clear") { |
| 186 | this->cmd_clear(input_list); |
| 187 | } |
| 188 | else if (first_token == "/status") { |
| 189 | this->cmd_status(input_list); |
no test coverage detected