Skip to content

Add exit call to interactive mode. #910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ static console_state con_st;

static bool is_interacting = false;

llama_context * ctx;

#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) || defined (_WIN32)
void sigint_handler(int signo) {
set_console_color(con_st, CONSOLE_COLOR_DEFAULT);
Expand All @@ -35,6 +37,9 @@ void sigint_handler(int signo) {
if (!is_interacting) {
is_interacting=true;
} else {
//printf("Exit call given, printing stats and exiting.\n");
llama_print_timings(ctx);
llama_free(ctx);
_exit(130);
}
}
Expand Down Expand Up @@ -92,8 +97,6 @@ int main(int argc, char ** argv) {
// params.prompt = R"(// this function checks if the number n is prime
//bool is_prime(int n) {)";

llama_context * ctx;

// load the model
{
auto lparams = llama_context_default_params();
Expand Down