cactus-react-native 0.2.11 → 1.0.1
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 +354 -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_2_dotprod.so → libcactus.a} +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus_util.so +0 -0
- package/cpp/HybridCactus.cpp +123 -0
- package/cpp/HybridCactus.hpp +35 -0
- package/cpp/HybridCactusUtil.cpp +45 -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 +347 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ffi_utils.h +286 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +319 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +254 -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 +347 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/ffi_utils.h +286 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +319 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +254 -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 +149 -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 +233 -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 +25 -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 +65 -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 +203 -0
- package/src/config/CactusConfig.ts +4 -0
- package/src/constants/packageVersion.ts +1 -0
- package/src/hooks/useCactusLM.ts +282 -0
- package/src/index.tsx +23 -0
- package/src/native/Cactus.ts +79 -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 +16 -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 +71 -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.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_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/lib/commonjs/lm.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CactusLM = void 0;
|
|
7
|
-
var _index = require("./index");
|
|
8
|
-
var _telemetry = require("./telemetry");
|
|
9
|
-
var _remote = require("./remote");
|
|
10
|
-
var _chat = require("./chat");
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
|
|
13
|
-
class CactusLM {
|
|
14
|
-
static _initCache = new Map();
|
|
15
|
-
static getCacheKey(params, cactusToken, retryOptions) {
|
|
16
|
-
return JSON.stringify({
|
|
17
|
-
params,
|
|
18
|
-
cactusToken,
|
|
19
|
-
retryOptions
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
constructor(context, initParams) {
|
|
23
|
-
this.context = context;
|
|
24
|
-
this.initParams = initParams;
|
|
25
|
-
this.conversationHistoryManager = new _chat.ConversationHistoryManager();
|
|
26
|
-
}
|
|
27
|
-
static isContextNotFoundError(e) {
|
|
28
|
-
const message = String(e?.message ?? e ?? '');
|
|
29
|
-
return /context not found/i.test(message);
|
|
30
|
-
}
|
|
31
|
-
async reinit() {
|
|
32
|
-
const newContext = await (0, _index.initLlama)(this.initParams);
|
|
33
|
-
this.context = newContext;
|
|
34
|
-
this.conversationHistoryManager.reset();
|
|
35
|
-
}
|
|
36
|
-
async run(op) {
|
|
37
|
-
try {
|
|
38
|
-
return await op();
|
|
39
|
-
} catch (e) {
|
|
40
|
-
if (!CactusLM.isContextNotFoundError(e)) throw e;
|
|
41
|
-
await this.reinit();
|
|
42
|
-
return await op();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
static async init(params, onProgress, cactusToken, retryOptions) {
|
|
46
|
-
if (cactusToken) {
|
|
47
|
-
(0, _remote.setCactusToken)(cactusToken);
|
|
48
|
-
}
|
|
49
|
-
const key = CactusLM.getCacheKey(params, cactusToken, retryOptions);
|
|
50
|
-
if (CactusLM._initCache.has(key)) {
|
|
51
|
-
return CactusLM._initCache.get(key);
|
|
52
|
-
}
|
|
53
|
-
const initPromise = (async () => {
|
|
54
|
-
const maxRetries = retryOptions?.maxRetries ?? 3;
|
|
55
|
-
const delayMs = retryOptions?.delayMs ?? 1000;
|
|
56
|
-
const configs = [params, {
|
|
57
|
-
...params,
|
|
58
|
-
n_gpu_layers: 0
|
|
59
|
-
}];
|
|
60
|
-
const sleep = ms => {
|
|
61
|
-
return new Promise(resolve => {
|
|
62
|
-
const start = Date.now();
|
|
63
|
-
const wait = () => {
|
|
64
|
-
if (Date.now() - start >= ms) {
|
|
65
|
-
resolve();
|
|
66
|
-
} else {
|
|
67
|
-
Promise.resolve().then(wait);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
wait();
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
for (const config of configs) {
|
|
74
|
-
let lastError = null;
|
|
75
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
76
|
-
try {
|
|
77
|
-
const context = await (0, _index.initLlama)(config, onProgress);
|
|
78
|
-
return {
|
|
79
|
-
lm: new CactusLM(context, config),
|
|
80
|
-
error: null
|
|
81
|
-
};
|
|
82
|
-
} catch (e) {
|
|
83
|
-
lastError = e;
|
|
84
|
-
const isLastConfig = configs.indexOf(config) === configs.length - 1;
|
|
85
|
-
const isLastAttempt = attempt === maxRetries;
|
|
86
|
-
_telemetry.Telemetry.error(e, {
|
|
87
|
-
n_gpu_layers: config.n_gpu_layers ?? null,
|
|
88
|
-
n_ctx: config.n_ctx ?? null,
|
|
89
|
-
model: config.model ?? null
|
|
90
|
-
});
|
|
91
|
-
if (!isLastAttempt) {
|
|
92
|
-
const delay = delayMs * Math.pow(2, attempt - 1);
|
|
93
|
-
await sleep(delay);
|
|
94
|
-
} else if (!isLastConfig) {
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (configs.indexOf(config) === configs.length - 1 && lastError) {
|
|
100
|
-
return {
|
|
101
|
-
lm: null,
|
|
102
|
-
error: lastError
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
lm: null,
|
|
108
|
-
error: new Error('Failed to initialize CactusLM after all retries')
|
|
109
|
-
};
|
|
110
|
-
})();
|
|
111
|
-
CactusLM._initCache.set(key, initPromise);
|
|
112
|
-
const result = await initPromise;
|
|
113
|
-
// Cache only while in-flight; never cache resolved instances
|
|
114
|
-
CactusLM._initCache.delete(key);
|
|
115
|
-
return result;
|
|
116
|
-
}
|
|
117
|
-
completion = async (messages, params = {}, callback) => {
|
|
118
|
-
const mode = params.mode || 'local';
|
|
119
|
-
let result;
|
|
120
|
-
let lastError = null;
|
|
121
|
-
if (mode === 'remote') {
|
|
122
|
-
result = await this._handleRemoteCompletion(messages, callback);
|
|
123
|
-
} else if (mode === 'local') {
|
|
124
|
-
result = await this._handleLocalCompletion(messages, params, callback);
|
|
125
|
-
} else if (mode === 'localfirst') {
|
|
126
|
-
try {
|
|
127
|
-
result = await this._handleLocalCompletion(messages, params, callback);
|
|
128
|
-
} catch (e) {
|
|
129
|
-
lastError = e;
|
|
130
|
-
try {
|
|
131
|
-
result = await this._handleRemoteCompletion(messages, callback);
|
|
132
|
-
} catch (remoteError) {
|
|
133
|
-
throw lastError;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
} else if (mode === 'remotefirst') {
|
|
137
|
-
try {
|
|
138
|
-
result = await this._handleRemoteCompletion(messages, callback);
|
|
139
|
-
} catch (e) {
|
|
140
|
-
lastError = e;
|
|
141
|
-
try {
|
|
142
|
-
result = await this._handleLocalCompletion(messages, params, callback);
|
|
143
|
-
} catch (localError) {
|
|
144
|
-
throw lastError;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
throw new Error('Invalid mode: ' + mode + '. Must be "local", "remote", "localfirst", or "remotefirst"');
|
|
149
|
-
}
|
|
150
|
-
return result;
|
|
151
|
-
};
|
|
152
|
-
_handleLocalCompletion = async (messages, params, callback) => {
|
|
153
|
-
const {
|
|
154
|
-
newMessages,
|
|
155
|
-
requiresReset
|
|
156
|
-
} = this.conversationHistoryManager.processNewMessages(messages);
|
|
157
|
-
if (requiresReset) {
|
|
158
|
-
await this.run(() => this.context.rewind());
|
|
159
|
-
this.conversationHistoryManager.reset();
|
|
160
|
-
}
|
|
161
|
-
if (newMessages.length === 0) {
|
|
162
|
-
console.warn('No messages to complete!');
|
|
163
|
-
}
|
|
164
|
-
const result = await this.run(() => this.context.completion({
|
|
165
|
-
messages: newMessages,
|
|
166
|
-
...params
|
|
167
|
-
}, callback));
|
|
168
|
-
this.conversationHistoryManager.update(newMessages, {
|
|
169
|
-
role: 'assistant',
|
|
170
|
-
content: result.content
|
|
171
|
-
});
|
|
172
|
-
return result;
|
|
173
|
-
};
|
|
174
|
-
async _handleRemoteCompletion(messages, callback) {
|
|
175
|
-
const prompt = messages.map(m => `${m.role}: ${m.content}`).join('\n');
|
|
176
|
-
const responseText = await (0, _remote.getTextCompletion)(messages);
|
|
177
|
-
if (callback) {
|
|
178
|
-
for (let i = 0; i < responseText.length; i++) {
|
|
179
|
-
callback({
|
|
180
|
-
token: responseText[i]
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return {
|
|
185
|
-
text: responseText,
|
|
186
|
-
reasoning_content: '',
|
|
187
|
-
tool_calls: [],
|
|
188
|
-
content: responseText,
|
|
189
|
-
tokens_predicted: responseText.split(' ').length,
|
|
190
|
-
tokens_evaluated: prompt.split(' ').length,
|
|
191
|
-
truncated: false,
|
|
192
|
-
stopped_eos: true,
|
|
193
|
-
stopped_word: '',
|
|
194
|
-
stopped_limit: 0,
|
|
195
|
-
stopping_word: '',
|
|
196
|
-
tokens_cached: 0,
|
|
197
|
-
timings: {
|
|
198
|
-
prompt_n: prompt.split(' ').length,
|
|
199
|
-
prompt_ms: 0,
|
|
200
|
-
prompt_per_token_ms: 0,
|
|
201
|
-
prompt_per_second: 0,
|
|
202
|
-
predicted_n: responseText.split(' ').length,
|
|
203
|
-
predicted_ms: 0,
|
|
204
|
-
predicted_per_token_ms: 0,
|
|
205
|
-
predicted_per_second: 0
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
async embedding(text, params, mode = 'local') {
|
|
210
|
-
let result;
|
|
211
|
-
let lastError = null;
|
|
212
|
-
if (mode === 'remote') {
|
|
213
|
-
result = await this._handleRemoteEmbedding(text);
|
|
214
|
-
} else if (mode === 'local') {
|
|
215
|
-
result = await this._handleLocalEmbedding(text, params);
|
|
216
|
-
} else if (mode === 'localfirst') {
|
|
217
|
-
try {
|
|
218
|
-
result = await this._handleLocalEmbedding(text, params);
|
|
219
|
-
} catch (e) {
|
|
220
|
-
lastError = e;
|
|
221
|
-
try {
|
|
222
|
-
result = await this._handleRemoteEmbedding(text);
|
|
223
|
-
} catch (remoteError) {
|
|
224
|
-
throw lastError;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
} else if (mode === 'remotefirst') {
|
|
228
|
-
try {
|
|
229
|
-
result = await this._handleRemoteEmbedding(text);
|
|
230
|
-
} catch (e) {
|
|
231
|
-
lastError = e;
|
|
232
|
-
try {
|
|
233
|
-
result = await this._handleLocalEmbedding(text, params);
|
|
234
|
-
} catch (localError) {
|
|
235
|
-
throw lastError;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
} else {
|
|
239
|
-
throw new Error('Invalid mode: ' + mode + '. Must be "local", "remote", "localfirst", or "remotefirst"');
|
|
240
|
-
}
|
|
241
|
-
return result;
|
|
242
|
-
}
|
|
243
|
-
async _handleLocalEmbedding(text, params) {
|
|
244
|
-
return this.run(() => this.context.embedding(text, params));
|
|
245
|
-
}
|
|
246
|
-
async _handleRemoteEmbedding(text) {
|
|
247
|
-
const embeddingValues = await (0, _remote.getVertexAIEmbedding)(text);
|
|
248
|
-
return {
|
|
249
|
-
embedding: embeddingValues
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
rewind = async () => {
|
|
253
|
-
return this.run(() => this.context.rewind());
|
|
254
|
-
};
|
|
255
|
-
async release() {
|
|
256
|
-
try {
|
|
257
|
-
return await this.context.release();
|
|
258
|
-
} catch (e) {
|
|
259
|
-
// Treat missing context as already released
|
|
260
|
-
if (CactusLM.isContextNotFoundError(e)) return;
|
|
261
|
-
throw e;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
async stopCompletion() {
|
|
265
|
-
return await this.run(() => this.context.stopCompletion());
|
|
266
|
-
}
|
|
267
|
-
isJinjaSupported() {
|
|
268
|
-
return this.context.isJinjaSupported();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
exports.CactusLM = CactusLM;
|
|
272
|
-
//# sourceMappingURL=lm.js.map
|
package/lib/commonjs/lm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_index","require","_telemetry","_remote","_chat","CactusLM","_initCache","Map","getCacheKey","params","cactusToken","retryOptions","JSON","stringify","constructor","context","initParams","conversationHistoryManager","ConversationHistoryManager","isContextNotFoundError","e","message","String","test","reinit","newContext","initLlama","reset","run","op","init","onProgress","setCactusToken","key","has","get","initPromise","maxRetries","delayMs","configs","n_gpu_layers","sleep","ms","Promise","resolve","start","Date","now","wait","then","config","lastError","attempt","lm","error","isLastConfig","indexOf","length","isLastAttempt","Telemetry","n_ctx","model","delay","Math","pow","Error","set","result","delete","completion","messages","callback","mode","_handleRemoteCompletion","_handleLocalCompletion","remoteError","localError","newMessages","requiresReset","processNewMessages","rewind","console","warn","update","role","content","prompt","map","m","join","responseText","getTextCompletion","i","token","text","reasoning_content","tool_calls","tokens_predicted","split","tokens_evaluated","truncated","stopped_eos","stopped_word","stopped_limit","stopping_word","tokens_cached","timings","prompt_n","prompt_ms","prompt_per_token_ms","prompt_per_second","predicted_n","predicted_ms","predicted_per_token_ms","predicted_per_second","embedding","_handleRemoteEmbedding","_handleLocalEmbedding","embeddingValues","getVertexAIEmbedding","release","stopCompletion","isJinjaSupported","exports"],"sourceRoot":"../../src","sources":["lm.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAYA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAbA;;AAoBO,MAAMI,QAAQ,CAAC;EAIpB,OAAeC,UAAU,GAAyC,IAAIC,GAAG,CAAC,CAAC;EAE3E,OAAeC,WAAWA,CAACC,MAAqB,EAAEC,WAAoB,EAAEC,YAAwD,EAAU;IACxI,OAAOC,IAAI,CAACC,SAAS,CAAC;MAAEJ,MAAM;MAAEC,WAAW;MAAEC;IAAa,CAAC,CAAC;EAC9D;EAEUG,WAAWA,CAACC,OAAqB,EAAEC,UAAyB,EAAE;IACtE,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,0BAA0B,GAAG,IAAIC,gCAA0B,CAAC,CAAC;EACpE;EAEA,OAAeC,sBAAsBA,CAACC,CAAU,EAAW;IACzD,MAAMC,OAAO,GAAGC,MAAM,CAAEF,CAAC,EAAUC,OAAO,IAA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MqG,cAAcA,CAAA,EAAkB;IACpC,OAAO,MAAM,IAAI,CAAC7F,GAAG,CAAC,MAAM,IAAI,CAACb,OAAO,CAAC0G,cAAc,CAAC,CAAC,CAAC;EAC5D;EAEAC,gBAAgBA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAAC3G,OAAO,CAAC2G,gBAAgB,CAAC,CAAC;EACxC;AACF;AAACC,OAAA,CAAAtH,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PROJECT_ID = void 0;
|
|
7
|
-
// DO NOT EDIT. This file is automatically generated by a post-install script.
|
|
8
|
-
const PROJECT_ID = exports.PROJECT_ID = '3bdfa16e-5da9-48dd-9969-794c13230061';
|
|
9
|
-
//# sourceMappingURL=projectId.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["PROJECT_ID","exports"],"sourceRoot":"../../src","sources":["projectId.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,sCAAsC","ignoreList":[]}
|
package/lib/commonjs/remote.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getTextCompletion = getTextCompletion;
|
|
7
|
-
exports.getVertexAICompletion = getVertexAICompletion;
|
|
8
|
-
exports.getVertexAIEmbedding = getVertexAIEmbedding;
|
|
9
|
-
exports.getVisionCompletion = getVisionCompletion;
|
|
10
|
-
exports.getVisionCompletionFromData = getVisionCompletionFromData;
|
|
11
|
-
exports.setCactusToken = setCactusToken;
|
|
12
|
-
let _cactusToken = null;
|
|
13
|
-
function setCactusToken(token) {
|
|
14
|
-
_cactusToken = token;
|
|
15
|
-
}
|
|
16
|
-
async function getVertexAIEmbedding(text) {
|
|
17
|
-
text = text;
|
|
18
|
-
throw new Error('Remote embedding is not currently supported. The Cactus library is in active development - if you need this functionality, please contact us at founders@cactuscompute.com');
|
|
19
|
-
}
|
|
20
|
-
async function getVertexAICompletion(messages, imageData, imagePath, mimeType) {
|
|
21
|
-
if (_cactusToken === null) {
|
|
22
|
-
throw new Error('CactusToken not set. Please call CactusVLM.init with cactusToken parameter.');
|
|
23
|
-
}
|
|
24
|
-
const endpoint = 'https://openrouter.ai/api/v1/chat/completions';
|
|
25
|
-
const headers = {
|
|
26
|
-
'Authorization': `Bearer ${_cactusToken}`,
|
|
27
|
-
'Content-Type': 'application/json'
|
|
28
|
-
};
|
|
29
|
-
const requestBody = {
|
|
30
|
-
model: 'google/gemini-2.5-flash-lite',
|
|
31
|
-
messages: messages
|
|
32
|
-
};
|
|
33
|
-
let imageUrl = '';
|
|
34
|
-
if (imageData) {
|
|
35
|
-
imageUrl = `data:${mimeType || 'image/jpeg'};base64,${imageData}`;
|
|
36
|
-
} else if (imagePath) {
|
|
37
|
-
const RNFS = require('react-native-fs');
|
|
38
|
-
const base64Data = await RNFS.readFile(imagePath, 'base64');
|
|
39
|
-
imageUrl = `data:${mimeType || detectMimeType(imagePath)};base64,${base64Data}`;
|
|
40
|
-
}
|
|
41
|
-
if (imageUrl) {
|
|
42
|
-
if (requestBody.messages[requestBody.messages.length - 1]?.role === 'user') {
|
|
43
|
-
requestBody.messages[requestBody.messages.length - 1] = {
|
|
44
|
-
role: 'user',
|
|
45
|
-
content: [{
|
|
46
|
-
type: 'text',
|
|
47
|
-
text: requestBody.messages[requestBody.messages.length - 1]?.content || ''
|
|
48
|
-
}, {
|
|
49
|
-
type: 'image_url',
|
|
50
|
-
image_url: {
|
|
51
|
-
url: imageUrl
|
|
52
|
-
}
|
|
53
|
-
}]
|
|
54
|
-
};
|
|
55
|
-
} else {
|
|
56
|
-
console.warn('Image data provided but message is not a user message: ', requestBody.messages);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const response = await fetch(endpoint, {
|
|
60
|
-
method: 'POST',
|
|
61
|
-
headers,
|
|
62
|
-
body: JSON.stringify(requestBody)
|
|
63
|
-
});
|
|
64
|
-
if (response.status === 401) {
|
|
65
|
-
_cactusToken = null;
|
|
66
|
-
throw new Error('Authentication failed. Please update your cactusToken.');
|
|
67
|
-
} else if (!response.ok) {
|
|
68
|
-
const errorText = await response.text();
|
|
69
|
-
throw new Error(`HTTP ${response.status}: ${errorText}`);
|
|
70
|
-
}
|
|
71
|
-
const responseBody = await response.json();
|
|
72
|
-
const responseText = responseBody.choices[0].message.content;
|
|
73
|
-
return responseText;
|
|
74
|
-
}
|
|
75
|
-
async function getTextCompletion(messages) {
|
|
76
|
-
return getVertexAICompletion(messages);
|
|
77
|
-
}
|
|
78
|
-
async function getVisionCompletion(messages, imagePath) {
|
|
79
|
-
return getVertexAICompletion(messages, undefined, imagePath);
|
|
80
|
-
}
|
|
81
|
-
async function getVisionCompletionFromData(messages, imageData, mimeType) {
|
|
82
|
-
return getVertexAICompletion(messages, imageData, undefined, mimeType);
|
|
83
|
-
}
|
|
84
|
-
function detectMimeType(filePath) {
|
|
85
|
-
const extension = filePath.toLowerCase().split('.').pop();
|
|
86
|
-
switch (extension) {
|
|
87
|
-
case 'jpg':
|
|
88
|
-
case 'jpeg':
|
|
89
|
-
return 'image/jpeg';
|
|
90
|
-
case 'png':
|
|
91
|
-
return 'image/png';
|
|
92
|
-
case 'gif':
|
|
93
|
-
return 'image/gif';
|
|
94
|
-
case 'webp':
|
|
95
|
-
return 'image/webp';
|
|
96
|
-
default:
|
|
97
|
-
return 'image/jpeg';
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=remote.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_cactusToken","setCactusToken","token","getVertexAIEmbedding","text","Error","getVertexAICompletion","messages","imageData","imagePath","mimeType","endpoint","headers","requestBody","model","imageUrl","RNFS","require","base64Data","readFile","detectMimeType","length","role","content","type","image_url","url","console","warn","response","fetch","method","body","JSON","stringify","status","ok","errorText","responseBody","json","responseText","choices","message","getTextCompletion","getVisionCompletion","undefined","getVisionCompletionFromData","filePath","extension","toLowerCase","split","pop"],"sourceRoot":"../../src","sources":["remote.ts"],"mappings":";;;;;;;;;;;AAEA,IAAIA,YAA2B,GAAG,IAAI;AAE/B,SAASC,cAAcA,CAACC,KAAoB,EAAQ;EACzDF,YAAY,GAAGE,KAAK;AACtB;AAEO,eAAeC,oBAAoBA,CAACC,IAAY,EAAqB;EAC1EA,IAAI,GAAGA,IAAI;EACX,MAAM,IAAIC,KAAK,CAAC,4KAA4K,CAAC;AAC/L;AAEO,eAAeC,qBAAqBA,CACzCC,QAAsC,EACtCC,SAAkB,EAClBC,SAAkB,EAClBC,QAAiB,EACA;EACjB,IAAIV,YAAY,KAAK,IAAI,EAAE;IACzB,MAAM,IAAIK,KAAK,CAAC,6EAA6E,CAAC;EAChG;EACA,MAAMM,QAAQ,GAAG,+CAA+C;EAEhE,MAAMC,OAAO,GAAG;IACd,eAAe,EAAE,UAAUZ,YAAY,EAAE;IACzC,cAAc,EAAE;EAClB,CAAC;EAED,MAAMa,WAAW,GAAG;IAClBC,KAAK,EAAE,8BAA8B;IACrCP,QAAQ,EAAEA;EACZ,CAAC;EAED,IAAIQ,QAAQ,GAAG,EAAE;EACjB,IAAIP,SAAS,EAAE;IACbO,QAAQ,GAAG,QAAQL,QAAQ,IAAI,YAAY,WAAWF,SAAS,EAAE;EACnE,CAAC,MAAM,IAAIC,SAAS,EAAE;IACpB,MAAMO,IAAI,GAAGC,OAAO,CAAC,iBAAiB,CAAC;IACvC,MAAMC,UAAU,GAAG,MAAMF,IAAI,CAACG,QAAQ,CAACV,SAAS,EAAE,QAAQ,CAAC;IAC3DM,QAAQ,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Y,GAAG,MAAMT,QAAQ,CAACU,IAAI,CAAC,CAAC;EAC1C,MAAMC,YAAY,GAAGF,YAAY,CAACG,OAAO,CAAC,CAAC,CAAC,CAACC,OAAO,CAACnB,OAAO;EAE5D,OAAOiB,YAAY;AACrB;AAEO,eAAeG,iBAAiBA,CAACpC,QAAsC,EAAmB;EAC/F,OAAOD,qBAAqB,CAACC,QAAQ,CAAC;AACxC;AAEO,eAAeqC,mBAAmBA,CAACrC,QAAsC,EAAEE,SAAiB,EAAmB;EACpH,OAAOH,qBAAqB,CAACC,QAAQ,EAAEsC,SAAS,EAAEpC,SAAS,CAAC;AAC9D;AAEO,eAAeqC,2BAA2BA,CAACvC,QAAsC,EAAEC,SAAiB,EAAEE,QAAiB,EAAmB;EAC/I,OAAOJ,qBAAqB,CAACC,QAAQ,EAAEC,SAAS,EAAEqC,SAAS,EAAEnC,QAAQ,CAAC;AACxE;AAEA,SAASU,cAAcA,CAAC2B,QAAgB,EAAU;EAChD,MAAMC,SAAS,GAAGD,QAAQ,CAACE,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC;EACzD,QAAQH,SAAS;IACf,KAAK,KAAK;IACV,KAAK,MAAM;MACT,OAAO,YAAY;IACrB,KAAK,KAAK;MACR,OAAO,WAAW;IACpB,KAAK,KAAK;MACR,OAAO,WAAW;IACpB,KAAK,MAAM;MACT,OAAO,YAAY;IACrB;MACE,OAAO,YAAY;EACvB;AACF","ignoreList":[]}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Telemetry = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
var _projectId = require("./projectId");
|
|
9
|
-
const packageJson = require('../package.json');
|
|
10
|
-
class Telemetry {
|
|
11
|
-
static instance = null;
|
|
12
|
-
constructor(config) {
|
|
13
|
-
this.config = {
|
|
14
|
-
table: 'telemetry',
|
|
15
|
-
...config
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
static getFilename(path) {
|
|
19
|
-
try {
|
|
20
|
-
return path.split('/').pop() || path.split('\\').pop() || 'unknown';
|
|
21
|
-
} catch {
|
|
22
|
-
return 'unknown';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
static autoInit() {
|
|
26
|
-
if (!Telemetry.instance) {
|
|
27
|
-
Telemetry.instance = new Telemetry({
|
|
28
|
-
supabaseUrl: 'https://vlqqczxwyaodtcdmdmlw.supabase.co',
|
|
29
|
-
supabaseKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZscXFjenh3eWFvZHRjZG1kbWx3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE1MTg2MzIsImV4cCI6MjA2NzA5NDYzMn0.nBzqGuK9j6RZ6mOPWU2boAC_5H9XDs-fPpo5P3WZYbI' // Anon!
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
static init(config) {
|
|
34
|
-
if (!Telemetry.instance) {
|
|
35
|
-
Telemetry.instance = new Telemetry(config);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
static track(payload, options, deviceMetadata) {
|
|
39
|
-
if (!Telemetry.instance) {
|
|
40
|
-
Telemetry.autoInit();
|
|
41
|
-
}
|
|
42
|
-
Telemetry.instance.trackInternal(payload, options, deviceMetadata);
|
|
43
|
-
}
|
|
44
|
-
static error(error, options) {
|
|
45
|
-
if (!Telemetry.instance) {
|
|
46
|
-
Telemetry.autoInit();
|
|
47
|
-
}
|
|
48
|
-
Telemetry.instance.errorInternal(error, options);
|
|
49
|
-
}
|
|
50
|
-
trackInternal(payload, options, deviceMetadata) {
|
|
51
|
-
const record = {
|
|
52
|
-
project_id: _projectId.PROJECT_ID,
|
|
53
|
-
device_id: deviceMetadata?.deviceId,
|
|
54
|
-
device_manufacturer: deviceMetadata?.make,
|
|
55
|
-
device_model: deviceMetadata?.model,
|
|
56
|
-
os: _reactNative.Platform.OS === 'ios' ? 'iOS' : 'Android',
|
|
57
|
-
os_version: _reactNative.Platform.Version.toString(),
|
|
58
|
-
framework: 'react-native',
|
|
59
|
-
framework_version: packageJson.version,
|
|
60
|
-
telemetry_payload: payload,
|
|
61
|
-
timestamp: new Date().toISOString(),
|
|
62
|
-
model_filename: Telemetry.getFilename(options.model || ''),
|
|
63
|
-
n_ctx: options.n_ctx,
|
|
64
|
-
n_gpu_layers: options.n_gpu_layers
|
|
65
|
-
};
|
|
66
|
-
this.sendRecord(record).catch(() => {});
|
|
67
|
-
}
|
|
68
|
-
errorInternal(error, options) {
|
|
69
|
-
const errorPayload = {
|
|
70
|
-
message: error.message,
|
|
71
|
-
stack: error.stack,
|
|
72
|
-
name: error.name
|
|
73
|
-
};
|
|
74
|
-
const record = {
|
|
75
|
-
project_id: _projectId.PROJECT_ID,
|
|
76
|
-
os: _reactNative.Platform.OS === 'ios' ? 'iOS' : 'Android',
|
|
77
|
-
os_version: _reactNative.Platform.Version.toString(),
|
|
78
|
-
framework: 'react-native',
|
|
79
|
-
framework_version: packageJson.version,
|
|
80
|
-
error_payload: errorPayload,
|
|
81
|
-
timestamp: new Date().toISOString(),
|
|
82
|
-
model_filename: Telemetry.getFilename(options.model || ''),
|
|
83
|
-
n_ctx: options.n_ctx,
|
|
84
|
-
n_gpu_layers: options.n_gpu_layers
|
|
85
|
-
};
|
|
86
|
-
this.sendRecord(record).catch(() => {});
|
|
87
|
-
}
|
|
88
|
-
async sendRecord(record) {
|
|
89
|
-
await globalThis.fetch(`${this.config.supabaseUrl}/rest/v1/${this.config.table}`, {
|
|
90
|
-
method: 'POST',
|
|
91
|
-
headers: {
|
|
92
|
-
'apikey': this.config.supabaseKey,
|
|
93
|
-
'Authorization': `Bearer ${this.config.supabaseKey}`,
|
|
94
|
-
'Content-Type': 'application/json',
|
|
95
|
-
'Prefer': 'return=minimal'
|
|
96
|
-
},
|
|
97
|
-
body: JSON.stringify([record])
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
exports.Telemetry = Telemetry;
|
|
102
|
-
//# sourceMappingURL=telemetry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_projectId","packageJson","Telemetry","instance","constructor","config","table","getFilename","path","split","pop","autoInit","supabaseUrl","supabaseKey","init","track","payload","options","deviceMetadata","trackInternal","error","errorInternal","record","project_id","PROJECT_ID","device_id","deviceId","device_manufacturer","make","device_model","model","os","Platform","OS","os_version","Version","toString","framework","framework_version","version","telemetry_payload","timestamp","Date","toISOString","model_filename","n_ctx","n_gpu_layers","sendRecord","catch","errorPayload","message","stack","name","error_payload","globalThis","fetch","method","headers","body","JSON","stringify","exports"],"sourceRoot":"../../src","sources":["telemetry.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AADA,MAAME,WAAW,GAAGF,OAAO,CAAC,iBAAiB,CAAC;AAgCvC,MAAMG,SAAS,CAAC;EACrB,OAAeC,QAAQ,GAAqB,IAAI;EAGxCC,WAAWA,CAACC,MAAuB,EAAE;IAC3C,IAAI,CAACA,MAAM,GAAG;MACZC,KAAK,EAAE,WAAW;MAClB,GAAGD;IACL,CAAC;EACH;EAEA,OAAeE,WAAWA,CAACC,IAAY,EAAU;IAC/C,IAAI;MACF,OAAOA,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,IAAIF,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,CAACC,GAAG,CAAC,CAAC,IAAI,SAAS;IACrE,CAAC,CAAC,MAAM;MACN,OAAO,SAAS;IAClB;EACF;EAEA,OAAOC,QAAQA,CAAA,EAAS;IACtB,IAAI,CAACT,SAAS,CAACC,QAAQ,EAAE;MAC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AC/D,MAAOgC,UAAU,CAASC,KAAK,CAAC,GAAG,IAAI,CAAClD,MAAM,CAACO,WAAW,YAAY,IAAI,CAACP,MAAM,CAACC,KAAK,EAAE,EAAE;MACzFkD,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,QAAQ,EAAE,IAAI,CAACpD,MAAM,CAACQ,WAAW;QACjC,eAAe,EAAE,UAAU,IAAI,CAACR,MAAM,CAACQ,WAAW,EAAE;QACpD,cAAc,EAAE,kBAAkB;QAClC,QAAQ,EAAE;MACZ,CAAC;MACD6C,IAAI,EAAEC,IAAI,CAACC,SAAS,CAAC,CAACtC,MAAM,CAAC;IAC/B,CAAC,CAAC;EACJ;AACF;AAACuC,OAAA,CAAA3D,SAAA,GAAAA,SAAA","ignoreList":[]}
|
package/lib/commonjs/tools.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Tools = void 0;
|
|
7
|
-
exports.parseAndExecuteTool = parseAndExecuteTool;
|
|
8
|
-
class Tools {
|
|
9
|
-
tools = new Map();
|
|
10
|
-
add(func, description, parameters) {
|
|
11
|
-
this.tools.set(func.name, {
|
|
12
|
-
func,
|
|
13
|
-
description,
|
|
14
|
-
parameters,
|
|
15
|
-
required: Object.entries(parameters).filter(([_, param]) => param.required).map(([key, _]) => key)
|
|
16
|
-
});
|
|
17
|
-
return func;
|
|
18
|
-
}
|
|
19
|
-
getSchemas() {
|
|
20
|
-
return Array.from(this.tools.entries()).map(([name, {
|
|
21
|
-
description,
|
|
22
|
-
parameters,
|
|
23
|
-
required
|
|
24
|
-
}]) => ({
|
|
25
|
-
type: "function",
|
|
26
|
-
function: {
|
|
27
|
-
name,
|
|
28
|
-
description,
|
|
29
|
-
parameters: {
|
|
30
|
-
type: "object",
|
|
31
|
-
properties: parameters,
|
|
32
|
-
required
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
async execute(name, args) {
|
|
38
|
-
const tool = this.tools.get(name);
|
|
39
|
-
if (!tool) throw new Error(`Tool ${name} not found`);
|
|
40
|
-
return await tool.func(...Object.values(args));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.Tools = Tools;
|
|
44
|
-
async function parseAndExecuteTool(result, tools) {
|
|
45
|
-
if (!result.tool_calls || result.tool_calls.length === 0) {
|
|
46
|
-
return {
|
|
47
|
-
toolCalled: false
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
const toolCall = result.tool_calls[0];
|
|
52
|
-
if (!toolCall) {
|
|
53
|
-
return {
|
|
54
|
-
toolCalled: false
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const toolName = toolCall.function.name;
|
|
58
|
-
const toolInput = JSON.parse(toolCall.function.arguments);
|
|
59
|
-
const toolOutput = await tools.execute(toolName, toolInput);
|
|
60
|
-
return {
|
|
61
|
-
toolCalled: true,
|
|
62
|
-
toolName,
|
|
63
|
-
toolInput,
|
|
64
|
-
toolOutput
|
|
65
|
-
};
|
|
66
|
-
} catch (error) {
|
|
67
|
-
return {
|
|
68
|
-
toolCalled: false
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Tools","tools","Map","add","func","description","parameters","set","name","required","Object","entries","filter","_","param","map","key","getSchemas","Array","from","type","function","properties","execute","args","tool","get","Error","values","exports","parseAndExecuteTool","result","tool_calls","length","toolCalled","toolCall","toolName","toolInput","JSON","parse","arguments","toolOutput","error"],"sourceRoot":"../../src","sources":["tools.ts"],"mappings":";;;;;;;AA4BO,MAAMA,KAAK,CAAC;EACTC,KAAK,GAAG,IAAIC,GAAG,CAAe,CAAC;EAEvCC,GAAGA,CACCC,IAAc,E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