From 8009a8ddb05597ac8b4b3db65c700fef2a425a7a Mon Sep 17 00:00:00 2001 From: Slaren <2141330+slaren@users.noreply.github.com> Date: Tue, 21 Mar 2023 04:56:47 +0100 Subject: [PATCH] Inject the reverse prompt again after eos in interactive mode --- main.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/main.cpp b/main.cpp index 5461c9e84..dd2cc160e 100644 --- a/main.cpp +++ b/main.cpp @@ -1004,7 +1004,11 @@ int main(int argc, char ** argv) { // replace end of text token with newline token when in interactive mode if (id == EOS_TOKEN_ID && params.interactive) { id = NEWLINE_TOKEN_ID; - is_interacting = true; + if (!antipromptv_inp.empty()) { + // inject the reverse prompt to return control to the user + auto& ap_inp = antipromptv_inp.front(); + embd_inp.insert(embd_inp.end(), ap_inp.begin(), ap_inp.end()); + } } // add it to the context @@ -1091,17 +1095,8 @@ int main(int argc, char ** argv) { // end of text token if (embd.back() == EOS_TOKEN_ID) { - if (params.interactive) { -// is_interacting = true; -// embd.back() = NEWLINE_TOKEN_ID; -// last_n_tokens.back() = NEWLINE_TOKEN_ID; -// if (params.antiprompt.size() != 0) { -// fprintf(stderr, "\n"); -// } - } else { - fprintf(stderr, " [end of text]\n"); - break; - } + fprintf(stderr, " [end of text]\n"); + break; } // In interactive mode, respect the maximum number of tokens and drop back to user input when reached.