cactus-react-native 0.2.11 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cactus.podspec +34 -0
- package/LICENSE +38 -0
- package/README.md +550 -69
- package/android/CMakeLists.txt +40 -0
- package/android/build.gradle +68 -44
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/cactus/CactusPackage.kt +22 -0
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +38 -0
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +24 -0
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusFileSystem.kt +227 -0
- package/android/src/main/jniLibs/arm64-v8a/{libcactus_v8.so → libcactus.a} +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_util.so +0 -0
- package/cpp/HybridCactus.cpp +135 -0
- package/cpp/HybridCactus.hpp +42 -0
- package/cpp/HybridCactusUtil.cpp +47 -0
- package/cpp/HybridCactusUtil.hpp +26 -0
- package/cpp/cactus_ffi.h +55 -0
- package/cpp/cactus_util.h +25 -0
- package/ios/HybridCactusCrypto.swift +37 -0
- package/ios/HybridCactusDeviceInfo.swift +32 -0
- package/ios/HybridCactusFileSystem.swift +234 -0
- package/ios/cactus.xcframework/{info.plist → Info.plist} +2 -37
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +8 -229
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +28 -229
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +545 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ffi_utils.h +400 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +338 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +275 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +343 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +11 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +55 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +545 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/ffi_utils.h +400 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +338 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +275 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +343 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/{tvos-arm64_x86_64-simulator → ios-arm64-simulator}/cactus.framework/_CodeSignature/CodeResources +1 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
- package/ios/cactus_util.xcframework/Info.plist +39 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +25 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +10 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +25 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +25 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +10 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +25 -0
- package/ios/{cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework → cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework}/Info.plist +0 -0
- package/ios/{cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework → cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework}/_CodeSignature/CodeResources +36 -2
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
- package/lib/module/api/Database.js +60 -0
- package/lib/module/api/Database.js.map +1 -0
- package/lib/module/classes/CactusLM.js +151 -0
- package/lib/module/classes/CactusLM.js.map +1 -0
- package/lib/module/config/CactusConfig.js +6 -0
- package/lib/module/config/CactusConfig.js.map +1 -0
- package/lib/module/constants/packageVersion.js +4 -0
- package/lib/module/constants/packageVersion.js.map +1 -0
- package/lib/module/hooks/useCactusLM.js +238 -0
- package/lib/module/hooks/useCactusLM.js.map +1 -0
- package/lib/module/index.js +9 -409
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/Cactus.js +50 -0
- package/lib/module/native/Cactus.js.map +1 -0
- package/lib/module/native/CactusCrypto.js +10 -0
- package/lib/module/native/CactusCrypto.js.map +1 -0
- package/lib/module/native/CactusDeviceInfo.js +13 -0
- package/lib/module/native/CactusDeviceInfo.js.map +1 -0
- package/lib/module/native/CactusFileSystem.js +35 -0
- package/lib/module/native/CactusFileSystem.js.map +1 -0
- package/lib/module/native/CactusUtil.js +23 -0
- package/lib/module/native/CactusUtil.js.map +1 -0
- package/lib/module/native/index.js +8 -0
- package/lib/module/native/index.js.map +1 -0
- package/lib/module/specs/Cactus.nitro.js +4 -0
- package/lib/module/specs/Cactus.nitro.js.map +1 -0
- package/lib/module/specs/CactusCrypto.nitro.js +4 -0
- package/lib/module/specs/CactusCrypto.nitro.js.map +1 -0
- package/lib/module/specs/CactusDeviceInfo.nitro.js +4 -0
- package/lib/module/specs/CactusDeviceInfo.nitro.js.map +1 -0
- package/lib/module/specs/CactusFileSystem.nitro.js +4 -0
- package/lib/module/specs/CactusFileSystem.nitro.js.map +1 -0
- package/lib/module/specs/CactusUtil.nitro.js +4 -0
- package/lib/module/specs/CactusUtil.nitro.js.map +1 -0
- package/lib/module/telemetry/Telemetry.js +100 -0
- package/lib/module/telemetry/Telemetry.js.map +1 -0
- package/lib/module/types/CactusLM.js +2 -0
- package/lib/module/types/CactusLM.js.map +1 -0
- package/lib/module/types/CactusModel.js +2 -0
- package/lib/module/types/CactusModel.js.map +1 -0
- package/lib/module/utils/error.js +4 -0
- package/lib/module/utils/error.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/api/Database.d.ts +11 -0
- package/lib/typescript/src/api/Database.d.ts.map +1 -0
- package/lib/typescript/src/classes/CactusLM.d.ts +26 -0
- package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -0
- package/lib/typescript/src/config/CactusConfig.d.ts +5 -0
- package/lib/typescript/src/config/CactusConfig.d.ts.map +1 -0
- package/lib/typescript/src/constants/packageVersion.d.ts +2 -0
- package/lib/typescript/src/constants/packageVersion.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCactusLM.d.ts +20 -0
- package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native/Cactus.d.ts +11 -0
- package/lib/typescript/src/native/Cactus.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusCrypto.d.ts +5 -0
- package/lib/typescript/src/native/CactusCrypto.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts +7 -0
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusFileSystem.d.ts +13 -0
- package/lib/typescript/src/native/CactusFileSystem.d.ts.map +1 -0
- package/lib/typescript/src/native/CactusUtil.d.ts +6 -0
- package/lib/typescript/src/native/CactusUtil.d.ts.map +1 -0
- package/lib/typescript/src/native/index.d.ts +6 -0
- package/lib/typescript/src/native/index.d.ts.map +1 -0
- package/lib/typescript/src/specs/Cactus.nitro.d.ts +13 -0
- package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +8 -0
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +16 -0
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts +16 -0
- package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +10 -0
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +1 -0
- package/lib/typescript/src/telemetry/Telemetry.d.ts +30 -0
- package/lib/typescript/src/telemetry/Telemetry.d.ts.map +1 -0
- package/lib/typescript/src/types/CactusLM.d.ts +67 -0
- package/lib/typescript/src/types/CactusLM.d.ts.map +1 -0
- package/lib/typescript/src/types/CactusModel.d.ts +12 -0
- package/lib/typescript/src/types/CactusModel.d.ts.map +1 -0
- package/lib/typescript/src/utils/error.d.ts +2 -0
- package/lib/typescript/src/utils/error.d.ts.map +1 -0
- package/nitro.json +31 -0
- package/nitrogen/generated/android/c++/JDeviceInfo.hpp +74 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +74 -0
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +65 -0
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +85 -0
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.cpp +192 -0
- package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.hpp +73 -0
- package/nitrogen/generated/android/cactus+autolinking.cmake +87 -0
- package/nitrogen/generated/android/cactus+autolinking.gradle +27 -0
- package/nitrogen/generated/android/cactusOnLoad.cpp +86 -0
- package/nitrogen/generated/android/cactusOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusFileSystemSpec.kt +95 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/cactusOnLoad.kt +35 -0
- package/nitrogen/generated/ios/Cactus+autolinking.rb +60 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +122 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +373 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +60 -0
- package/nitrogen/generated/ios/CactusAutolinking.mm +69 -0
- package/nitrogen/generated/ios/CactusAutolinking.swift +55 -0
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +77 -0
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +88 -0
- package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.hpp +143 -0
- package/nitrogen/generated/ios/swift/DeviceInfo.swift +98 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +139 -0
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +164 -0
- package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec.swift +65 -0
- package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec_cxx.swift +303 -0
- package/nitrogen/generated/shared/c++/DeviceInfo.hpp +92 -0
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +67 -0
- package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.hpp +73 -0
- package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +66 -0
- package/package.json +84 -143
- package/src/api/Database.ts +83 -0
- package/src/classes/CactusLM.ts +205 -0
- package/src/config/CactusConfig.ts +4 -0
- package/src/constants/packageVersion.ts +1 -0
- package/src/hooks/useCactusLM.ts +285 -0
- package/src/index.tsx +23 -0
- package/src/native/Cactus.ts +83 -0
- package/src/native/CactusCrypto.ts +11 -0
- package/src/native/CactusDeviceInfo.ts +18 -0
- package/src/native/CactusFileSystem.ts +47 -0
- package/src/native/CactusUtil.ts +27 -0
- package/src/native/index.ts +5 -0
- package/src/specs/Cactus.nitro.ts +20 -0
- package/src/specs/CactusCrypto.nitro.ts +6 -0
- package/src/specs/CactusDeviceInfo.nitro.ts +15 -0
- package/src/specs/CactusFileSystem.nitro.ts +21 -0
- package/src/specs/CactusUtil.nitro.ts +8 -0
- package/src/telemetry/Telemetry.ts +159 -0
- package/src/types/CactusLM.ts +73 -0
- package/src/types/CactusModel.ts +14 -0
- package/src/utils/error.ts +2 -0
- package/LICENSE.txt +0 -20
- package/android/src/main/CMakeLists.txt +0 -140
- package/android/src/main/java/com/cactus/Cactus.java +0 -1190
- package/android/src/main/java/com/cactus/CactusPackage.java +0 -48
- package/android/src/main/java/com/cactus/LlamaContext.java +0 -748
- package/android/src/main/jni-utils.h +0 -100
- package/android/src/main/jni.cpp +0 -1605
- package/android/src/main/jniLibs/arm64-v8a/libcactus.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_dotprod.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_dotprod_i8mm.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_i8mm.so +0 -0
- package/android/src/newarch/java/com/cactus/CactusModule.java +0 -204
- package/android/src/oldarch/java/com/cactus/CactusModule.java +0 -205
- package/cactus-react-native.podspec +0 -42
- package/ios/CMakeLists.txt +0 -131
- package/ios/Cactus.h +0 -6
- package/ios/Cactus.mm +0 -681
- package/ios/CactusContext.h +0 -81
- package/ios/CactusContext.mm +0 -1032
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/chat.h +0 -145
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/common.h +0 -674
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-alloc.h +0 -76
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-backend-impl.h +0 -255
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-backend.h +0 -354
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-common.h +0 -1857
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-cpp.h +0 -39
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-cpu.h +0 -143
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-impl.h +0 -601
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-metal-impl.h +0 -622
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-metal.h +0 -66
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-opt.h +0 -237
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-quants.h +0 -100
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-threading.h +0 -14
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml.h +0 -2202
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/gguf.h +0 -202
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/json.hpp +0 -24766
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-adapter.h +0 -76
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-arch.h +0 -437
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-batch.h +0 -89
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-chat.h +0 -58
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-context.h +0 -276
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-cparams.h +0 -39
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-cpp.h +0 -30
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-grammar.h +0 -173
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-graph.h +0 -640
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-hparams.h +0 -190
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-impl.h +0 -61
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-io.h +0 -35
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-kv-cache.h +0 -515
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-memory.h +0 -32
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-mmap.h +0 -68
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model-loader.h +0 -169
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model-saver.h +0 -37
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model.h +0 -425
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-sampling.h +0 -32
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-vocab.h +0 -131
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama.h +0 -1376
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/log.h +0 -103
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/minja/chat-template.hpp +0 -542
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/minja/minja.hpp +0 -2974
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/sampling.h +0 -107
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/unicode-data.h +0 -20
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/unicode.h +0 -66
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/ggml-llama.metallib +0 -0
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/cactus.h +0 -232
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/cactus_ffi.h +0 -256
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/chat.h +0 -145
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/common.h +0 -674
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-alloc.h +0 -76
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend-impl.h +0 -255
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend.h +0 -354
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-common.h +0 -1857
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpp.h +0 -39
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpu.h +0 -143
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-impl.h +0 -601
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal-impl.h +0 -622
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal.h +0 -66
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-opt.h +0 -237
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-quants.h +0 -100
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-threading.h +0 -14
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml.h +0 -2202
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/gguf.h +0 -202
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/json.hpp +0 -24766
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-adapter.h +0 -76
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-arch.h +0 -437
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-batch.h +0 -89
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-chat.h +0 -58
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-context.h +0 -276
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-cparams.h +0 -39
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-cpp.h +0 -30
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-grammar.h +0 -173
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-graph.h +0 -640
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-hparams.h +0 -190
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-impl.h +0 -61
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-io.h +0 -35
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-kv-cache.h +0 -515
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-memory.h +0 -32
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-mmap.h +0 -68
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-loader.h +0 -169
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-saver.h +0 -37
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model.h +0 -425
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-sampling.h +0 -32
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-vocab.h +0 -131
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama.h +0 -1376
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/log.h +0 -103
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/minja/chat-template.hpp +0 -542
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/minja/minja.hpp +0 -2974
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/sampling.h +0 -107
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/unicode-data.h +0 -20
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/unicode.h +0 -66
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/ggml-llama-sim.metallib +0 -0
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/cactus.h +0 -232
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/cactus_ffi.h +0 -256
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/chat.h +0 -145
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/common.h +0 -674
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-alloc.h +0 -76
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-backend-impl.h +0 -255
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-backend.h +0 -354
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-common.h +0 -1857
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-cpp.h +0 -39
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-cpu.h +0 -143
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-impl.h +0 -601
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-metal-impl.h +0 -622
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-metal.h +0 -66
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-opt.h +0 -237
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-quants.h +0 -100
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-threading.h +0 -14
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml.h +0 -2202
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/gguf.h +0 -202
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/json.hpp +0 -24766
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-adapter.h +0 -76
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-arch.h +0 -437
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-batch.h +0 -89
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-chat.h +0 -58
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-context.h +0 -276
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-cparams.h +0 -39
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-cpp.h +0 -30
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-grammar.h +0 -173
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-graph.h +0 -640
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-hparams.h +0 -190
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-impl.h +0 -61
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-io.h +0 -35
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-kv-cache.h +0 -515
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-memory.h +0 -32
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-mmap.h +0 -68
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model-loader.h +0 -169
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model-saver.h +0 -37
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model.h +0 -425
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-sampling.h +0 -32
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-vocab.h +0 -131
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama.h +0 -1376
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/log.h +0 -103
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/minja/chat-template.hpp +0 -542
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/minja/minja.hpp +0 -2974
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/sampling.h +0 -107
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/unicode-data.h +0 -20
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/unicode.h +0 -66
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/tvos-arm64/cactus.framework/ggml-llama.metallib +0 -0
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/cactus.h +0 -232
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/cactus_ffi.h +0 -256
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/chat.h +0 -145
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/common.h +0 -674
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-alloc.h +0 -76
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend-impl.h +0 -255
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend.h +0 -354
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-common.h +0 -1857
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpp.h +0 -39
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpu.h +0 -143
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-impl.h +0 -601
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal-impl.h +0 -622
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal.h +0 -66
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-opt.h +0 -237
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-quants.h +0 -100
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-threading.h +0 -14
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml.h +0 -2202
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/gguf.h +0 -202
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/json.hpp +0 -24766
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-adapter.h +0 -76
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-arch.h +0 -437
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-batch.h +0 -89
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-chat.h +0 -58
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-context.h +0 -276
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-cparams.h +0 -39
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-cpp.h +0 -30
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-grammar.h +0 -173
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-graph.h +0 -640
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-hparams.h +0 -190
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-impl.h +0 -61
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-io.h +0 -35
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-kv-cache.h +0 -515
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-memory.h +0 -32
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-mmap.h +0 -68
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-loader.h +0 -169
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-saver.h +0 -37
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model.h +0 -425
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-sampling.h +0 -32
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-vocab.h +0 -131
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama.h +0 -1376
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/log.h +0 -103
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/minja/chat-template.hpp +0 -542
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/minja/minja.hpp +0 -2974
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/sampling.h +0 -107
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/unicode-data.h +0 -20
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/unicode.h +0 -66
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/ggml-llama-sim.metallib +0 -0
- package/lib/commonjs/NativeCactus.js +0 -9
- package/lib/commonjs/NativeCactus.js.map +0 -1
- package/lib/commonjs/agent.js +0 -73
- package/lib/commonjs/agent.js.map +0 -1
- package/lib/commonjs/chat.js +0 -73
- package/lib/commonjs/chat.js.map +0 -1
- package/lib/commonjs/index.js +0 -523
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/lm.js +0 -272
- package/lib/commonjs/lm.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/commonjs/projectId.js +0 -9
- package/lib/commonjs/projectId.js.map +0 -1
- package/lib/commonjs/remote.js +0 -100
- package/lib/commonjs/remote.js.map +0 -1
- package/lib/commonjs/telemetry.js +0 -102
- package/lib/commonjs/telemetry.js.map +0 -1
- package/lib/commonjs/tools.js +0 -72
- package/lib/commonjs/tools.js.map +0 -1
- package/lib/commonjs/tts.js +0 -141
- package/lib/commonjs/tts.js.map +0 -1
- package/lib/commonjs/vlm.js +0 -221
- package/lib/commonjs/vlm.js.map +0 -1
- package/lib/module/NativeCactus.js +0 -5
- package/lib/module/NativeCactus.js.map +0 -1
- package/lib/module/agent.js +0 -68
- package/lib/module/agent.js.map +0 -1
- package/lib/module/chat.js +0 -67
- package/lib/module/chat.js.map +0 -1
- package/lib/module/lm.js +0 -267
- package/lib/module/lm.js.map +0 -1
- package/lib/module/projectId.js +0 -5
- package/lib/module/projectId.js.map +0 -1
- package/lib/module/remote.js +0 -91
- package/lib/module/remote.js.map +0 -1
- package/lib/module/telemetry.js +0 -97
- package/lib/module/telemetry.js.map +0 -1
- package/lib/module/tools.js +0 -66
- package/lib/module/tools.js.map +0 -1
- package/lib/module/tts.js +0 -135
- package/lib/module/tts.js.map +0 -1
- package/lib/module/vlm.js +0 -216
- package/lib/module/vlm.js.map +0 -1
- package/lib/typescript/NativeCactus.d.ts +0 -252
- package/lib/typescript/NativeCactus.d.ts.map +0 -1
- package/lib/typescript/agent.d.ts +0 -31
- package/lib/typescript/agent.d.ts.map +0 -1
- package/lib/typescript/chat.d.ts +0 -23
- package/lib/typescript/chat.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -114
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/lm.d.ts +0 -36
- package/lib/typescript/lm.d.ts.map +0 -1
- package/lib/typescript/projectId.d.ts +0 -2
- package/lib/typescript/projectId.d.ts.map +0 -1
- package/lib/typescript/remote.d.ts +0 -8
- package/lib/typescript/remote.d.ts.map +0 -1
- package/lib/typescript/telemetry.d.ts +0 -25
- package/lib/typescript/telemetry.d.ts.map +0 -1
- package/lib/typescript/tools.d.ts +0 -36
- package/lib/typescript/tools.d.ts.map +0 -1
- package/lib/typescript/tts.d.ts +0 -54
- package/lib/typescript/tts.d.ts.map +0 -1
- package/lib/typescript/vlm.d.ts +0 -33
- package/lib/typescript/vlm.d.ts.map +0 -1
- package/scripts/postInstall.js +0 -33
- package/src/NativeCactus.ts +0 -317
- package/src/agent.ts +0 -112
- package/src/chat.ts +0 -91
- package/src/index.ts +0 -663
- package/src/lm.ts +0 -324
- package/src/projectId.ts +0 -1
- package/src/remote.ts +0 -113
- package/src/telemetry.ts +0 -137
- package/src/tools.ts +0 -94
- package/src/tts.ts +0 -236
- package/src/vlm.ts +0 -276
|
@@ -1,748 +0,0 @@
|
|
|
1
|
-
package com.cactus;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.Arguments;
|
|
4
|
-
import com.facebook.react.bridge.WritableArray;
|
|
5
|
-
import com.facebook.react.bridge.WritableMap;
|
|
6
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
7
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
8
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
10
|
-
|
|
11
|
-
import android.util.Log;
|
|
12
|
-
import android.provider.Settings;
|
|
13
|
-
import android.os.Build;
|
|
14
|
-
import android.content.res.AssetManager;
|
|
15
|
-
|
|
16
|
-
import java.lang.StringBuilder;
|
|
17
|
-
import java.io.BufferedReader;
|
|
18
|
-
import java.io.FileReader;
|
|
19
|
-
import java.io.File;
|
|
20
|
-
import java.io.IOException;
|
|
21
|
-
|
|
22
|
-
public class LlamaContext {
|
|
23
|
-
public static final String NAME = "CactusContext";
|
|
24
|
-
|
|
25
|
-
private static String loadedLibrary = "";
|
|
26
|
-
|
|
27
|
-
private static class NativeLogCallback {
|
|
28
|
-
DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter;
|
|
29
|
-
|
|
30
|
-
public NativeLogCallback(ReactApplicationContext reactContext) {
|
|
31
|
-
this.eventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
void emitNativeLog(String level, String text) {
|
|
35
|
-
WritableMap event = Arguments.createMap();
|
|
36
|
-
event.putString("level", level);
|
|
37
|
-
event.putString("text", text);
|
|
38
|
-
eventEmitter.emit("@Cactus_onNativeLog", event);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static void toggleNativeLog(ReactApplicationContext reactContext, boolean enabled) {
|
|
43
|
-
if (LlamaContext.isArchNotSupported()) {
|
|
44
|
-
throw new IllegalStateException("Only 64-bit architectures are supported");
|
|
45
|
-
}
|
|
46
|
-
if (enabled) {
|
|
47
|
-
setupLog(new NativeLogCallback(reactContext));
|
|
48
|
-
} else {
|
|
49
|
-
unsetLog();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private int id;
|
|
54
|
-
private ReactApplicationContext reactContext;
|
|
55
|
-
private long context;
|
|
56
|
-
private WritableMap modelDetails;
|
|
57
|
-
private int jobId = -1;
|
|
58
|
-
private DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter;
|
|
59
|
-
|
|
60
|
-
public LlamaContext(int id, ReactApplicationContext reactContext, ReadableMap params) {
|
|
61
|
-
if (LlamaContext.isArchNotSupported()) {
|
|
62
|
-
throw new IllegalStateException("Only 64-bit architectures are supported");
|
|
63
|
-
}
|
|
64
|
-
if (!params.hasKey("model")) {
|
|
65
|
-
throw new IllegalArgumentException("Missing required parameter: model");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
String modelPath = params.getString("model");
|
|
69
|
-
File modelFile = new File(modelPath);
|
|
70
|
-
if (!modelFile.exists()) {
|
|
71
|
-
Log.e(NAME, "Model file does not exist: " + modelPath);
|
|
72
|
-
throw new IllegalArgumentException("Model file does not exist: " + modelPath);
|
|
73
|
-
}
|
|
74
|
-
if (!modelFile.canRead()) {
|
|
75
|
-
Log.e(NAME, "Model file is not readable: " + modelPath);
|
|
76
|
-
throw new IllegalArgumentException("Model file is not readable: " + modelPath);
|
|
77
|
-
}
|
|
78
|
-
eventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
|
|
79
|
-
this.id = id;
|
|
80
|
-
this.context = initContext(
|
|
81
|
-
params.getString("model"),
|
|
82
|
-
params.hasKey("chat_template") ? params.getString("chat_template") : "",
|
|
83
|
-
params.hasKey("reasoning_format") ? params.getString("reasoning_format") : "none",
|
|
84
|
-
params.hasKey("embedding") ? params.getBoolean("embedding") : false,
|
|
85
|
-
params.hasKey("embd_normalize") ? params.getInt("embd_normalize") : -1,
|
|
86
|
-
params.hasKey("n_ctx") ? params.getInt("n_ctx") : 512,
|
|
87
|
-
params.hasKey("n_batch") ? params.getInt("n_batch") : 512,
|
|
88
|
-
params.hasKey("n_ubatch") ? params.getInt("n_ubatch") : 512,
|
|
89
|
-
params.hasKey("n_threads") ? params.getInt("n_threads") : 0,
|
|
90
|
-
params.hasKey("n_gpu_layers") ? params.getInt("n_gpu_layers") : 0,
|
|
91
|
-
params.hasKey("flash_attn") ? params.getBoolean("flash_attn") : false,
|
|
92
|
-
params.hasKey("cache_type_k") ? params.getString("cache_type_k") : "f16",
|
|
93
|
-
params.hasKey("cache_type_v") ? params.getString("cache_type_v") : "f16",
|
|
94
|
-
params.hasKey("use_mlock") ? params.getBoolean("use_mlock") : true,
|
|
95
|
-
params.hasKey("use_mmap") ? params.getBoolean("use_mmap") : true,
|
|
96
|
-
params.hasKey("vocab_only") ? params.getBoolean("vocab_only") : false,
|
|
97
|
-
params.hasKey("lora") ? params.getString("lora") : "",
|
|
98
|
-
params.hasKey("lora_scaled") ? (float) params.getDouble("lora_scaled") : 1.0f,
|
|
99
|
-
params.hasKey("lora_list") ? params.getArray("lora_list") : null,
|
|
100
|
-
params.hasKey("rope_freq_base") ? (float) params.getDouble("rope_freq_base") : 0.0f,
|
|
101
|
-
params.hasKey("rope_freq_scale") ? (float) params.getDouble("rope_freq_scale") : 0.0f,
|
|
102
|
-
params.hasKey("pooling_type") ? params.getInt("pooling_type") : -1,
|
|
103
|
-
params.hasKey("use_progress_callback") ? new LoadProgressCallback(this) : null
|
|
104
|
-
);
|
|
105
|
-
if (this.context == -1) {
|
|
106
|
-
throw new IllegalStateException("Failed to initialize context for model: " + modelPath +
|
|
107
|
-
". Please check if the model file exists and is accessible.");
|
|
108
|
-
}
|
|
109
|
-
this.modelDetails = loadModelDetails(this.context);
|
|
110
|
-
this.reactContext = reactContext;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public void interruptLoad() {
|
|
114
|
-
interruptLoad(this.context);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public long getContext() {
|
|
118
|
-
return context;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public WritableMap getModelDetails() {
|
|
122
|
-
return modelDetails;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
public String getLoadedLibrary() {
|
|
126
|
-
return loadedLibrary;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
public WritableMap getFormattedChatWithJinja(String messages, String chatTemplate, ReadableMap params) {
|
|
130
|
-
String jsonSchema = params.hasKey("json_schema") ? params.getString("json_schema") : "";
|
|
131
|
-
String tools = params.hasKey("tools") ? params.getString("tools") : "";
|
|
132
|
-
Boolean parallelToolCalls = params.hasKey("parallel_tool_calls") ? params.getBoolean("parallel_tool_calls") : false;
|
|
133
|
-
String toolChoice = params.hasKey("tool_choice") ? params.getString("tool_choice") : "";
|
|
134
|
-
return getFormattedChatWithJinja(
|
|
135
|
-
this.context,
|
|
136
|
-
messages,
|
|
137
|
-
chatTemplate == null ? "" : chatTemplate,
|
|
138
|
-
jsonSchema,
|
|
139
|
-
tools,
|
|
140
|
-
parallelToolCalls,
|
|
141
|
-
toolChoice
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
public String getFormattedChat(String messages, String chatTemplate) {
|
|
146
|
-
return getFormattedChat(this.context, messages, chatTemplate == null ? "" : chatTemplate);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
private void emitLoadProgress(int progress) {
|
|
150
|
-
WritableMap event = Arguments.createMap();
|
|
151
|
-
event.putInt("contextId", LlamaContext.this.id);
|
|
152
|
-
event.putInt("progress", progress);
|
|
153
|
-
eventEmitter.emit("@Cactus_onInitContextProgress", event);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private static class LoadProgressCallback {
|
|
157
|
-
LlamaContext context;
|
|
158
|
-
|
|
159
|
-
public LoadProgressCallback(LlamaContext context) {
|
|
160
|
-
this.context = context;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
void onLoadProgress(int progress) {
|
|
164
|
-
context.emitLoadProgress(progress);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
private void emitPartialCompletion(WritableMap tokenResult) {
|
|
169
|
-
WritableMap event = Arguments.createMap();
|
|
170
|
-
event.putInt("contextId", LlamaContext.this.id);
|
|
171
|
-
event.putMap("tokenResult", tokenResult);
|
|
172
|
-
eventEmitter.emit("@Cactus_onToken", event);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
private static class PartialCompletionCallback {
|
|
176
|
-
LlamaContext context;
|
|
177
|
-
boolean emitNeeded;
|
|
178
|
-
|
|
179
|
-
public PartialCompletionCallback(LlamaContext context, boolean emitNeeded) {
|
|
180
|
-
this.context = context;
|
|
181
|
-
this.emitNeeded = emitNeeded;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
void onPartialCompletion(WritableMap tokenResult) {
|
|
185
|
-
if (!emitNeeded) return;
|
|
186
|
-
context.emitPartialCompletion(tokenResult);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public WritableMap loadSession(String path) {
|
|
191
|
-
if (path == null || path.isEmpty()) {
|
|
192
|
-
throw new IllegalArgumentException("File path is empty");
|
|
193
|
-
}
|
|
194
|
-
File file = new File(path);
|
|
195
|
-
if (!file.exists()) {
|
|
196
|
-
throw new IllegalArgumentException("File does not exist: " + path);
|
|
197
|
-
}
|
|
198
|
-
WritableMap result = loadSession(this.context, path);
|
|
199
|
-
if (result.hasKey("error")) {
|
|
200
|
-
throw new IllegalStateException(result.getString("error"));
|
|
201
|
-
}
|
|
202
|
-
return result;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
public int saveSession(String path, int size) {
|
|
206
|
-
if (path == null || path.isEmpty()) {
|
|
207
|
-
throw new IllegalArgumentException("File path is empty");
|
|
208
|
-
}
|
|
209
|
-
return saveSession(this.context, path, size);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
public WritableMap completion(ReadableMap params) {
|
|
213
|
-
Log.d(NAME, "🔵 ANDROID: completion() called");
|
|
214
|
-
if (!params.hasKey("prompt")) {
|
|
215
|
-
throw new IllegalArgumentException("Missing required parameter: prompt");
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
Log.d(NAME, "📝 ANDROID: prompt length = " + params.getString("prompt").length());
|
|
219
|
-
Log.d(NAME, "🧮 ANDROID: context ptr = " + this.context);
|
|
220
|
-
|
|
221
|
-
double[][] logit_bias = new double[0][0];
|
|
222
|
-
if (params.hasKey("logit_bias")) {
|
|
223
|
-
ReadableArray logit_bias_array = params.getArray("logit_bias");
|
|
224
|
-
logit_bias = new double[logit_bias_array.size()][];
|
|
225
|
-
for (int i = 0; i < logit_bias_array.size(); i++) {
|
|
226
|
-
ReadableArray logit_bias_row = logit_bias_array.getArray(i);
|
|
227
|
-
logit_bias[i] = new double[logit_bias_row.size()];
|
|
228
|
-
for (int j = 0; j < logit_bias_row.size(); j++) {
|
|
229
|
-
logit_bias[i][j] = logit_bias_row.getDouble(j);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
Log.d(NAME, "🚀 ANDROID: About to call doCompletion native method...");
|
|
235
|
-
WritableMap result = doCompletion(
|
|
236
|
-
this.context,
|
|
237
|
-
params.getString("prompt"),
|
|
238
|
-
params.hasKey("chat_format") ? params.getInt("chat_format") : 0,
|
|
239
|
-
params.hasKey("grammar") ? params.getString("grammar") : "",
|
|
240
|
-
params.hasKey("json_schema") ? params.getString("json_schema") : "",
|
|
241
|
-
params.hasKey("grammar_lazy") ? params.getBoolean("grammar_lazy") : false,
|
|
242
|
-
params.hasKey("grammar_triggers") ? params.getArray("grammar_triggers") : null,
|
|
243
|
-
params.hasKey("preserved_tokens") ? params.getArray("preserved_tokens") : null,
|
|
244
|
-
params.hasKey("temperature") ? (float) params.getDouble("temperature") : 0.7f,
|
|
245
|
-
params.hasKey("n_threads") ? params.getInt("n_threads") : 0,
|
|
246
|
-
params.hasKey("n_predict") ? params.getInt("n_predict") : -1,
|
|
247
|
-
params.hasKey("n_probs") ? params.getInt("n_probs") : 0,
|
|
248
|
-
params.hasKey("penalty_last_n") ? params.getInt("penalty_last_n") : 64,
|
|
249
|
-
params.hasKey("penalty_repeat") ? (float) params.getDouble("penalty_repeat") : 1.00f,
|
|
250
|
-
params.hasKey("penalty_freq") ? (float) params.getDouble("penalty_freq") : 0.00f,
|
|
251
|
-
params.hasKey("penalty_present") ? (float) params.getDouble("penalty_present") : 0.00f,
|
|
252
|
-
params.hasKey("mirostat") ? (float) params.getDouble("mirostat") : 0.00f,
|
|
253
|
-
params.hasKey("mirostat_tau") ? (float) params.getDouble("mirostat_tau") : 5.00f,
|
|
254
|
-
params.hasKey("mirostat_eta") ? (float) params.getDouble("mirostat_eta") : 0.10f,
|
|
255
|
-
params.hasKey("top_k") ? params.getInt("top_k") : 40,
|
|
256
|
-
params.hasKey("top_p") ? (float) params.getDouble("top_p") : 0.95f,
|
|
257
|
-
params.hasKey("min_p") ? (float) params.getDouble("min_p") : 0.05f,
|
|
258
|
-
params.hasKey("xtc_threshold") ? (float) params.getDouble("xtc_threshold") : 0.00f,
|
|
259
|
-
params.hasKey("xtc_probability") ? (float) params.getDouble("xtc_probability") : 0.00f,
|
|
260
|
-
params.hasKey("typical_p") ? (float) params.getDouble("typical_p") : 1.00f,
|
|
261
|
-
params.hasKey("seed") ? params.getInt("seed") : -1,
|
|
262
|
-
params.hasKey("stop") ? params.getArray("stop").toArrayList().toArray(new String[0]) : new String[0],
|
|
263
|
-
params.hasKey("ignore_eos") ? params.getBoolean("ignore_eos") : false,
|
|
264
|
-
logit_bias,
|
|
265
|
-
params.hasKey("dry_multiplier") ? (float) params.getDouble("dry_multiplier") : 0.00f,
|
|
266
|
-
params.hasKey("dry_base") ? (float) params.getDouble("dry_base") : 1.75f,
|
|
267
|
-
params.hasKey("dry_allowed_length") ? params.getInt("dry_allowed_length") : 2,
|
|
268
|
-
params.hasKey("dry_penalty_last_n") ? params.getInt("dry_penalty_last_n") : -1,
|
|
269
|
-
params.hasKey("top_n_sigma") ? (float) params.getDouble("top_n_sigma") : -1.0f,
|
|
270
|
-
params.hasKey("dry_sequence_breakers") ? params.getArray("dry_sequence_breakers").toArrayList().toArray(new String[0]) : new String[]{"\n", ":", "\"", "*"},
|
|
271
|
-
new PartialCompletionCallback(
|
|
272
|
-
this,
|
|
273
|
-
params.hasKey("emit_partial_completion") ? params.getBoolean("emit_partial_completion") : false
|
|
274
|
-
)
|
|
275
|
-
);
|
|
276
|
-
Log.d(NAME, "✅ ANDROID: doCompletion returned successfully");
|
|
277
|
-
if (result.hasKey("error")) {
|
|
278
|
-
Log.e(NAME, "❌ ANDROID: doCompletion returned error: " + result.getString("error"));
|
|
279
|
-
throw new IllegalStateException(result.getString("error"));
|
|
280
|
-
}
|
|
281
|
-
Log.d(NAME, "📤 ANDROID: completion() returning result");
|
|
282
|
-
return result;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
public void stopCompletion() {
|
|
286
|
-
stopCompletion(this.context);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
public boolean isPredicting() {
|
|
290
|
-
return isPredicting(this.context);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
public WritableMap tokenize(String text) {
|
|
294
|
-
WritableMap result = Arguments.createMap();
|
|
295
|
-
result.putArray("tokens", tokenize(this.context, text));
|
|
296
|
-
return result;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
public String detokenize(ReadableArray tokens) {
|
|
300
|
-
int[] toks = new int[tokens.size()];
|
|
301
|
-
for (int i = 0; i < tokens.size(); i++) {
|
|
302
|
-
toks[i] = (int) tokens.getDouble(i);
|
|
303
|
-
}
|
|
304
|
-
return detokenize(this.context, toks);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
public WritableMap getEmbedding(String text, ReadableMap params) {
|
|
308
|
-
if (isEmbeddingEnabled(this.context) == false) {
|
|
309
|
-
throw new IllegalStateException("Embedding is not enabled");
|
|
310
|
-
}
|
|
311
|
-
WritableMap result = embedding(
|
|
312
|
-
this.context,
|
|
313
|
-
text,
|
|
314
|
-
params.hasKey("embd_normalize") ? params.getInt("embd_normalize") : -1
|
|
315
|
-
);
|
|
316
|
-
if (result.hasKey("error")) {
|
|
317
|
-
throw new IllegalStateException(result.getString("error"));
|
|
318
|
-
}
|
|
319
|
-
return result;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
public String bench(int pp, int tg, int pl, int nr) {
|
|
323
|
-
return bench(this.context, pp, tg, pl, nr);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
public int applyLoraAdapters(ReadableArray loraAdapters) {
|
|
327
|
-
int result = applyLoraAdapters(this.context, loraAdapters);
|
|
328
|
-
if (result != 0) {
|
|
329
|
-
throw new IllegalStateException("Failed to apply lora adapters");
|
|
330
|
-
}
|
|
331
|
-
return result;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
public void removeLoraAdapters() {
|
|
335
|
-
removeLoraAdapters(this.context);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
public WritableArray getLoadedLoraAdapters() {
|
|
339
|
-
return getLoadedLoraAdapters(this.context);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
public void rewind() {
|
|
343
|
-
rewind(this.context);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
public void release() {
|
|
347
|
-
freeContext(context);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
public boolean initMultimodal(String mmprojPath, boolean useGpu) {
|
|
351
|
-
return initMultimodal(this.context, mmprojPath, useGpu);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
public boolean isMultimodalEnabled() {
|
|
355
|
-
return isMultimodalEnabled(this.context);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
public boolean isMultimodalSupportVision() {
|
|
359
|
-
return isMultimodalSupportVision(this.context);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
public boolean isMultimodalSupportAudio() {
|
|
363
|
-
return isMultimodalSupportAudio(this.context);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
public void releaseMultimodal() {
|
|
367
|
-
releaseMultimodal(this.context);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
public WritableMap multimodalCompletion(String prompt, ReadableArray mediaPaths, ReadableMap params) {
|
|
371
|
-
if (!params.hasKey("prompt")) {
|
|
372
|
-
params = Arguments.createMap();
|
|
373
|
-
((WritableMap) params).putString("prompt", prompt);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
String[] mediaPathsArray = new String[mediaPaths.size()];
|
|
377
|
-
for (int i = 0; i < mediaPaths.size(); i++) {
|
|
378
|
-
mediaPathsArray[i] = mediaPaths.getString(i);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
double[][] logit_bias = new double[0][0];
|
|
382
|
-
if (params.hasKey("logit_bias")) {
|
|
383
|
-
ReadableArray logit_bias_array = params.getArray("logit_bias");
|
|
384
|
-
logit_bias = new double[logit_bias_array.size()][];
|
|
385
|
-
for (int i = 0; i < logit_bias_array.size(); i++) {
|
|
386
|
-
ReadableArray logit_bias_row = logit_bias_array.getArray(i);
|
|
387
|
-
logit_bias[i] = new double[logit_bias_row.size()];
|
|
388
|
-
for (int j = 0; j < logit_bias_row.size(); j++) {
|
|
389
|
-
logit_bias[i][j] = logit_bias_row.getDouble(j);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
WritableMap result = doMultimodalCompletion(
|
|
395
|
-
this.context,
|
|
396
|
-
prompt,
|
|
397
|
-
mediaPathsArray,
|
|
398
|
-
params.hasKey("chat_format") ? params.getInt("chat_format") : 0,
|
|
399
|
-
params.hasKey("grammar") ? params.getString("grammar") : "",
|
|
400
|
-
params.hasKey("json_schema") ? params.getString("json_schema") : "",
|
|
401
|
-
params.hasKey("grammar_lazy") ? params.getBoolean("grammar_lazy") : false,
|
|
402
|
-
params.hasKey("grammar_triggers") ? params.getArray("grammar_triggers") : null,
|
|
403
|
-
params.hasKey("preserved_tokens") ? params.getArray("preserved_tokens") : null,
|
|
404
|
-
params.hasKey("temperature") ? (float) params.getDouble("temperature") : 0.7f,
|
|
405
|
-
params.hasKey("n_threads") ? params.getInt("n_threads") : 0,
|
|
406
|
-
params.hasKey("n_predict") ? params.getInt("n_predict") : -1,
|
|
407
|
-
params.hasKey("n_probs") ? params.getInt("n_probs") : 0,
|
|
408
|
-
params.hasKey("penalty_last_n") ? params.getInt("penalty_last_n") : 64,
|
|
409
|
-
params.hasKey("penalty_repeat") ? (float) params.getDouble("penalty_repeat") : 1.00f,
|
|
410
|
-
params.hasKey("penalty_freq") ? (float) params.getDouble("penalty_freq") : 0.00f,
|
|
411
|
-
params.hasKey("penalty_present") ? (float) params.getDouble("penalty_present") : 0.00f,
|
|
412
|
-
params.hasKey("mirostat") ? (float) params.getDouble("mirostat") : 0.00f,
|
|
413
|
-
params.hasKey("mirostat_tau") ? (float) params.getDouble("mirostat_tau") : 5.00f,
|
|
414
|
-
params.hasKey("mirostat_eta") ? (float) params.getDouble("mirostat_eta") : 0.10f,
|
|
415
|
-
params.hasKey("top_k") ? params.getInt("top_k") : 40,
|
|
416
|
-
params.hasKey("top_p") ? (float) params.getDouble("top_p") : 0.95f,
|
|
417
|
-
params.hasKey("min_p") ? (float) params.getDouble("min_p") : 0.05f,
|
|
418
|
-
params.hasKey("xtc_threshold") ? (float) params.getDouble("xtc_threshold") : 0.00f,
|
|
419
|
-
params.hasKey("xtc_probability") ? (float) params.getDouble("xtc_probability") : 0.00f,
|
|
420
|
-
params.hasKey("typical_p") ? (float) params.getDouble("typical_p") : 1.00f,
|
|
421
|
-
params.hasKey("seed") ? params.getInt("seed") : -1,
|
|
422
|
-
params.hasKey("stop") ? params.getArray("stop").toArrayList().toArray(new String[0]) : new String[0],
|
|
423
|
-
params.hasKey("ignore_eos") ? params.getBoolean("ignore_eos") : false,
|
|
424
|
-
logit_bias,
|
|
425
|
-
params.hasKey("dry_multiplier") ? (float) params.getDouble("dry_multiplier") : 0.00f,
|
|
426
|
-
params.hasKey("dry_base") ? (float) params.getDouble("dry_base") : 1.75f,
|
|
427
|
-
params.hasKey("dry_allowed_length") ? params.getInt("dry_allowed_length") : 2,
|
|
428
|
-
params.hasKey("dry_penalty_last_n") ? params.getInt("dry_penalty_last_n") : -1,
|
|
429
|
-
params.hasKey("top_n_sigma") ? (float) params.getDouble("top_n_sigma") : -1.0f,
|
|
430
|
-
params.hasKey("dry_sequence_breakers") ? params.getArray("dry_sequence_breakers").toArrayList().toArray(new String[0]) : new String[]{"\n", ":", "\"", "*"},
|
|
431
|
-
new PartialCompletionCallback(
|
|
432
|
-
this,
|
|
433
|
-
params.hasKey("emit_partial_completion") ? params.getBoolean("emit_partial_completion") : false
|
|
434
|
-
)
|
|
435
|
-
);
|
|
436
|
-
if (result.hasKey("error")) {
|
|
437
|
-
throw new IllegalStateException(result.getString("error"));
|
|
438
|
-
}
|
|
439
|
-
return result;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
public WritableMap tokenize(String text, ReadableArray mediaPaths) {
|
|
443
|
-
String[] mediaPathsArray = new String[mediaPaths.size()];
|
|
444
|
-
for (int i = 0; i < mediaPaths.size(); i++) {
|
|
445
|
-
mediaPathsArray[i] = mediaPaths.getString(i);
|
|
446
|
-
}
|
|
447
|
-
WritableMap result = tokenize(this.context, text, mediaPathsArray);
|
|
448
|
-
return result;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
public boolean initVocoder(String vocoderModelPath) {
|
|
452
|
-
return initVocoder(this.context, vocoderModelPath);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
public boolean isVocoderEnabled() {
|
|
456
|
-
return isVocoderEnabled(this.context);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
public int getTTSType() {
|
|
460
|
-
return getTTSType(this.context);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
public String getFormattedAudioCompletion(String speakerJsonStr, String textToSpeak) {
|
|
464
|
-
return getFormattedAudioCompletion(this.context, speakerJsonStr, textToSpeak);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
public WritableArray getAudioCompletionGuideTokens(String textToSpeak) {
|
|
468
|
-
return getAudioCompletionGuideTokens(this.context, textToSpeak);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
public WritableArray decodeAudioTokens(ReadableArray tokens) {
|
|
472
|
-
int[] toks = new int[tokens.size()];
|
|
473
|
-
for (int i = 0; i < tokens.size(); i++) {
|
|
474
|
-
toks[i] = (int) tokens.getDouble(i);
|
|
475
|
-
}
|
|
476
|
-
return decodeAudioTokens(this.context, toks);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
public WritableMap getDeviceInfo() {
|
|
480
|
-
WritableMap deviceInfo = Arguments.createMap();
|
|
481
|
-
|
|
482
|
-
String deviceId = Settings.Secure.getString(this.reactContext.getContentResolver(), Settings.Secure.ANDROID_ID);
|
|
483
|
-
|
|
484
|
-
String make = Build.MANUFACTURER;
|
|
485
|
-
String model = Build.MODEL;
|
|
486
|
-
String osVersion = Build.VERSION.RELEASE;
|
|
487
|
-
|
|
488
|
-
deviceInfo.putString("deviceId", deviceId);
|
|
489
|
-
deviceInfo.putString("make", make);
|
|
490
|
-
deviceInfo.putString("model", model);
|
|
491
|
-
deviceInfo.putString("os", "Android");
|
|
492
|
-
deviceInfo.putString("osVersion", osVersion);
|
|
493
|
-
|
|
494
|
-
return deviceInfo;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
public void releaseVocoder() {
|
|
498
|
-
releaseVocoder(this.context);
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
static {
|
|
502
|
-
Log.d(NAME, "Primary ABI: " + Build.SUPPORTED_ABIS[0]);
|
|
503
|
-
|
|
504
|
-
String cpuFeatures = LlamaContext.getCpuFeatures();
|
|
505
|
-
Log.d(NAME, "CPU features: " + cpuFeatures);
|
|
506
|
-
boolean hasFp16 = cpuFeatures.contains("fp16") || cpuFeatures.contains("fphp");
|
|
507
|
-
boolean hasDotProd = cpuFeatures.contains("dotprod") || cpuFeatures.contains("asimddp");
|
|
508
|
-
boolean hasSve = cpuFeatures.contains("sve");
|
|
509
|
-
boolean hasI8mm = cpuFeatures.contains("i8mm");
|
|
510
|
-
boolean isAtLeastArmV82 = cpuFeatures.contains("asimd") && cpuFeatures.contains("crc32") && cpuFeatures.contains("aes");
|
|
511
|
-
boolean isAtLeastArmV84 = cpuFeatures.contains("dcpop") && cpuFeatures.contains("uscat");
|
|
512
|
-
Log.d(NAME, "- hasFp16: " + hasFp16);
|
|
513
|
-
Log.d(NAME, "- hasDotProd: " + hasDotProd);
|
|
514
|
-
Log.d(NAME, "- hasSve: " + hasSve);
|
|
515
|
-
Log.d(NAME, "- hasI8mm: " + hasI8mm);
|
|
516
|
-
Log.d(NAME, "- isAtLeastArmV82: " + isAtLeastArmV82);
|
|
517
|
-
Log.d(NAME, "- isAtLeastArmV84: " + isAtLeastArmV84);
|
|
518
|
-
|
|
519
|
-
if (LlamaContext.isArm64V8a()) {
|
|
520
|
-
if (hasDotProd && hasI8mm) {
|
|
521
|
-
Log.d(NAME, "Loading libcactus_v8_2_dotprod_i8mm.so");
|
|
522
|
-
System.loadLibrary("cactus_v8_2_dotprod_i8mm");
|
|
523
|
-
loadedLibrary = "cactus_v8_2_dotprod_i8mm";
|
|
524
|
-
} else if (hasDotProd) {
|
|
525
|
-
Log.d(NAME, "Loading libcactus_v8_2_dotprod.so");
|
|
526
|
-
System.loadLibrary("cactus_v8_2_dotprod");
|
|
527
|
-
loadedLibrary = "cactus_v8_2_dotprod";
|
|
528
|
-
} else if (hasI8mm) {
|
|
529
|
-
Log.d(NAME, "Loading libcactus_v8_2_i8mm.so");
|
|
530
|
-
System.loadLibrary("cactus_v8_2_i8mm");
|
|
531
|
-
loadedLibrary = "cactus_v8_2_i8mm";
|
|
532
|
-
} else if (hasFp16) {
|
|
533
|
-
Log.d(NAME, "Loading libcactus_v8_2.so");
|
|
534
|
-
System.loadLibrary("cactus_v8_2");
|
|
535
|
-
loadedLibrary = "cactus_v8_2";
|
|
536
|
-
} else {
|
|
537
|
-
Log.d(NAME, "Loading default libcactus_v8.so");
|
|
538
|
-
System.loadLibrary("cactus_v8");
|
|
539
|
-
loadedLibrary = "cactus_v8";
|
|
540
|
-
}
|
|
541
|
-
} else if (LlamaContext.isX86_64()) {
|
|
542
|
-
Log.d(NAME, "Loading libcactus_x86_64.so");
|
|
543
|
-
System.loadLibrary("cactus_x86_64");
|
|
544
|
-
loadedLibrary = "cactus_x86_64";
|
|
545
|
-
} else {
|
|
546
|
-
Log.d(NAME, "ARM32 is not supported, skipping loading library");
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
private static boolean isArm64V8a() {
|
|
551
|
-
return Build.SUPPORTED_ABIS[0].equals("arm64-v8a");
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
private static boolean isX86_64() {
|
|
555
|
-
return Build.SUPPORTED_ABIS[0].equals("x86_64");
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
private static boolean isArchNotSupported() {
|
|
559
|
-
return isArm64V8a() == false && isX86_64() == false;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
private static String getCpuFeatures() {
|
|
563
|
-
File file = new File("/proc/cpuinfo");
|
|
564
|
-
StringBuilder stringBuilder = new StringBuilder();
|
|
565
|
-
try {
|
|
566
|
-
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
|
567
|
-
String line;
|
|
568
|
-
while ((line = bufferedReader.readLine()) != null) {
|
|
569
|
-
if (line.startsWith("Features")) {
|
|
570
|
-
stringBuilder.append(line);
|
|
571
|
-
break;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
bufferedReader.close();
|
|
575
|
-
return stringBuilder.toString();
|
|
576
|
-
} catch (IOException e) {
|
|
577
|
-
Log.w(NAME, "Couldn't read /proc/cpuinfo", e);
|
|
578
|
-
return "";
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
protected static native WritableMap modelInfo(
|
|
583
|
-
String model,
|
|
584
|
-
String[] skip
|
|
585
|
-
);
|
|
586
|
-
protected static native long initContext(
|
|
587
|
-
String model,
|
|
588
|
-
String chat_template,
|
|
589
|
-
String reasoning_format,
|
|
590
|
-
boolean embedding,
|
|
591
|
-
int embd_normalize,
|
|
592
|
-
int n_ctx,
|
|
593
|
-
int n_batch,
|
|
594
|
-
int n_ubatch,
|
|
595
|
-
int n_threads,
|
|
596
|
-
int n_gpu_layers,
|
|
597
|
-
boolean flash_attn,
|
|
598
|
-
String cache_type_k,
|
|
599
|
-
String cache_type_v,
|
|
600
|
-
boolean use_mlock,
|
|
601
|
-
boolean use_mmap,
|
|
602
|
-
boolean vocab_only,
|
|
603
|
-
String lora,
|
|
604
|
-
float lora_scaled,
|
|
605
|
-
ReadableArray lora_list,
|
|
606
|
-
float rope_freq_base,
|
|
607
|
-
float rope_freq_scale,
|
|
608
|
-
int pooling_type,
|
|
609
|
-
LoadProgressCallback load_progress_callback
|
|
610
|
-
);
|
|
611
|
-
protected static native void interruptLoad(long contextPtr);
|
|
612
|
-
protected static native WritableMap loadModelDetails(
|
|
613
|
-
long contextPtr
|
|
614
|
-
);
|
|
615
|
-
protected static native WritableMap getFormattedChatWithJinja(
|
|
616
|
-
long contextPtr,
|
|
617
|
-
String messages,
|
|
618
|
-
String chatTemplate,
|
|
619
|
-
String jsonSchema,
|
|
620
|
-
String tools,
|
|
621
|
-
boolean parallelToolCalls,
|
|
622
|
-
String toolChoice
|
|
623
|
-
);
|
|
624
|
-
protected static native String getFormattedChat(
|
|
625
|
-
long contextPtr,
|
|
626
|
-
String messages,
|
|
627
|
-
String chatTemplate
|
|
628
|
-
);
|
|
629
|
-
protected static native WritableMap loadSession(
|
|
630
|
-
long contextPtr,
|
|
631
|
-
String path
|
|
632
|
-
);
|
|
633
|
-
protected static native int saveSession(
|
|
634
|
-
long contextPtr,
|
|
635
|
-
String path,
|
|
636
|
-
int size
|
|
637
|
-
);
|
|
638
|
-
protected static native WritableMap doCompletion(
|
|
639
|
-
long context_ptr,
|
|
640
|
-
String prompt,
|
|
641
|
-
int chat_format,
|
|
642
|
-
String grammar,
|
|
643
|
-
String json_schema,
|
|
644
|
-
boolean grammar_lazy,
|
|
645
|
-
ReadableArray grammar_triggers,
|
|
646
|
-
ReadableArray preserved_tokens,
|
|
647
|
-
float temperature,
|
|
648
|
-
int n_threads,
|
|
649
|
-
int n_predict,
|
|
650
|
-
int n_probs,
|
|
651
|
-
int penalty_last_n,
|
|
652
|
-
float penalty_repeat,
|
|
653
|
-
float penalty_freq,
|
|
654
|
-
float penalty_present,
|
|
655
|
-
float mirostat,
|
|
656
|
-
float mirostat_tau,
|
|
657
|
-
float mirostat_eta,
|
|
658
|
-
int top_k,
|
|
659
|
-
float top_p,
|
|
660
|
-
float min_p,
|
|
661
|
-
float xtc_threshold,
|
|
662
|
-
float xtc_probability,
|
|
663
|
-
float typical_p,
|
|
664
|
-
int seed,
|
|
665
|
-
String[] stop,
|
|
666
|
-
boolean ignore_eos,
|
|
667
|
-
double[][] logit_bias,
|
|
668
|
-
float dry_multiplier,
|
|
669
|
-
float dry_base,
|
|
670
|
-
int dry_allowed_length,
|
|
671
|
-
int dry_penalty_last_n,
|
|
672
|
-
float top_n_sigma,
|
|
673
|
-
String[] dry_sequence_breakers,
|
|
674
|
-
PartialCompletionCallback partial_completion_callback
|
|
675
|
-
);
|
|
676
|
-
protected static native void stopCompletion(long contextPtr);
|
|
677
|
-
protected static native boolean isPredicting(long contextPtr);
|
|
678
|
-
protected static native WritableArray tokenize(long contextPtr, String text);
|
|
679
|
-
protected static native String detokenize(long contextPtr, int[] tokens);
|
|
680
|
-
protected static native boolean isEmbeddingEnabled(long contextPtr);
|
|
681
|
-
protected static native WritableMap embedding(
|
|
682
|
-
long contextPtr,
|
|
683
|
-
String text,
|
|
684
|
-
int embd_normalize
|
|
685
|
-
);
|
|
686
|
-
protected static native String bench(long contextPtr, int pp, int tg, int pl, int nr);
|
|
687
|
-
protected static native int applyLoraAdapters(long contextPtr, ReadableArray loraAdapters);
|
|
688
|
-
protected static native void removeLoraAdapters(long contextPtr);
|
|
689
|
-
protected static native WritableArray getLoadedLoraAdapters(long contextPtr);
|
|
690
|
-
protected static native void rewind(long contextPtr);
|
|
691
|
-
protected static native void freeContext(long contextPtr);
|
|
692
|
-
protected static native void setupLog(NativeLogCallback logCallback);
|
|
693
|
-
protected static native void unsetLog();
|
|
694
|
-
|
|
695
|
-
protected static native boolean initMultimodal(long contextPtr, String mmprojPath, boolean useGpu);
|
|
696
|
-
protected static native boolean isMultimodalEnabled(long contextPtr);
|
|
697
|
-
protected static native boolean isMultimodalSupportVision(long contextPtr);
|
|
698
|
-
protected static native boolean isMultimodalSupportAudio(long contextPtr);
|
|
699
|
-
protected static native void releaseMultimodal(long contextPtr);
|
|
700
|
-
protected static native WritableMap doMultimodalCompletion(
|
|
701
|
-
long contextPtr,
|
|
702
|
-
String prompt,
|
|
703
|
-
String[] mediaPaths,
|
|
704
|
-
int chat_format,
|
|
705
|
-
String grammar,
|
|
706
|
-
String json_schema,
|
|
707
|
-
boolean grammar_lazy,
|
|
708
|
-
ReadableArray grammar_triggers,
|
|
709
|
-
ReadableArray preserved_tokens,
|
|
710
|
-
float temperature,
|
|
711
|
-
int n_threads,
|
|
712
|
-
int n_predict,
|
|
713
|
-
int n_probs,
|
|
714
|
-
int penalty_last_n,
|
|
715
|
-
float penalty_repeat,
|
|
716
|
-
float penalty_freq,
|
|
717
|
-
float penalty_present,
|
|
718
|
-
float mirostat,
|
|
719
|
-
float mirostat_tau,
|
|
720
|
-
float mirostat_eta,
|
|
721
|
-
int top_k,
|
|
722
|
-
float top_p,
|
|
723
|
-
float min_p,
|
|
724
|
-
float xtc_threshold,
|
|
725
|
-
float xtc_probability,
|
|
726
|
-
float typical_p,
|
|
727
|
-
int seed,
|
|
728
|
-
String[] stop,
|
|
729
|
-
boolean ignore_eos,
|
|
730
|
-
double[][] logit_bias,
|
|
731
|
-
float dry_multiplier,
|
|
732
|
-
float dry_base,
|
|
733
|
-
int dry_allowed_length,
|
|
734
|
-
int dry_penalty_last_n,
|
|
735
|
-
float top_n_sigma,
|
|
736
|
-
String[] dry_sequence_breakers,
|
|
737
|
-
PartialCompletionCallback partial_completion_callback
|
|
738
|
-
);
|
|
739
|
-
protected static native WritableMap tokenize(long contextPtr, String text, String[] mediaPaths);
|
|
740
|
-
|
|
741
|
-
protected static native boolean initVocoder(long contextPtr, String vocoderModelPath);
|
|
742
|
-
protected static native boolean isVocoderEnabled(long contextPtr);
|
|
743
|
-
protected static native int getTTSType(long contextPtr);
|
|
744
|
-
protected static native String getFormattedAudioCompletion(long contextPtr, String speakerJsonStr, String textToSpeak);
|
|
745
|
-
protected static native WritableArray getAudioCompletionGuideTokens(long contextPtr, String textToSpeak);
|
|
746
|
-
protected static native WritableArray decodeAudioTokens(long contextPtr, int[] tokens);
|
|
747
|
-
protected static native void releaseVocoder(long contextPtr);
|
|
748
|
-
}
|