Skip to content

Commit d8bc930

Browse files
committed
skip -1 tok in loop to avoid send '' on end
1 parent 343be7f commit d8bc930

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/server/server.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,13 @@ int main(int argc, char **argv)
13221322

13231323
while (llama.has_next_token) {
13241324
const completion_token_output token_with_probs = llama.doCompletion();
1325-
const std::string token_text = token_with_probs.tok == -1 ? "" : llama_token_to_str(llama.ctx, token_with_probs.tok);
1326-
if (llama.multibyte_pending > 0) {
1325+
if (
1326+
token_with_probs.tok == -1 ||
1327+
sent_count == llama.generated_text.size()
1328+
) {
13271329
continue;
13281330
}
1331+
const std::string token_text = llama_token_to_str(llama.ctx, token_with_probs.tok);
13291332

13301333
size_t pos = std::min(sent_count, llama.generated_text.size());
13311334

0 commit comments

Comments
 (0)