From: devojony Date: Mon, 22 Jul 2024 06:54:42 +0000 (+0800) Subject: examples: fix android example cannot be generated continuously (#8621) X-Git-Tag: upstream/0.0.4488~1054 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=b7c11d36e605b35206901d0e21905f1b99508e33;p=pkg%2Fggml%2Fsources%2Fllama.cpp examples: fix android example cannot be generated continuously (#8621) When generation ends `completion_loop()` should return a NULL, not the empty string --- diff --git a/examples/llama.android/llama/src/main/cpp/llama-android.cpp b/examples/llama.android/llama/src/main/cpp/llama-android.cpp index 92a6b16b..2aafe231 100644 --- a/examples/llama.android/llama/src/main/cpp/llama-android.cpp +++ b/examples/llama.android/llama/src/main/cpp/llama-android.cpp @@ -409,7 +409,7 @@ Java_android_llama_cpp_LLamaAndroid_completion_1loop( const auto n_cur = env->CallIntMethod(intvar_ncur, la_int_var_value); if (llama_token_is_eog(model, new_token_id) || n_cur == n_len) { - return env->NewStringUTF(""); + return nullptr; } auto new_token_chars = llama_token_to_piece(context, new_token_id);