From 7d9b23fcbd897a3edda69bb57dc72d7d89288a9a Mon Sep 17 00:00:00 2001 From: a-ghorbani Date: Fri, 29 Nov 2024 22:09:48 +0100 Subject: [PATCH] feat: sync llama.rn -> llama.cpp --- ios/Podfile.lock | 4 ++-- package.json | 2 +- src/store/ModelStore.ts | 18 ++++++++++++------ yarn.lock | 8 ++++---- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index d3a40db..87b5293 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -74,7 +74,7 @@ PODS: - hermes-engine/Pre-built (= 0.73.7) - hermes-engine/Pre-built (0.73.7) - libevent (2.1.12) - - llama-rn (0.3.12): + - llama-rn (0.4.3-1): - React-Core - OpenSSL-Universal (1.1.1100) - RCT-Folly (2022.05.16.00): @@ -1464,7 +1464,7 @@ SPEC CHECKSUMS: glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 hermes-engine: 39589e9c297d024e90fe68f6830ff86c4e01498a libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - llama-rn: 79f49fb25fc92ecbda076e7cb7b56fb7db6e5ab9 + llama-rn: b69b2a7416b025c262a95a1cb0e12ad8703c55fc OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0 RCTRequired: 77f73950d15b8c1a2b48ba5b79020c3003d1c9b5 diff --git a/package.json b/package.json index d31defc..908a857 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "dependencies": { "@flyerhq/react-native-link-preview": "^1.6.0", "@gorhom/bottom-sheet": "^5.0.5", - "@pocketpalai/llama.rn": "^0.3.12", + "@pocketpalai/llama.rn": "0.4.3-1", "@react-native-async-storage/async-storage": "^1.23.1", "@react-native-clipboard/clipboard": "^1.14.0", "@react-native-community/blur": "^4.4.1", diff --git a/src/store/ModelStore.ts b/src/store/ModelStore.ts index 5ec9ec6..27cbf8b 100644 --- a/src/store/ModelStore.ts +++ b/src/store/ModelStore.ts @@ -552,12 +552,18 @@ class ModelStore { this.loadingModel = model; }); try { - const ctx = await initLlama({ - model: filePath, - use_mlock: true, - n_ctx: this.n_context, - n_gpu_layers: this.useMetal ? this.n_gpu_layers : 0, // Set as needed, 0 for no GPU // TODO ggml-metal.metal - }); + const ctx = await initLlama( + { + model: filePath, + use_mlock: true, + n_ctx: this.n_context, + n_gpu_layers: this.useMetal ? this.n_gpu_layers : 0, // Set as needed, 0 for no GPU // TODO ggml-metal.metal + use_progress_callback: true, + }, + (_progress: number) => { + //console.log('progress: ', _progress); + }, + ); // Get stop token from the model and add to the list of stop tokens. const eos_token_id = Number( diff --git a/yarn.lock b/yarn.lock index e152531..90cc0a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1738,10 +1738,10 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== -"@pocketpalai/llama.rn@^0.3.12": - version "0.3.12" - resolved "https://registry.yarnpkg.com/@pocketpalai/llama.rn/-/llama.rn-0.3.12.tgz#378bdff95b87a49eccaac2bef368c5ed4c1511e8" - integrity sha512-1nEwiiXlfA5M1JOeokhtXe1jC2mxyNKD5l973Q8cnT67BwDJjsAPQtozqXC17CaxjLiuSfD42ypf1qYf4KMyCg== +"@pocketpalai/llama.rn@0.4.3-1": + version "0.4.3-1" + resolved "https://registry.yarnpkg.com/@pocketpalai/llama.rn/-/llama.rn-0.4.3-1.tgz#e8e965b55effd9071f900b7dac25396fff9b34b9" + integrity sha512-7L7gou7m91s3fAP9jlKf17De86XRyLUSEw1RTopmSQKuengZHxWcgMESCLIT5y6/u69IzlM6DVjrQUsBb0Om9A== "@react-native-async-storage/async-storage@^1.23.1": version "1.24.0"