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
package/README.md
CHANGED
|
@@ -1,104 +1,585 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
Official React-Native plugin for Cactus, a framework for deploying LLM/VLM/TTS models locally in your app. Requires iOS 12.0+, Android API 24+ and Yarn. For iOS apps, ensure you have cocoapods or install with `brew install cocoapods`. For Android apps, you need Java 17 installed. Expo is strongly recommended.
|
|
4
|
-
|
|
5
3
|
## Resources
|
|
4
|
+
|
|
6
5
|
[](https://github.com/cactus-compute/cactus) [](https://huggingface.co/Cactus-Compute/models?sort=downloads) [](https://discord.gg/bNurx3AXTJ) [](https://cactuscompute.com/docs/react-native)
|
|
7
6
|
|
|
8
7
|
## Installation
|
|
9
|
-
|
|
8
|
+
|
|
10
9
|
```bash
|
|
11
|
-
npm install cactus-react-native
|
|
12
|
-
# or
|
|
13
|
-
yarn add cactus-react-native
|
|
10
|
+
npm install cactus-react-native react-native-nitro-modules
|
|
14
11
|
```
|
|
15
|
-
*N/B*: To build locally or use this repo, see instructions in `example/README.md`
|
|
16
12
|
|
|
17
|
-
##
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Get started with Cactus in just a few lines of code:
|
|
16
|
+
|
|
18
17
|
```typescript
|
|
19
|
-
import { CactusLM } from 'cactus-react-native';
|
|
18
|
+
import { CactusLM, type Message } from 'cactus-react-native';
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// Create a new instance
|
|
21
|
+
const cactusLM = new CactusLM();
|
|
22
|
+
|
|
23
|
+
// Download the model
|
|
24
|
+
await cactusLM.download({
|
|
25
|
+
onProgress: (progress) => console.log(`Download: ${Math.round(progress * 100)}%`)
|
|
24
26
|
});
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
// Generate a completion
|
|
29
|
+
const messages: Message[] = [
|
|
30
|
+
{ role: 'user', content: 'What is the capital of France?' }
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const result = await cactusLM.complete({ messages });
|
|
34
|
+
console.log(result.response); // "The capital of France is Paris."
|
|
35
|
+
|
|
36
|
+
// Clean up resources
|
|
37
|
+
await cactusLM.destroy();
|
|
29
38
|
```
|
|
30
|
-
## Embeddings
|
|
31
|
-
```typescript
|
|
32
|
-
import { CactusLM } from 'cactus-react-native';
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
40
|
+
**Using the React Hook:**
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { useCactusLM } from 'cactus-react-native';
|
|
39
44
|
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
45
|
+
const App = () => {
|
|
46
|
+
const cactusLM = useCactusLM();
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
// Download the model if not already available
|
|
50
|
+
if (!cactusLM.isDownloaded) {
|
|
51
|
+
cactusLM.download();
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
const handleGenerate = () => {
|
|
56
|
+
// Generate a completion
|
|
57
|
+
cactusLM.complete({
|
|
58
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (cactusLM.isDownloading) {
|
|
63
|
+
return (
|
|
64
|
+
<Text>
|
|
65
|
+
Downloading model: {Math.round(cactusLM.downloadProgress * 100)}%
|
|
66
|
+
</Text>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<>
|
|
72
|
+
<Button onPress={handleGenerate} title="Generate" />
|
|
73
|
+
<Text>{cactusLM.completion}</Text>
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
43
77
|
```
|
|
44
|
-
|
|
78
|
+
|
|
79
|
+
## Language Model
|
|
80
|
+
|
|
81
|
+
### Completion
|
|
82
|
+
|
|
83
|
+
Generate text responses from the model by providing a conversation history.
|
|
84
|
+
|
|
85
|
+
#### Class
|
|
86
|
+
|
|
45
87
|
```typescript
|
|
46
|
-
import {
|
|
88
|
+
import { CactusLM, type Message } from 'cactus-react-native';
|
|
47
89
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
90
|
+
const cactusLM = new CactusLM();
|
|
91
|
+
|
|
92
|
+
const messages: Message[] = [{ role: 'user', content: 'Hello, World!' }];
|
|
93
|
+
const onToken = (token: string) => { console.log('Token:', token) };
|
|
94
|
+
|
|
95
|
+
const result = await cactusLM.complete({ messages, onToken });
|
|
96
|
+
console.log('Completion result:', result);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Hook
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { useCactusLM, type Message } from 'cactus-react-native';
|
|
52
103
|
|
|
53
|
-
const
|
|
104
|
+
const App = () => {
|
|
105
|
+
const cactusLM = useCactusLM();
|
|
54
106
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
107
|
+
const handleComplete = async () => {
|
|
108
|
+
const messages: Message[] = [{ role: 'user', content: 'Hello, World!' }];
|
|
109
|
+
|
|
110
|
+
const result = await cactusLM.complete({ messages });
|
|
111
|
+
console.log('Completion result:', result);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<>
|
|
116
|
+
<Button title="Complete" onPress={handleComplete} />
|
|
117
|
+
<Text>{cactusLM.completion}</Text>
|
|
118
|
+
</>
|
|
119
|
+
);
|
|
59
120
|
};
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Vision
|
|
124
|
+
|
|
125
|
+
Vision allows you to pass images along with text prompts, enabling the model to analyze and understand visual content.
|
|
126
|
+
|
|
127
|
+
#### Class
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { CactusLM, type Message } from 'cactus-react-native';
|
|
131
|
+
|
|
132
|
+
// Vision-capable model
|
|
133
|
+
const cactusLM = new CactusLM({ model: 'lfm2-vl-450m' });
|
|
134
|
+
|
|
135
|
+
const messages: Message[] = [
|
|
136
|
+
{
|
|
137
|
+
role: 'user',
|
|
138
|
+
content: "What's in the image?",
|
|
139
|
+
images: ['path/to/your/image'],
|
|
140
|
+
},
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
const result = await cactusLM.complete({ messages });
|
|
144
|
+
console.log('Response:', result.response);
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Hook
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import { useCactusLM, type Message } from 'cactus-react-native';
|
|
151
|
+
|
|
152
|
+
const App = () => {
|
|
153
|
+
// Vision-capable model
|
|
154
|
+
const cactusLM = useCactusLM({ model: 'lfm2-vl-450m' });
|
|
155
|
+
|
|
156
|
+
const handleAnalyze = async () => {
|
|
157
|
+
const messages: Message[] = [
|
|
158
|
+
{
|
|
159
|
+
role: 'user',
|
|
160
|
+
content: "What's in the image?",
|
|
161
|
+
images: ['path/to/your/image'],
|
|
162
|
+
},
|
|
163
|
+
];
|
|
60
164
|
|
|
61
|
-
|
|
165
|
+
await cactusLM.complete({ messages });
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<>
|
|
170
|
+
<Button title="Analyze Image" onPress={handleAnalyze} />
|
|
171
|
+
<Text>{cactusLM.completion}</Text>
|
|
172
|
+
</>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
62
175
|
```
|
|
63
|
-
|
|
176
|
+
|
|
177
|
+
### Tool Calling
|
|
178
|
+
|
|
179
|
+
Enable the model to generate function calls by defining available tools and their parameters.
|
|
180
|
+
|
|
181
|
+
#### Class
|
|
182
|
+
|
|
64
183
|
```typescript
|
|
65
|
-
|
|
66
|
-
model: '/path/to/model.gguf',
|
|
67
|
-
n_ctx: 2048,
|
|
68
|
-
}, undefined, 'your_cactus_token');
|
|
184
|
+
import { CactusLM, type Message, type Tool } from 'cactus-react-native';
|
|
69
185
|
|
|
70
|
-
|
|
71
|
-
|
|
186
|
+
const tools: Tool[] = [
|
|
187
|
+
{
|
|
188
|
+
type: 'function',
|
|
189
|
+
name: 'get_weather',
|
|
190
|
+
description: 'Get current weather for a location',
|
|
191
|
+
parameters: {
|
|
192
|
+
type: 'object',
|
|
193
|
+
properties: {
|
|
194
|
+
location: {
|
|
195
|
+
type: 'string',
|
|
196
|
+
description: 'City name',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
required: ['location'],
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
];
|
|
72
203
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
204
|
+
const cactusLM = new CactusLM();
|
|
205
|
+
|
|
206
|
+
const messages: Message[] = [
|
|
207
|
+
{ role: 'user', content: "What's the weather in San Francisco?" },
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
const result = await cactusLM.complete({ messages, tools });
|
|
211
|
+
console.log('Response:', result.response);
|
|
212
|
+
console.log('Function calls:', result.functionCalls);
|
|
77
213
|
```
|
|
78
214
|
|
|
79
|
-
|
|
215
|
+
#### Hook
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
import { useCactusLM, type Message, type Tool } from 'cactus-react-native';
|
|
219
|
+
|
|
220
|
+
const tools: Tool[] = [
|
|
221
|
+
{
|
|
222
|
+
type: 'function',
|
|
223
|
+
name: 'get_weather',
|
|
224
|
+
description: 'Get current weather for a location',
|
|
225
|
+
parameters: {
|
|
226
|
+
type: 'object',
|
|
227
|
+
properties: {
|
|
228
|
+
location: {
|
|
229
|
+
type: 'string',
|
|
230
|
+
description: 'City name',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
required: ['location'],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
|
|
238
|
+
const App = () => {
|
|
239
|
+
const cactusLM = useCactusLM();
|
|
240
|
+
|
|
241
|
+
const handleComplete = async () => {
|
|
242
|
+
const messages: Message[] = [
|
|
243
|
+
{ role: 'user', content: "What's the weather in San Francisco?" },
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
const result = await cactusLM.complete({ messages, tools });
|
|
247
|
+
console.log('Response:', result.response);
|
|
248
|
+
console.log('Function calls:', result.functionCalls);
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
return <Button title="Complete" onPress={handleComplete} />;
|
|
252
|
+
};
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### RAG (Retrieval Augmented Generation)
|
|
256
|
+
|
|
257
|
+
RAG allows you to provide a corpus of documents that the model can reference during generation, enabling it to answer questions based on your data.
|
|
258
|
+
|
|
259
|
+
#### Class
|
|
260
|
+
|
|
80
261
|
```typescript
|
|
81
|
-
import {
|
|
262
|
+
import { CactusLM, type Message } from 'cactus-react-native';
|
|
82
263
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
model: '/path/to/model.gguf',
|
|
86
|
-
n_ctx: 2048,
|
|
264
|
+
const cactusLM = new CactusLM({
|
|
265
|
+
corpusDir: 'path/to/your/corpus', // Directory containing .txt files
|
|
87
266
|
});
|
|
88
267
|
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{
|
|
93
|
-
location: { type: 'string', description: 'City name', required: true }
|
|
94
|
-
}
|
|
95
|
-
);
|
|
268
|
+
const messages: Message[] = [
|
|
269
|
+
{ role: 'user', content: 'What information is in the documents?' },
|
|
270
|
+
];
|
|
96
271
|
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
272
|
+
const result = await cactusLM.complete({ messages });
|
|
273
|
+
console.log(result.response);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### Hook
|
|
277
|
+
|
|
278
|
+
```tsx
|
|
279
|
+
import { useCactusLM, type Message } from 'cactus-react-native';
|
|
280
|
+
|
|
281
|
+
const App = () => {
|
|
282
|
+
const cactusLM = useCactusLM({
|
|
283
|
+
corpusDir: 'path/to/your/corpus', // Directory containing .txt files
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const handleAsk = async () => {
|
|
287
|
+
const messages: Message[] = [
|
|
288
|
+
{ role: 'user', content: 'What information is in the documents?' },
|
|
289
|
+
];
|
|
290
|
+
|
|
291
|
+
await cactusLM.complete({ messages });
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<>
|
|
296
|
+
<Button title="Ask Question" onPress={handleAsk} />
|
|
297
|
+
<Text>{cactusLM.completion}</Text>
|
|
298
|
+
</>
|
|
299
|
+
);
|
|
300
|
+
};
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Embedding
|
|
304
|
+
|
|
305
|
+
Convert text into numerical vector representations that capture semantic meaning, useful for similarity search and semantic understanding.
|
|
306
|
+
|
|
307
|
+
#### Class
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
import { CactusLM } from 'cactus-react-native';
|
|
311
|
+
|
|
312
|
+
const cactusLM = new CactusLM();
|
|
313
|
+
|
|
314
|
+
const result = await cactusLM.embed({ text: 'Hello, World!' });
|
|
315
|
+
console.log('Embedding vector:', result.embedding);
|
|
316
|
+
console.log('Embedding vector length:', result.embedding.length);
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### Hook
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
import { useCactusLM } from 'cactus-react-native';
|
|
323
|
+
|
|
324
|
+
const App = () => {
|
|
325
|
+
const cactusLM = useCactusLM();
|
|
326
|
+
|
|
327
|
+
const handleEmbed = async () => {
|
|
328
|
+
const result = await cactusLM.embed({ text: 'Hello, World!' });
|
|
329
|
+
console.log('Embedding vector:', result.embedding);
|
|
330
|
+
console.log('Embedding vector length:', result.embedding.length);
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
return <Button title="Embed" onPress={handleEmbed} />;
|
|
334
|
+
};
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## API Reference
|
|
338
|
+
|
|
339
|
+
### CactusLM Class
|
|
340
|
+
|
|
341
|
+
#### Constructor
|
|
342
|
+
|
|
343
|
+
**`new CactusLM(params?: CactusLMParams)`**
|
|
344
|
+
|
|
345
|
+
**Parameters:**
|
|
346
|
+
- `model` - Model slug (default: `'qwen3-0.6'`).
|
|
347
|
+
- `contextSize` - Context window size (default: `2048`).
|
|
348
|
+
- `corpusDir` - Directory containing text files for RAG (default: `undefined`).
|
|
349
|
+
|
|
350
|
+
#### Methods
|
|
351
|
+
|
|
352
|
+
**`download(params?: CactusLMDownloadParams): Promise<void>`**
|
|
353
|
+
|
|
354
|
+
Downloads the model. If the model is already downloaded, returns immediately with progress at 100%. Throws an error if a download is already in progress. Automatically refreshes the models list after successful download.
|
|
355
|
+
|
|
356
|
+
**Parameters:**
|
|
357
|
+
- `onProgress` - Callback for download progress (0-1).
|
|
358
|
+
|
|
359
|
+
**`init(): Promise<void>`**
|
|
360
|
+
|
|
361
|
+
Initializes the model and prepares it for inference. Safe to call multiple times (idempotent). Throws an error if the model is not downloaded yet. Automatically initializes telemetry if not already done.
|
|
362
|
+
|
|
363
|
+
**`complete(params: CactusLMCompleteParams): Promise<CactusLMCompleteResult>`**
|
|
364
|
+
|
|
365
|
+
Performs text completion with optional streaming and tool support. Automatically calls `init()` if not already initialized. Throws an error if a generation (completion or embedding) is already in progress.
|
|
366
|
+
|
|
367
|
+
**Parameters:**
|
|
368
|
+
- `messages` - Array of `Message` objects.
|
|
369
|
+
- `options` - Generation options:
|
|
370
|
+
- `temperature` - Sampling temperature (default: model-optimized).
|
|
371
|
+
- `topP` - Nucleus sampling threshold (default: model-optimized).
|
|
372
|
+
- `topK` - Top-K sampling limit (default: model-optimized).
|
|
373
|
+
- `maxTokens` - Maximum number of tokens to generate (default: `512`).
|
|
374
|
+
- `stopSequences` - Array of strings to stop generation (default: `undefined`).
|
|
375
|
+
- `tools` - Array of `Tool` objects for function calling (default: `undefined`).
|
|
376
|
+
- `onToken` - Callback for streaming tokens.
|
|
377
|
+
|
|
378
|
+
**`embed(params: CactusLMEmbedParams): Promise<CactusLMEmbedResult>`**
|
|
379
|
+
|
|
380
|
+
Generates embeddings for the given text. Automatically calls `init()` if not already initialized. Throws an error if a generation (completion or embedding) is already in progress.
|
|
381
|
+
|
|
382
|
+
**Parameters:**
|
|
383
|
+
- `text` - Text to embed.
|
|
384
|
+
|
|
385
|
+
**`stop(): Promise<void>`**
|
|
386
|
+
|
|
387
|
+
Stops ongoing generation.
|
|
388
|
+
|
|
389
|
+
**`reset(): Promise<void>`**
|
|
390
|
+
|
|
391
|
+
Resets the model's internal state, clearing any cached context. Automatically calls `stop()` first.
|
|
392
|
+
|
|
393
|
+
**`destroy(): Promise<void>`**
|
|
394
|
+
|
|
395
|
+
Releases all resources associated with the model. Automatically calls `stop()` first. Safe to call even if the model is not initialized.
|
|
396
|
+
|
|
397
|
+
**`getModels(params?: CactusLMGetModelsParams): Promise<CactusModel[]>`**
|
|
398
|
+
|
|
399
|
+
Fetches available models and persists the results locally for caching. Returns cached results if available, unless `forceRefresh` is `true`. Checks the download status for each model and includes it in the results.
|
|
400
|
+
|
|
401
|
+
**Parameters:**
|
|
402
|
+
- `forceRefresh` - If `true`, fetches from the server and updates the local cache (default: `false`).
|
|
403
|
+
|
|
404
|
+
### useCactusLM Hook
|
|
405
|
+
|
|
406
|
+
The `useCactusLM` hook manages a `CactusLM` instance with reactive state. When model parameters (`model`, `contextSize`, or `corpusDir`) change, the hook creates a new instance and resets all state. The hook automatically cleans up resources when the component unmounts.
|
|
407
|
+
|
|
408
|
+
#### State
|
|
409
|
+
|
|
410
|
+
- `completion: string` - Current generated text. Automatically accumulated during streaming. Cleared before each new completion and when calling `reset()` or `destroy()`.
|
|
411
|
+
- `isGenerating: boolean` - Whether the model is currently generating (completion or embedding). Both operations share this flag.
|
|
412
|
+
- `isInitializing: boolean` - Whether the model is initializing.
|
|
413
|
+
- `isDownloaded: boolean` - Whether the model is downloaded locally. Automatically checked when the hook mounts or model changes.
|
|
414
|
+
- `isDownloading: boolean` - Whether the model is being downloaded.
|
|
415
|
+
- `downloadProgress: number` - Download progress (0-1). Reset to `0` after download completes.
|
|
416
|
+
- `error: string | null` - Last error message from any operation, or `null` if there is no error. Cleared before starting new operations.
|
|
417
|
+
|
|
418
|
+
#### Methods
|
|
419
|
+
|
|
420
|
+
- `download(params?: CactusLMDownloadParams): Promise<void>` - Downloads the model. Updates `isDownloading` and `downloadProgress` state during download. Sets `isDownloaded` to `true` on success.
|
|
421
|
+
- `init(): Promise<void>` - Initializes the model for inference. Sets `isInitializing` to `true` during initialization.
|
|
422
|
+
- `complete(params: CactusLMCompleteParams): Promise<CactusLMCompleteResult>` - Generates text completions. Automatically accumulates tokens in the `completion` state during streaming. Sets `isGenerating` to `true` while generating. Clears `completion` before starting.
|
|
423
|
+
- `embed(params: CactusLMEmbedParams): Promise<CactusLMEmbedResult>` - Generates embeddings for the given text. Sets `isGenerating` to `true` during operation.
|
|
424
|
+
- `stop(): Promise<void>` - Stops ongoing generation. Clears any errors.
|
|
425
|
+
- `reset(): Promise<void>` - Resets the model's internal state, clearing cached context. Also clears the `completion` state.
|
|
426
|
+
- `destroy(): Promise<void>` - Releases all resources associated with the model. Clears the `completion` state. Automatically called when the component unmounts.
|
|
427
|
+
- `getModels(params?: CactusLMGetModelsParams): Promise<CactusModel[]>` - Fetches available models and returns them. Results are cached locally.
|
|
428
|
+
|
|
429
|
+
## Type Definitions
|
|
430
|
+
|
|
431
|
+
### CactusLMParams
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
interface CactusLMParams {
|
|
435
|
+
model?: string;
|
|
436
|
+
contextSize?: number;
|
|
437
|
+
corpusDir?: string;
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### CactusLMDownloadParams
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
interface CactusLMDownloadParams {
|
|
445
|
+
onProgress?: (progress: number) => void;
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### Message
|
|
450
|
+
|
|
451
|
+
```typescript
|
|
452
|
+
interface Message {
|
|
453
|
+
role: 'user' | 'assistant' | 'system';
|
|
454
|
+
content?: string;
|
|
455
|
+
images?: string[];
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Options
|
|
460
|
+
|
|
461
|
+
```typescript
|
|
462
|
+
interface Options {
|
|
463
|
+
temperature?: number;
|
|
464
|
+
topP?: number;
|
|
465
|
+
topK?: number;
|
|
466
|
+
maxTokens?: number;
|
|
467
|
+
stopSequences?: string[];
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Tool
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
interface Tool {
|
|
475
|
+
type: 'function';
|
|
476
|
+
name: string;
|
|
477
|
+
description: string;
|
|
478
|
+
parameters: {
|
|
479
|
+
type: 'object';
|
|
480
|
+
properties: {
|
|
481
|
+
[key: string]: {
|
|
482
|
+
type: string;
|
|
483
|
+
description: string;
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
required: string[];
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### CactusLMCompleteParams
|
|
492
|
+
|
|
493
|
+
```typescript
|
|
494
|
+
interface CactusLMCompleteParams {
|
|
495
|
+
messages: Message[];
|
|
496
|
+
options?: Options;
|
|
497
|
+
tools?: Tool[];
|
|
498
|
+
onToken?: (token: string) => void;
|
|
499
|
+
}
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### CactusLMCompleteResult
|
|
503
|
+
|
|
504
|
+
```typescript
|
|
505
|
+
interface CactusLMCompleteResult {
|
|
506
|
+
success: boolean;
|
|
507
|
+
response: string;
|
|
508
|
+
functionCalls?: {
|
|
509
|
+
name: string;
|
|
510
|
+
arguments: { [key: string]: any };
|
|
511
|
+
}[];
|
|
512
|
+
timeToFirstTokenMs: number;
|
|
513
|
+
totalTimeMs: number;
|
|
514
|
+
tokensPerSecond: number;
|
|
515
|
+
prefillTokens: number;
|
|
516
|
+
decodeTokens: number;
|
|
517
|
+
totalTokens: number;
|
|
518
|
+
}
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### CactusLMEmbedParams
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
interface CactusLMEmbedParams {
|
|
525
|
+
text: string;
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### CactusLMEmbedResult
|
|
530
|
+
|
|
531
|
+
```typescript
|
|
532
|
+
interface CactusLMEmbedResult {
|
|
533
|
+
embedding: number[];
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### CactusLMGetModelsParams
|
|
538
|
+
|
|
539
|
+
```typescript
|
|
540
|
+
interface CactusLMGetModelsParams {
|
|
541
|
+
forceRefresh?: boolean;
|
|
542
|
+
}
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### CactusModel
|
|
546
|
+
|
|
547
|
+
```typescript
|
|
548
|
+
interface CactusModel {
|
|
549
|
+
name: string;
|
|
550
|
+
slug: string;
|
|
551
|
+
quantization: number;
|
|
552
|
+
sizeMb: number;
|
|
553
|
+
downloadUrl: string;
|
|
554
|
+
supportsToolCalling: boolean;
|
|
555
|
+
supportsVision: boolean;
|
|
556
|
+
createdAt: Date;
|
|
557
|
+
isDownloaded: boolean;
|
|
558
|
+
}
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
## Configuration
|
|
562
|
+
|
|
563
|
+
### Telemetry
|
|
564
|
+
|
|
565
|
+
Cactus offers powerful telemetry for all your projects. Create a token on the [Cactus dashboard](https://www.cactuscompute.com/dashboard).
|
|
566
|
+
|
|
567
|
+
```typescript
|
|
568
|
+
import { CactusConfig } from 'cactus-react-native';
|
|
569
|
+
|
|
570
|
+
// Enable Telemetry for your project
|
|
571
|
+
CactusConfig.telemetryToken = 'your-token-here';
|
|
572
|
+
|
|
573
|
+
// Disable telemetry
|
|
574
|
+
CactusConfig.isTelemetryEnabled = false;
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
## Performance Tips
|
|
578
|
+
|
|
579
|
+
- **Model Selection** - Choose smaller models for faster inference on mobile devices.
|
|
580
|
+
- **Context Size** - Reduce the context size to lower memory usage.
|
|
581
|
+
- **Memory Management** - Always call `destroy()` when you're done with models to free up resources.
|
|
582
|
+
|
|
583
|
+
## Example App
|
|
102
584
|
|
|
103
|
-
|
|
104
|
-
```
|
|
585
|
+
Check out [our example app](/example) for a complete React Native implementation.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
project(cactus)
|
|
2
|
+
cmake_minimum_required(VERSION 3.9.0)
|
|
3
|
+
|
|
4
|
+
set(PACKAGE_NAME cactus)
|
|
5
|
+
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
7
|
+
|
|
8
|
+
# Define C++ library and add all sources
|
|
9
|
+
add_library(${PACKAGE_NAME} SHARED
|
|
10
|
+
src/main/cpp/cpp-adapter.cpp
|
|
11
|
+
../cpp/HybridCactus.cpp
|
|
12
|
+
../cpp/HybridCactusUtil.cpp
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
add_library(libcactus STATIC IMPORTED)
|
|
16
|
+
set_target_properties(libcactus PROPERTIES
|
|
17
|
+
IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/src/main/jniLibs/${ANDROID_ABI}/libcactus.a"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
add_library(libcactus_util SHARED IMPORTED)
|
|
21
|
+
set_target_properties(libcactus_util PROPERTIES
|
|
22
|
+
IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/src/main/jniLibs/${ANDROID_ABI}/libcactus_util.so"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Add Nitrogen specs :)
|
|
26
|
+
include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/cactus+autolinking.cmake)
|
|
27
|
+
|
|
28
|
+
# Set up local includes
|
|
29
|
+
include_directories("src/main/cpp" "../cpp")
|
|
30
|
+
|
|
31
|
+
find_library(LOG_LIB log)
|
|
32
|
+
|
|
33
|
+
# Link all libraries together
|
|
34
|
+
target_link_libraries(
|
|
35
|
+
${PACKAGE_NAME}
|
|
36
|
+
${LOG_LIB}
|
|
37
|
+
android # <-- Android core
|
|
38
|
+
libcactus
|
|
39
|
+
libcactus_util
|
|
40
|
+
)
|