is_interacting = true;
}
+ // set the color for the prompt which will be output initially
if (params.use_color) {
printf(ANSI_COLOR_YELLOW);
}
embd.clear();
if (embd_inp.size() <= input_consumed) {
- // out of input, sample next token
+ // out of user input, sample next token
const float top_k = params.top_k;
const float top_p = params.top_p;
const float temp = params.temp;
// decrement remaining sampling budget
--remaining_tokens;
} else {
- // if here, it means we are still processing the input prompt
+ // some user input remains from prompt or interaction, forward it to processing
while (embd_inp.size() > input_consumed) {
embd.push_back(embd_inp[input_consumed]);
last_n_tokens.erase(last_n_tokens.begin());
break;
}
}
-
- if (params.use_color && embd_inp.size() <= input_consumed) {
- printf(ANSI_COLOR_RESET);
- }
}
// display text
for (auto id : embd) {
printf("%s", vocab.id_to_token[id].c_str());
}
+ // reset color to default if we there is no pending user input
+ if (params.use_color && embd_inp.size() <= input_consumed) {
+ printf(ANSI_COLOR_RESET);
+ }
fflush(stdout);
}