From 725117cb02fea85a7540008a68c55528f50391cb Mon Sep 17 00:00:00 2001 From: jhen Date: Fri, 26 Apr 2024 18:06:27 +0800 Subject: [PATCH] feat: migrate to new session API --- android/src/main/jni.cpp | 4 ++-- ios/RNLlamaContext.mm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/src/main/jni.cpp b/android/src/main/jni.cpp index 68d6231f..558eeb60 100644 --- a/android/src/main/jni.cpp +++ b/android/src/main/jni.cpp @@ -231,7 +231,7 @@ Java_com_rnllama_LlamaContext_loadSession( auto result = createWriteableMap(env); size_t n_token_count_out = 0; llama->embd.resize(llama->params.n_ctx); - if (!llama_load_session_file(llama->ctx, path_chars, llama->embd.data(), llama->embd.capacity(), &n_token_count_out)) { + if (!llama_state_load_file(llama->ctx, path_chars, llama->embd.data(), llama->embd.capacity(), &n_token_count_out)) { env->ReleaseStringUTFChars(path, path_chars); putString(env, result, "error", "Failed to load session"); @@ -262,7 +262,7 @@ Java_com_rnllama_LlamaContext_saveSession( std::vector session_tokens = llama->embd; int default_size = session_tokens.size(); int save_size = size > 0 && size <= default_size ? size : default_size; - if (!llama_save_session_file(llama->ctx, path_chars, session_tokens.data(), save_size)) { + if (!llama_state_save_file(llama->ctx, path_chars, session_tokens.data(), save_size)) { env->ReleaseStringUTFChars(path, path_chars); return -1; } diff --git a/ios/RNLlamaContext.mm b/ios/RNLlamaContext.mm index fb912d73..58819f2a 100644 --- a/ios/RNLlamaContext.mm +++ b/ios/RNLlamaContext.mm @@ -390,7 +390,7 @@ - (NSDictionary *)loadSession:(NSString *)path { size_t n_token_count_out = 0; llama->embd.resize(llama->params.n_ctx); - if (!llama_load_session_file(llama->ctx, [path UTF8String], llama->embd.data(), llama->embd.capacity(), &n_token_count_out)) { + if (!llama_state_load_file(llama->ctx, [path UTF8String], llama->embd.data(), llama->embd.capacity(), &n_token_count_out)) { @throw [NSException exceptionWithName:@"LlamaException" reason:@"Failed to load session" userInfo:nil]; } llama->embd.resize(n_token_count_out); @@ -408,7 +408,7 @@ - (int)saveSession:(NSString *)path size:(int)size { std::vector session_tokens = llama->embd; int default_size = session_tokens.size(); int save_size = size > 0 && size <= default_size ? size : default_size; - if (!llama_save_session_file(llama->ctx, [path UTF8String], session_tokens.data(), save_size)) { + if (!llama_state_save_file(llama->ctx, [path UTF8String], session_tokens.data(), save_size)) { @throw [NSException exceptionWithName:@"LlamaException" reason:@"Failed to save session" userInfo:nil]; } return session_tokens.size();