@@ -48,10 +48,10 @@ class ExecuTorchLlamaCallbackJni
4848    static  auto  cls = ExecuTorchLlamaCallbackJni::javaClassStatic ();
4949    static  const  auto  method =
5050        cls->getMethod <void (facebook::jni::local_ref<jstring>)>(" onResult"  );
51-     static  std::wstring_convert<std::codecvt_utf8_utf16<char16_t >, char16_t > converter;
52-     std::u16string result_u16 = converter.from_bytes (result);
53-     __android_log_print (ANDROID_LOG_ERROR, " ExecuTorchDBG"  , " U16:%s"  , result_u16.c_str ());
54-     facebook::jni::local_ref<jstring> s = facebook::jni::make_jstring (result_u16 );
51+     //   static std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
52+     //   std::u16string result_u16 = converter.from_bytes(result);
53+     //   __android_log_print(ANDROID_LOG_ERROR, "ExecuTorchDBG", "U16:%s", result_u16.c_str());
54+     facebook::jni::local_ref<jstring> s = facebook::jni::make_jstring (result );
5555    method (self (), s);
5656  }
5757
@@ -153,12 +153,14 @@ class ExecuTorchLlamaJni
153153          [callback](const  llm::Stats& result) { callback->onStats (result); },
154154          echo);
155155    } else  if  (model_type_category_ == MODEL_TYPE_CATEGORY_LLM) {
156+       std::string my_result;
156157      runner_->generate (
157158          prompt->toStdString (),
158159          seq_len,
159-           [callback](std::string result) { callback-> onResult ( result) ; },
160+           [callback, &my_result ](std::string result) { my_result +=  result; },
160161          [callback](const  llm::Stats& result) { callback->onStats (result); },
161162          echo);
163+           callback->onResult (my_result);
162164    }
163165    return  0 ;
164166  }
0 commit comments