Skip to content

Commit 1cf14cc

Browse files
authored
fix server crashes (#2076)
1 parent cc45a7f commit 1cf14cc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/server/server.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ int main(int argc, char ** argv) {
906906

907907
while (llama.has_next_token) {
908908
const completion_token_output token_with_probs = llama.doCompletion();
909-
const std::string token_text = llama_token_to_str(llama.ctx, token_with_probs.tok);
909+
const std::string token_text = token_with_probs.tok == -1 ? "" : llama_token_to_str(llama.ctx, token_with_probs.tok);
910910

911911
stop_pos = llama.findStoppingStrings(llama.generated_text,
912912
token_text.size(), STOP_FULL);
@@ -933,7 +933,7 @@ int main(int argc, char ** argv) {
933933

934934
while (llama.has_next_token) {
935935
const completion_token_output token_with_probs = llama.doCompletion();
936-
const std::string token_text = llama_token_to_str(llama.ctx, token_with_probs.tok);
936+
const std::string token_text = token_with_probs.tok == -1 ? "" : llama_token_to_str(llama.ctx, token_with_probs.tok);
937937
if (llama.multibyte_pending > 0) {
938938
continue;
939939
}

0 commit comments

Comments
 (0)