From 530eb57fe4772bb2d8063c80bddee34ae6365d00 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 29 May 2023 08:37:34 +0800 Subject: [PATCH] fix the error of no ending --- examples/grpc-server/grpc-server.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/grpc-server/grpc-server.cpp b/examples/grpc-server/grpc-server.cpp index 4a9f3a05b..914a559f0 100644 --- a/examples/grpc-server/grpc-server.cpp +++ b/examples/grpc-server/grpc-server.cpp @@ -220,7 +220,7 @@ public: bool loadPrompt(std::string prompt) { // prompt.insert(0, " Below is an instruction that describes a task. Write a response that appropriately completes the request.\n"); // always add a first space - prompt.insert(0, 1, ' '); // always add a first space + prompt.insert(0, 1, ' '); // always add a first space std::vector prompt_tokens = ::llama_tokenize(ctx, prompt, true); // compare the evaluated prompt with the new prompt int new_prompt_len = 0; @@ -455,12 +455,14 @@ public: { has_next_token = false; } - - if (params.interactive && n_remain <= 0 && params.n_predict != -1) + else { - n_remain = params.n_predict; + if (params.interactive && n_remain <= 0 && params.n_predict != -1) + { + n_remain = params.n_predict; + } + has_next_token = n_remain != 0; } - has_next_token = n_remain != 0; return result; }