From ac7c5544e5d5afa02b6725e6342a5ca19368b98e Mon Sep 17 00:00:00 2001 From: jhen Date: Tue, 22 Aug 2023 13:46:45 +0800 Subject: [PATCH] fix(ios): incorrect sent_token_probs_index --- ios/RNLlamaContext.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ios/RNLlamaContext.mm b/ios/RNLlamaContext.mm index 5ca45ac..b7c23d6 100644 --- a/ios/RNLlamaContext.mm +++ b/ios/RNLlamaContext.mm @@ -227,7 +227,9 @@ - (NSDictionary *)completion:(NSDictionary *)params rnllama::STOP_PARTIAL); } - const std::string to_send = self->llama->generated_text.substr(pos, stop_pos); + const std::string to_send = stop_pos == std::string::npos ? + self->llama->generated_text.substr(pos, std::string::npos) : + ""; // just don't send anything if we're not done sent_count += to_send.size(); std::vector probs_output = {};