Treat empty line input as "no input"

Do not insert a "newline" token if user inputs empty line. This let's
user to continue the output after she has been asked by reverse prompt
for more data. Otherwise an empty-line input would insert a "newline"
token which would break the flow of the conversation.
This commit is contained in:
Jakub Horak 2023-03-26 16:50:02 +02:00
parent b391579db9
commit 35e76863db

View file

@ -465,14 +465,19 @@ int main(int argc, char ** argv) {
// done taking input, reset color
set_console_state(CONSOLE_STATE_DEFAULT);
auto line_inp = ::llama_tokenize(ctx, buffer, false);
embd_inp.insert(embd_inp.end(), line_inp.begin(), line_inp.end());
// Add tokens to buffer only if the line is non-empty.
// This let's the user make the chat continue if it was stopped
// on a reverse prompt.
if (buffer.length() > 1) {
auto line_inp = ::llama_tokenize(ctx, buffer, false);
embd_inp.insert(embd_inp.end(), line_inp.begin(), line_inp.end());
if (params.instruct) {
embd_inp.insert(embd_inp.end(), inp_sfx.begin(), inp_sfx.end());
}
if (params.instruct) {
embd_inp.insert(embd_inp.end(), inp_sfx.begin(), inp_sfx.end());
}
n_remain -= line_inp.size();
n_remain -= line_inp.size();
}
input_noecho = true; // do not echo this again
}