Never exit the main loop in interactive mode.
If the end of stream token mark is found, when in interactive mode, ask for user input instead of exiting the main loop. In case of running out of token budget, reset it and ask for user input. With these changes, embd can end up empty and cause a crash in the next iteration of the loop, so we check for its size as well.
This commit is contained in:
parent
d7def1a752
commit
bb5e8ec79a
1 changed files with 14 additions and 4 deletions
18
main.cpp
18
main.cpp
|
@ -1035,10 +1035,20 @@ int main(int argc, char ** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// end of text token
|
if (params.interactive) {
|
||||||
if (embd.back() == 2) {
|
if (embd.size() && embd.back() == 2) {
|
||||||
fprintf(stderr, " [end of text]\n");
|
is_interacting = true;
|
||||||
break;
|
}
|
||||||
|
if (remaining_tokens == 0) {
|
||||||
|
remaining_tokens = params.n_predict;
|
||||||
|
is_interacting = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// end of text token
|
||||||
|
if (embd.size() && embd.back() == 2) {
|
||||||
|
fprintf(stderr, " [end of text]\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue