]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Fix for main example getting stuck when -n -2 and --interactive (#2767)
authorKerfuffle <redacted>
Thu, 24 Aug 2023 16:11:13 +0000 (10:11 -0600)
committerGitHub <redacted>
Thu, 24 Aug 2023 16:11:13 +0000 (10:11 -0600)
* Fix for main example getting stuck when -n -2 and --interactive

* Add a comment so future generations may suffer less.

examples/main/main.cpp

index 1393f0b084a2116ee2dff3a806df1a1a258e7010..cb8747c2b74f1728049ad4a6b2f2cd6761a2b199 100644 (file)
@@ -798,7 +798,8 @@ int main(int argc, char ** argv) {
         }
 
         // In interactive mode, respect the maximum number of tokens and drop back to user input when reached.
-        if (params.interactive && n_remain <= 0 && params.n_predict != -1) {
+        // We skip this logic when n_predict == -1 (infinite) or -2 (stop at context size).
+        if (params.interactive && n_remain <= 0 && params.n_predict >= 0) {
             n_remain = params.n_predict;
             is_interacting = true;
         }