Add means to exit interactive mode

This commit is contained in:
changhz 2023-05-22 08:28:25 -04:00
parent 7e4ea5beff
commit 47e41fa8ce

View file

@ -549,6 +549,9 @@ int main(int argc, char ** argv) {
bool another_line = true; bool another_line = true;
do { do {
another_line = console_readline(con_st, line); another_line = console_readline(con_st, line);
if (!line.compare("/exit\n")) {
goto out_of_main_loop;
}
buffer += line; buffer += line;
} while (another_line); } while (another_line);
@ -604,8 +607,9 @@ int main(int argc, char ** argv) {
n_remain = params.n_predict; n_remain = params.n_predict;
is_interacting = true; is_interacting = true;
} }
} } // end while
out_of_main_loop:
if (!path_session.empty() && params.prompt_cache_all) { if (!path_session.empty() && params.prompt_cache_all) {
fprintf(stderr, "\n%s: saving final output to session file '%s'\n", __func__, path_session.c_str()); fprintf(stderr, "\n%s: saving final output to session file '%s'\n", __func__, path_session.c_str());
llama_save_session_file(ctx, path_session.c_str(), session_tokens.data(), session_tokens.size()); llama_save_session_file(ctx, path_session.c_str(), session_tokens.data(), session_tokens.size());