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.
Files changed (510) hide show
  1. package/Cactus.podspec +34 -0
  2. package/LICENSE +38 -0
  3. package/README.md +550 -69
  4. package/android/CMakeLists.txt +40 -0
  5. package/android/build.gradle +68 -44
  6. package/android/gradle.properties +5 -5
  7. package/android/src/main/AndroidManifest.xml +1 -3
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/cactus/CactusPackage.kt +22 -0
  10. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +38 -0
  11. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +24 -0
  12. package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusFileSystem.kt +227 -0
  13. package/android/src/main/jniLibs/arm64-v8a/{libcactus_v8.so → libcactus.a} +0 -0
  14. package/android/src/main/jniLibs/arm64-v8a/libcactus_util.so +0 -0
  15. package/cpp/HybridCactus.cpp +135 -0
  16. package/cpp/HybridCactus.hpp +42 -0
  17. package/cpp/HybridCactusUtil.cpp +47 -0
  18. package/cpp/HybridCactusUtil.hpp +26 -0
  19. package/cpp/cactus_ffi.h +55 -0
  20. package/cpp/cactus_util.h +25 -0
  21. package/ios/HybridCactusCrypto.swift +37 -0
  22. package/ios/HybridCactusDeviceInfo.swift +32 -0
  23. package/ios/HybridCactusFileSystem.swift +234 -0
  24. package/ios/cactus.xcframework/{info.plist → Info.plist} +2 -37
  25. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +8 -229
  26. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +28 -229
  27. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +545 -0
  28. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ffi_utils.h +400 -0
  29. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +338 -0
  30. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +275 -0
  31. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +343 -0
  32. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Info.plist +0 -0
  33. package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
  34. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +11 -0
  35. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +55 -0
  36. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +545 -0
  37. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/ffi_utils.h +400 -0
  38. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +338 -0
  39. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +275 -0
  40. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +343 -0
  41. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Info.plist +0 -0
  42. package/ios/cactus.xcframework/{tvos-arm64_x86_64-simulator → ios-arm64-simulator}/cactus.framework/_CodeSignature/CodeResources +1 -1
  43. package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
  44. package/ios/cactus_util.xcframework/Info.plist +39 -0
  45. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +25 -0
  46. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +10 -0
  47. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +25 -0
  48. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
  49. package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
  50. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +25 -0
  51. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +10 -0
  52. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +25 -0
  53. package/ios/{cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework → cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework}/Info.plist +0 -0
  54. package/ios/{cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework → cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework}/_CodeSignature/CodeResources +36 -2
  55. package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
  56. package/lib/module/api/Database.js +60 -0
  57. package/lib/module/api/Database.js.map +1 -0
  58. package/lib/module/classes/CactusLM.js +151 -0
  59. package/lib/module/classes/CactusLM.js.map +1 -0
  60. package/lib/module/config/CactusConfig.js +6 -0
  61. package/lib/module/config/CactusConfig.js.map +1 -0
  62. package/lib/module/constants/packageVersion.js +4 -0
  63. package/lib/module/constants/packageVersion.js.map +1 -0
  64. package/lib/module/hooks/useCactusLM.js +238 -0
  65. package/lib/module/hooks/useCactusLM.js.map +1 -0
  66. package/lib/module/index.js +9 -409
  67. package/lib/module/index.js.map +1 -1
  68. package/lib/module/native/Cactus.js +50 -0
  69. package/lib/module/native/Cactus.js.map +1 -0
  70. package/lib/module/native/CactusCrypto.js +10 -0
  71. package/lib/module/native/CactusCrypto.js.map +1 -0
  72. package/lib/module/native/CactusDeviceInfo.js +13 -0
  73. package/lib/module/native/CactusDeviceInfo.js.map +1 -0
  74. package/lib/module/native/CactusFileSystem.js +35 -0
  75. package/lib/module/native/CactusFileSystem.js.map +1 -0
  76. package/lib/module/native/CactusUtil.js +23 -0
  77. package/lib/module/native/CactusUtil.js.map +1 -0
  78. package/lib/module/native/index.js +8 -0
  79. package/lib/module/native/index.js.map +1 -0
  80. package/lib/module/specs/Cactus.nitro.js +4 -0
  81. package/lib/module/specs/Cactus.nitro.js.map +1 -0
  82. package/lib/module/specs/CactusCrypto.nitro.js +4 -0
  83. package/lib/module/specs/CactusCrypto.nitro.js.map +1 -0
  84. package/lib/module/specs/CactusDeviceInfo.nitro.js +4 -0
  85. package/lib/module/specs/CactusDeviceInfo.nitro.js.map +1 -0
  86. package/lib/module/specs/CactusFileSystem.nitro.js +4 -0
  87. package/lib/module/specs/CactusFileSystem.nitro.js.map +1 -0
  88. package/lib/module/specs/CactusUtil.nitro.js +4 -0
  89. package/lib/module/specs/CactusUtil.nitro.js.map +1 -0
  90. package/lib/module/telemetry/Telemetry.js +100 -0
  91. package/lib/module/telemetry/Telemetry.js.map +1 -0
  92. package/lib/module/types/CactusLM.js +2 -0
  93. package/lib/module/types/CactusLM.js.map +1 -0
  94. package/lib/module/types/CactusModel.js +2 -0
  95. package/lib/module/types/CactusModel.js.map +1 -0
  96. package/lib/module/utils/error.js +4 -0
  97. package/lib/module/utils/error.js.map +1 -0
  98. package/lib/typescript/package.json +1 -0
  99. package/lib/typescript/src/api/Database.d.ts +11 -0
  100. package/lib/typescript/src/api/Database.d.ts.map +1 -0
  101. package/lib/typescript/src/classes/CactusLM.d.ts +26 -0
  102. package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -0
  103. package/lib/typescript/src/config/CactusConfig.d.ts +5 -0
  104. package/lib/typescript/src/config/CactusConfig.d.ts.map +1 -0
  105. package/lib/typescript/src/constants/packageVersion.d.ts +2 -0
  106. package/lib/typescript/src/constants/packageVersion.d.ts.map +1 -0
  107. package/lib/typescript/src/hooks/useCactusLM.d.ts +20 -0
  108. package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -0
  109. package/lib/typescript/src/index.d.ts +6 -0
  110. package/lib/typescript/src/index.d.ts.map +1 -0
  111. package/lib/typescript/src/native/Cactus.d.ts +11 -0
  112. package/lib/typescript/src/native/Cactus.d.ts.map +1 -0
  113. package/lib/typescript/src/native/CactusCrypto.d.ts +5 -0
  114. package/lib/typescript/src/native/CactusCrypto.d.ts.map +1 -0
  115. package/lib/typescript/src/native/CactusDeviceInfo.d.ts +7 -0
  116. package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +1 -0
  117. package/lib/typescript/src/native/CactusFileSystem.d.ts +13 -0
  118. package/lib/typescript/src/native/CactusFileSystem.d.ts.map +1 -0
  119. package/lib/typescript/src/native/CactusUtil.d.ts +6 -0
  120. package/lib/typescript/src/native/CactusUtil.d.ts.map +1 -0
  121. package/lib/typescript/src/native/index.d.ts +6 -0
  122. package/lib/typescript/src/native/index.d.ts.map +1 -0
  123. package/lib/typescript/src/specs/Cactus.nitro.d.ts +13 -0
  124. package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -0
  125. package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +8 -0
  126. package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +1 -0
  127. package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +16 -0
  128. package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +1 -0
  129. package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts +16 -0
  130. package/lib/typescript/src/specs/CactusFileSystem.nitro.d.ts.map +1 -0
  131. package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +10 -0
  132. package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +1 -0
  133. package/lib/typescript/src/telemetry/Telemetry.d.ts +30 -0
  134. package/lib/typescript/src/telemetry/Telemetry.d.ts.map +1 -0
  135. package/lib/typescript/src/types/CactusLM.d.ts +67 -0
  136. package/lib/typescript/src/types/CactusLM.d.ts.map +1 -0
  137. package/lib/typescript/src/types/CactusModel.d.ts +12 -0
  138. package/lib/typescript/src/types/CactusModel.d.ts.map +1 -0
  139. package/lib/typescript/src/utils/error.d.ts +2 -0
  140. package/lib/typescript/src/utils/error.d.ts.map +1 -0
  141. package/nitro.json +31 -0
  142. package/nitrogen/generated/android/c++/JDeviceInfo.hpp +74 -0
  143. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +74 -0
  144. package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +65 -0
  145. package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +65 -0
  146. package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +85 -0
  147. package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +66 -0
  148. package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.cpp +192 -0
  149. package/nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.hpp +73 -0
  150. package/nitrogen/generated/android/cactus+autolinking.cmake +87 -0
  151. package/nitrogen/generated/android/cactus+autolinking.gradle +27 -0
  152. package/nitrogen/generated/android/cactusOnLoad.cpp +86 -0
  153. package/nitrogen/generated/android/cactusOnLoad.hpp +25 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +50 -0
  155. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/Func_void_double.kt +80 -0
  156. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +58 -0
  157. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +62 -0
  158. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusFileSystemSpec.kt +95 -0
  159. package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/cactusOnLoad.kt +35 -0
  160. package/nitrogen/generated/ios/Cactus+autolinking.rb +60 -0
  161. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +122 -0
  162. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +373 -0
  163. package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +60 -0
  164. package/nitrogen/generated/ios/CactusAutolinking.mm +69 -0
  165. package/nitrogen/generated/ios/CactusAutolinking.swift +55 -0
  166. package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +11 -0
  167. package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +77 -0
  168. package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +11 -0
  169. package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +88 -0
  170. package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.cpp +11 -0
  171. package/nitrogen/generated/ios/c++/HybridCactusFileSystemSpecSwift.hpp +143 -0
  172. package/nitrogen/generated/ios/swift/DeviceInfo.swift +98 -0
  173. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  174. package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +47 -0
  175. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  176. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  177. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  178. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +54 -0
  179. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  180. package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +57 -0
  181. package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +139 -0
  182. package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +58 -0
  183. package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +164 -0
  184. package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec.swift +65 -0
  185. package/nitrogen/generated/ios/swift/HybridCactusFileSystemSpec_cxx.swift +303 -0
  186. package/nitrogen/generated/shared/c++/DeviceInfo.hpp +92 -0
  187. package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +21 -0
  188. package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +63 -0
  189. package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +22 -0
  190. package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +67 -0
  191. package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.cpp +29 -0
  192. package/nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.hpp +73 -0
  193. package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +26 -0
  194. package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +71 -0
  195. package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +23 -0
  196. package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +66 -0
  197. package/package.json +84 -143
  198. package/src/api/Database.ts +83 -0
  199. package/src/classes/CactusLM.ts +205 -0
  200. package/src/config/CactusConfig.ts +4 -0
  201. package/src/constants/packageVersion.ts +1 -0
  202. package/src/hooks/useCactusLM.ts +285 -0
  203. package/src/index.tsx +23 -0
  204. package/src/native/Cactus.ts +83 -0
  205. package/src/native/CactusCrypto.ts +11 -0
  206. package/src/native/CactusDeviceInfo.ts +18 -0
  207. package/src/native/CactusFileSystem.ts +47 -0
  208. package/src/native/CactusUtil.ts +27 -0
  209. package/src/native/index.ts +5 -0
  210. package/src/specs/Cactus.nitro.ts +20 -0
  211. package/src/specs/CactusCrypto.nitro.ts +6 -0
  212. package/src/specs/CactusDeviceInfo.nitro.ts +15 -0
  213. package/src/specs/CactusFileSystem.nitro.ts +21 -0
  214. package/src/specs/CactusUtil.nitro.ts +8 -0
  215. package/src/telemetry/Telemetry.ts +159 -0
  216. package/src/types/CactusLM.ts +73 -0
  217. package/src/types/CactusModel.ts +14 -0
  218. package/src/utils/error.ts +2 -0
  219. package/LICENSE.txt +0 -20
  220. package/android/src/main/CMakeLists.txt +0 -140
  221. package/android/src/main/java/com/cactus/Cactus.java +0 -1190
  222. package/android/src/main/java/com/cactus/CactusPackage.java +0 -48
  223. package/android/src/main/java/com/cactus/LlamaContext.java +0 -748
  224. package/android/src/main/jni-utils.h +0 -100
  225. package/android/src/main/jni.cpp +0 -1605
  226. package/android/src/main/jniLibs/arm64-v8a/libcactus.so +0 -0
  227. package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2.so +0 -0
  228. package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_dotprod.so +0 -0
  229. package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_dotprod_i8mm.so +0 -0
  230. package/android/src/main/jniLibs/arm64-v8a/libcactus_v8_2_i8mm.so +0 -0
  231. package/android/src/newarch/java/com/cactus/CactusModule.java +0 -204
  232. package/android/src/oldarch/java/com/cactus/CactusModule.java +0 -205
  233. package/cactus-react-native.podspec +0 -42
  234. package/ios/CMakeLists.txt +0 -131
  235. package/ios/Cactus.h +0 -6
  236. package/ios/Cactus.mm +0 -681
  237. package/ios/CactusContext.h +0 -81
  238. package/ios/CactusContext.mm +0 -1032
  239. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/chat.h +0 -145
  240. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/common.h +0 -674
  241. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-alloc.h +0 -76
  242. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-backend-impl.h +0 -255
  243. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-backend.h +0 -354
  244. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-common.h +0 -1857
  245. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-cpp.h +0 -39
  246. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-cpu.h +0 -143
  247. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-impl.h +0 -601
  248. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-metal-impl.h +0 -622
  249. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-metal.h +0 -66
  250. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-opt.h +0 -237
  251. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-quants.h +0 -100
  252. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml-threading.h +0 -14
  253. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ggml.h +0 -2202
  254. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/gguf.h +0 -202
  255. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
  256. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/json.hpp +0 -24766
  257. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-adapter.h +0 -76
  258. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-arch.h +0 -437
  259. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-batch.h +0 -89
  260. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-chat.h +0 -58
  261. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-context.h +0 -276
  262. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-cparams.h +0 -39
  263. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-cpp.h +0 -30
  264. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-grammar.h +0 -173
  265. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-graph.h +0 -640
  266. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-hparams.h +0 -190
  267. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-impl.h +0 -61
  268. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-io.h +0 -35
  269. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-kv-cache.h +0 -515
  270. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-memory.h +0 -32
  271. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-mmap.h +0 -68
  272. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model-loader.h +0 -169
  273. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model-saver.h +0 -37
  274. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-model.h +0 -425
  275. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-sampling.h +0 -32
  276. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama-vocab.h +0 -131
  277. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/llama.h +0 -1376
  278. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/log.h +0 -103
  279. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/minja/chat-template.hpp +0 -542
  280. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/minja/minja.hpp +0 -2974
  281. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/sampling.h +0 -107
  282. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/unicode-data.h +0 -20
  283. package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/unicode.h +0 -66
  284. package/ios/cactus.xcframework/ios-arm64/cactus.framework/ggml-llama.metallib +0 -0
  285. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/cactus.h +0 -232
  286. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/cactus_ffi.h +0 -256
  287. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/chat.h +0 -145
  288. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/common.h +0 -674
  289. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-alloc.h +0 -76
  290. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend-impl.h +0 -255
  291. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend.h +0 -354
  292. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-common.h +0 -1857
  293. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpp.h +0 -39
  294. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpu.h +0 -143
  295. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-impl.h +0 -601
  296. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal-impl.h +0 -622
  297. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal.h +0 -66
  298. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-opt.h +0 -237
  299. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-quants.h +0 -100
  300. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml-threading.h +0 -14
  301. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/ggml.h +0 -2202
  302. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/gguf.h +0 -202
  303. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
  304. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/json.hpp +0 -24766
  305. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-adapter.h +0 -76
  306. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-arch.h +0 -437
  307. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-batch.h +0 -89
  308. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-chat.h +0 -58
  309. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-context.h +0 -276
  310. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-cparams.h +0 -39
  311. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-cpp.h +0 -30
  312. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-grammar.h +0 -173
  313. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-graph.h +0 -640
  314. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-hparams.h +0 -190
  315. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-impl.h +0 -61
  316. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-io.h +0 -35
  317. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-kv-cache.h +0 -515
  318. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-memory.h +0 -32
  319. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-mmap.h +0 -68
  320. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-loader.h +0 -169
  321. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-saver.h +0 -37
  322. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-model.h +0 -425
  323. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-sampling.h +0 -32
  324. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama-vocab.h +0 -131
  325. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/llama.h +0 -1376
  326. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/log.h +0 -103
  327. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/minja/chat-template.hpp +0 -542
  328. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/minja/minja.hpp +0 -2974
  329. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/sampling.h +0 -107
  330. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/unicode-data.h +0 -20
  331. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/Headers/unicode.h +0 -66
  332. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/cactus +0 -0
  333. package/ios/cactus.xcframework/ios-arm64_x86_64-simulator/cactus.framework/ggml-llama-sim.metallib +0 -0
  334. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/cactus.h +0 -232
  335. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/cactus_ffi.h +0 -256
  336. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/chat.h +0 -145
  337. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/common.h +0 -674
  338. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-alloc.h +0 -76
  339. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-backend-impl.h +0 -255
  340. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-backend.h +0 -354
  341. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-common.h +0 -1857
  342. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-cpp.h +0 -39
  343. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-cpu.h +0 -143
  344. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-impl.h +0 -601
  345. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-metal-impl.h +0 -622
  346. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-metal.h +0 -66
  347. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-opt.h +0 -237
  348. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-quants.h +0 -100
  349. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml-threading.h +0 -14
  350. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/ggml.h +0 -2202
  351. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/gguf.h +0 -202
  352. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
  353. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/json.hpp +0 -24766
  354. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-adapter.h +0 -76
  355. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-arch.h +0 -437
  356. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-batch.h +0 -89
  357. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-chat.h +0 -58
  358. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-context.h +0 -276
  359. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-cparams.h +0 -39
  360. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-cpp.h +0 -30
  361. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-grammar.h +0 -173
  362. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-graph.h +0 -640
  363. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-hparams.h +0 -190
  364. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-impl.h +0 -61
  365. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-io.h +0 -35
  366. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-kv-cache.h +0 -515
  367. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-memory.h +0 -32
  368. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-mmap.h +0 -68
  369. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model-loader.h +0 -169
  370. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model-saver.h +0 -37
  371. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-model.h +0 -425
  372. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-sampling.h +0 -32
  373. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama-vocab.h +0 -131
  374. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/llama.h +0 -1376
  375. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/log.h +0 -103
  376. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/minja/chat-template.hpp +0 -542
  377. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/minja/minja.hpp +0 -2974
  378. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/sampling.h +0 -107
  379. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/unicode-data.h +0 -20
  380. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Headers/unicode.h +0 -66
  381. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/Info.plist +0 -0
  382. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/cactus +0 -0
  383. package/ios/cactus.xcframework/tvos-arm64/cactus.framework/ggml-llama.metallib +0 -0
  384. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/cactus.h +0 -232
  385. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/cactus_ffi.h +0 -256
  386. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/chat.h +0 -145
  387. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/common.h +0 -674
  388. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-alloc.h +0 -76
  389. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend-impl.h +0 -255
  390. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-backend.h +0 -354
  391. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-common.h +0 -1857
  392. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpp.h +0 -39
  393. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-cpu.h +0 -143
  394. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-impl.h +0 -601
  395. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal-impl.h +0 -622
  396. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-metal.h +0 -66
  397. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-opt.h +0 -237
  398. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-quants.h +0 -100
  399. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml-threading.h +0 -14
  400. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/ggml.h +0 -2202
  401. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/gguf.h +0 -202
  402. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/json-schema-to-grammar.h +0 -21
  403. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/json.hpp +0 -24766
  404. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-adapter.h +0 -76
  405. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-arch.h +0 -437
  406. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-batch.h +0 -89
  407. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-chat.h +0 -58
  408. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-context.h +0 -276
  409. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-cparams.h +0 -39
  410. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-cpp.h +0 -30
  411. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-grammar.h +0 -173
  412. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-graph.h +0 -640
  413. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-hparams.h +0 -190
  414. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-impl.h +0 -61
  415. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-io.h +0 -35
  416. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-kv-cache.h +0 -515
  417. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-memory.h +0 -32
  418. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-mmap.h +0 -68
  419. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-loader.h +0 -169
  420. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model-saver.h +0 -37
  421. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-model.h +0 -425
  422. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-sampling.h +0 -32
  423. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama-vocab.h +0 -131
  424. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/llama.h +0 -1376
  425. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/log.h +0 -103
  426. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/minja/chat-template.hpp +0 -542
  427. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/minja/minja.hpp +0 -2974
  428. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/sampling.h +0 -107
  429. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/unicode-data.h +0 -20
  430. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Headers/unicode.h +0 -66
  431. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/Info.plist +0 -0
  432. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/cactus +0 -0
  433. package/ios/cactus.xcframework/tvos-arm64_x86_64-simulator/cactus.framework/ggml-llama-sim.metallib +0 -0
  434. package/lib/commonjs/NativeCactus.js +0 -9
  435. package/lib/commonjs/NativeCactus.js.map +0 -1
  436. package/lib/commonjs/agent.js +0 -73
  437. package/lib/commonjs/agent.js.map +0 -1
  438. package/lib/commonjs/chat.js +0 -73
  439. package/lib/commonjs/chat.js.map +0 -1
  440. package/lib/commonjs/index.js +0 -523
  441. package/lib/commonjs/index.js.map +0 -1
  442. package/lib/commonjs/lm.js +0 -272
  443. package/lib/commonjs/lm.js.map +0 -1
  444. package/lib/commonjs/package.json +0 -1
  445. package/lib/commonjs/projectId.js +0 -9
  446. package/lib/commonjs/projectId.js.map +0 -1
  447. package/lib/commonjs/remote.js +0 -100
  448. package/lib/commonjs/remote.js.map +0 -1
  449. package/lib/commonjs/telemetry.js +0 -102
  450. package/lib/commonjs/telemetry.js.map +0 -1
  451. package/lib/commonjs/tools.js +0 -72
  452. package/lib/commonjs/tools.js.map +0 -1
  453. package/lib/commonjs/tts.js +0 -141
  454. package/lib/commonjs/tts.js.map +0 -1
  455. package/lib/commonjs/vlm.js +0 -221
  456. package/lib/commonjs/vlm.js.map +0 -1
  457. package/lib/module/NativeCactus.js +0 -5
  458. package/lib/module/NativeCactus.js.map +0 -1
  459. package/lib/module/agent.js +0 -68
  460. package/lib/module/agent.js.map +0 -1
  461. package/lib/module/chat.js +0 -67
  462. package/lib/module/chat.js.map +0 -1
  463. package/lib/module/lm.js +0 -267
  464. package/lib/module/lm.js.map +0 -1
  465. package/lib/module/projectId.js +0 -5
  466. package/lib/module/projectId.js.map +0 -1
  467. package/lib/module/remote.js +0 -91
  468. package/lib/module/remote.js.map +0 -1
  469. package/lib/module/telemetry.js +0 -97
  470. package/lib/module/telemetry.js.map +0 -1
  471. package/lib/module/tools.js +0 -66
  472. package/lib/module/tools.js.map +0 -1
  473. package/lib/module/tts.js +0 -135
  474. package/lib/module/tts.js.map +0 -1
  475. package/lib/module/vlm.js +0 -216
  476. package/lib/module/vlm.js.map +0 -1
  477. package/lib/typescript/NativeCactus.d.ts +0 -252
  478. package/lib/typescript/NativeCactus.d.ts.map +0 -1
  479. package/lib/typescript/agent.d.ts +0 -31
  480. package/lib/typescript/agent.d.ts.map +0 -1
  481. package/lib/typescript/chat.d.ts +0 -23
  482. package/lib/typescript/chat.d.ts.map +0 -1
  483. package/lib/typescript/index.d.ts +0 -114
  484. package/lib/typescript/index.d.ts.map +0 -1
  485. package/lib/typescript/lm.d.ts +0 -36
  486. package/lib/typescript/lm.d.ts.map +0 -1
  487. package/lib/typescript/projectId.d.ts +0 -2
  488. package/lib/typescript/projectId.d.ts.map +0 -1
  489. package/lib/typescript/remote.d.ts +0 -8
  490. package/lib/typescript/remote.d.ts.map +0 -1
  491. package/lib/typescript/telemetry.d.ts +0 -25
  492. package/lib/typescript/telemetry.d.ts.map +0 -1
  493. package/lib/typescript/tools.d.ts +0 -36
  494. package/lib/typescript/tools.d.ts.map +0 -1
  495. package/lib/typescript/tts.d.ts +0 -54
  496. package/lib/typescript/tts.d.ts.map +0 -1
  497. package/lib/typescript/vlm.d.ts +0 -33
  498. package/lib/typescript/vlm.d.ts.map +0 -1
  499. package/scripts/postInstall.js +0 -33
  500. package/src/NativeCactus.ts +0 -317
  501. package/src/agent.ts +0 -112
  502. package/src/chat.ts +0 -91
  503. package/src/index.ts +0 -663
  504. package/src/lm.ts +0 -324
  505. package/src/projectId.ts +0 -1
  506. package/src/remote.ts +0 -113
  507. package/src/telemetry.ts +0 -137
  508. package/src/tools.ts +0 -94
  509. package/src/tts.ts +0 -236
  510. package/src/vlm.ts +0 -276
@@ -1,1190 +0,0 @@
1
- package com.cactus;
2
-
3
- import androidx.annotation.NonNull;
4
- import android.util.Log;
5
- import android.provider.Settings;
6
- import android.os.Build;
7
- import android.os.Handler;
8
- import android.os.AsyncTask;
9
-
10
- import com.facebook.react.bridge.Promise;
11
- import com.facebook.react.bridge.ReactApplicationContext;
12
- import com.facebook.react.bridge.ReactMethod;
13
- import com.facebook.react.bridge.LifecycleEventListener;
14
- import com.facebook.react.bridge.ReadableMap;
15
- import com.facebook.react.bridge.ReadableArray;
16
- import com.facebook.react.bridge.WritableMap;
17
- import com.facebook.react.bridge.WritableArray;
18
- import com.facebook.react.bridge.Arguments;
19
-
20
- import java.util.HashMap;
21
- import java.util.Random;
22
- import java.io.File;
23
- import java.io.FileInputStream;
24
- import java.io.PushbackInputStream;
25
- import java.util.concurrent.ExecutorService;
26
- import java.util.concurrent.Executors;
27
-
28
- public class Cactus implements LifecycleEventListener {
29
- public static final String NAME = "Cactus";
30
-
31
- private ReactApplicationContext reactContext;
32
- private final ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
33
-
34
- public Cactus(ReactApplicationContext reactContext) {
35
- reactContext.addLifecycleEventListener(this);
36
- this.reactContext = reactContext;
37
- }
38
-
39
- private HashMap<AsyncTask, String> tasks = new HashMap<>();
40
-
41
- private HashMap<Integer, LlamaContext> contexts = new HashMap<>();
42
-
43
- public void toggleNativeLog(boolean enabled, Promise promise) {
44
- new AsyncTask<Void, Void, Boolean>() {
45
- private Exception exception;
46
-
47
- @Override
48
- protected Boolean doInBackground(Void... voids) {
49
- try {
50
- LlamaContext.toggleNativeLog(reactContext, enabled);
51
- return true;
52
- } catch (Exception e) {
53
- exception = e;
54
- }
55
- return null;
56
- }
57
-
58
- @Override
59
- protected void onPostExecute(Boolean result) {
60
- if (exception != null) {
61
- promise.reject(exception);
62
- return;
63
- }
64
- promise.resolve(result);
65
- }
66
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
67
- }
68
-
69
- private int llamaContextLimit = -1;
70
-
71
- public void setContextLimit(double limit, Promise promise) {
72
- llamaContextLimit = (int) limit;
73
- promise.resolve(null);
74
- }
75
-
76
- public void modelInfo(final String model, final ReadableArray skip, final Promise promise) {
77
- new AsyncTask<Void, Void, WritableMap>() {
78
- private Exception exception;
79
-
80
- @Override
81
- protected WritableMap doInBackground(Void... voids) {
82
- try {
83
- String[] skipArray = new String[skip.size()];
84
- for (int i = 0; i < skip.size(); i++) {
85
- skipArray[i] = skip.getString(i);
86
- }
87
- return LlamaContext.modelInfo(model, skipArray);
88
- } catch (Exception e) {
89
- exception = e;
90
- }
91
- return null;
92
- }
93
-
94
- @Override
95
- protected void onPostExecute(WritableMap result) {
96
- if (exception != null) {
97
- promise.reject(exception);
98
- return;
99
- }
100
- promise.resolve(result);
101
- }
102
- }.executeOnExecutor(singleThreadExecutor);
103
- }
104
-
105
- public void initContext(double id, final ReadableMap params, final Promise promise) {
106
- final int contextId = (int) id;
107
- AsyncTask task = new AsyncTask<Void, Void, WritableMap>() {
108
- private Exception exception;
109
-
110
- @Override
111
- protected WritableMap doInBackground(Void... voids) {
112
- try {
113
- LlamaContext context = contexts.get(contextId);
114
- if (context != null) {
115
- throw new Exception("Context already exists");
116
- }
117
- if (llamaContextLimit > -1 && contexts.size() >= llamaContextLimit) {
118
- throw new Exception("Context limit reached");
119
- }
120
- LlamaContext llamaContext = new LlamaContext(contextId, reactContext, params);
121
- if (llamaContext.getContext() == 0) {
122
- throw new Exception("Failed to initialize context");
123
- }
124
- contexts.put(contextId, llamaContext);
125
- WritableMap result = Arguments.createMap();
126
- result.putBoolean("gpu", false);
127
- result.putString("reasonNoGPU", "Currently not supported");
128
- result.putMap("model", llamaContext.getModelDetails());
129
- result.putString("androidLib", llamaContext.getLoadedLibrary());
130
- return result;
131
- } catch (Exception e) {
132
- exception = e;
133
- return null;
134
- }
135
- }
136
-
137
- @Override
138
- protected void onPostExecute(WritableMap result) {
139
- if (exception != null) {
140
- promise.reject(exception);
141
- return;
142
- }
143
- promise.resolve(result);
144
- tasks.remove(this);
145
- }
146
- }.executeOnExecutor(singleThreadExecutor);
147
- tasks.put(task, "initContext");
148
- }
149
-
150
- public void getFormattedChat(double id, final String messages, final String chatTemplate, final ReadableMap params, Promise promise) {
151
- final int contextId = (int) id;
152
- AsyncTask task = new AsyncTask<Void, Void, Object>() {
153
- private Exception exception;
154
-
155
- @Override
156
- protected Object doInBackground(Void... voids) {
157
- try {
158
- LlamaContext context = contexts.get(contextId);
159
- if (context == null) {
160
- throw new Exception("Context not found");
161
- }
162
- if (params.hasKey("jinja") && params.getBoolean("jinja")) {
163
- ReadableMap result = context.getFormattedChatWithJinja(messages, chatTemplate, params);
164
- if (result.hasKey("_error")) {
165
- throw new Exception(result.getString("_error"));
166
- }
167
- return result;
168
- }
169
- return context.getFormattedChat(messages, chatTemplate);
170
- } catch (Exception e) {
171
- exception = e;
172
- return null;
173
- }
174
- }
175
-
176
- @Override
177
- protected void onPostExecute(Object result) {
178
- if (exception != null) {
179
- promise.reject(exception);
180
- return;
181
- }
182
- promise.resolve(result);
183
- tasks.remove(this);
184
- }
185
- }.executeOnExecutor(singleThreadExecutor);
186
- tasks.put(task, "getFormattedChat-" + contextId);
187
- }
188
-
189
- public void loadSession(double id, final String path, Promise promise) {
190
- final int contextId = (int) id;
191
- AsyncTask task = new AsyncTask<Void, Void, WritableMap>() {
192
- private Exception exception;
193
-
194
- @Override
195
- protected WritableMap doInBackground(Void... voids) {
196
- try {
197
- LlamaContext context = contexts.get(contextId);
198
- if (context == null) {
199
- throw new Exception("Context not found");
200
- }
201
- WritableMap result = context.loadSession(path);
202
- return result;
203
- } catch (Exception e) {
204
- exception = e;
205
- }
206
- return null;
207
- }
208
-
209
- @Override
210
- protected void onPostExecute(WritableMap result) {
211
- if (exception != null) {
212
- promise.reject(exception);
213
- return;
214
- }
215
- promise.resolve(result);
216
- tasks.remove(this);
217
- }
218
- }.executeOnExecutor(singleThreadExecutor);
219
- tasks.put(task, "loadSession-" + contextId);
220
- }
221
-
222
- public void saveSession(double id, final String path, double size, Promise promise) {
223
- final int contextId = (int) id;
224
- AsyncTask task = new AsyncTask<Void, Void, Integer>() {
225
- private Exception exception;
226
-
227
- @Override
228
- protected Integer doInBackground(Void... voids) {
229
- try {
230
- LlamaContext context = contexts.get(contextId);
231
- if (context == null) {
232
- throw new Exception("Context not found");
233
- }
234
- Integer count = context.saveSession(path, (int) size);
235
- return count;
236
- } catch (Exception e) {
237
- exception = e;
238
- }
239
- return -1;
240
- }
241
-
242
- @Override
243
- protected void onPostExecute(Integer result) {
244
- if (exception != null) {
245
- promise.reject(exception);
246
- return;
247
- }
248
- promise.resolve(result);
249
- tasks.remove(this);
250
- }
251
- }.executeOnExecutor(singleThreadExecutor);
252
- tasks.put(task, "saveSession-" + contextId);
253
- }
254
-
255
- public void completion(double id, final ReadableMap params, final Promise promise) {
256
- Log.d(NAME, "BRIDGE: completion() method called with contextId=" + (int)id);
257
- final int contextId = (int) id;
258
- AsyncTask task = new AsyncTask<Void, Void, WritableMap>() {
259
- private Exception exception;
260
-
261
- @Override
262
- protected WritableMap doInBackground(Void... voids) {
263
- Log.d(NAME, "⚡ BRIDGE: AsyncTask doInBackground starting...");
264
- try {
265
- LlamaContext context = contexts.get(contextId);
266
- if (context == null) {
267
- Log.e(NAME, "BRIDGE: Context not found for id=" + contextId);
268
- throw new Exception("Context not found");
269
- }
270
- Log.d(NAME, "BRIDGE: Context found, checking if predicting...");
271
- if (context.isPredicting()) {
272
- Log.e(NAME, "BRIDGE: Context is busy (predicting)");
273
- throw new Exception("Context is busy");
274
- }
275
- Log.d(NAME, "BRIDGE: About to call context.completion()...");
276
- WritableMap result = context.completion(params);
277
- Log.d(NAME, "BRIDGE: context.completion() returned successfully");
278
- return result;
279
- } catch (Exception e) {
280
- Log.e(NAME, "BRIDGE: Exception in doInBackground: " + e.getMessage());
281
- exception = e;
282
- }
283
- return null;
284
- }
285
-
286
- @Override
287
- protected void onPostExecute(WritableMap result) {
288
- Log.d(NAME, "BRIDGE: onPostExecute called");
289
- if (exception != null) {
290
- Log.e(NAME, "BRIDGE: Rejecting promise with exception: " + exception.getMessage());
291
- promise.reject(exception);
292
- return;
293
- }
294
- Log.d(NAME, "BRIDGE: Resolving promise with result");
295
- promise.resolve(result);
296
- tasks.remove(this);
297
- Log.d(NAME, "BRIDGE: completion() finished successfully");
298
- }
299
- }.executeOnExecutor(singleThreadExecutor);
300
- Log.d(NAME, "BRIDGE: AsyncTask queued for execution");
301
- tasks.put(task, "completion-" + contextId);
302
- }
303
-
304
- public void stopCompletion(double id, final Promise promise) {
305
- final int contextId = (int) id;
306
- AsyncTask task = new AsyncTask<Void, Void, Void>() {
307
- private Exception exception;
308
-
309
- @Override
310
- protected Void doInBackground(Void... voids) {
311
- try {
312
- LlamaContext context = contexts.get(contextId);
313
- if (context == null) {
314
- throw new Exception("Context not found");
315
- }
316
- context.stopCompletion();
317
- AsyncTask completionTask = null;
318
- for (AsyncTask task : tasks.keySet()) {
319
- if (tasks.get(task).equals("completion-" + contextId)) {
320
- task.get();
321
- break;
322
- }
323
- }
324
- } catch (Exception e) {
325
- exception = e;
326
- }
327
- return null;
328
- }
329
-
330
- @Override
331
- protected void onPostExecute(Void result) {
332
- if (exception != null) {
333
- promise.reject(exception);
334
- return;
335
- }
336
- promise.resolve(result);
337
- tasks.remove(this);
338
- }
339
- }.executeOnExecutor(singleThreadExecutor);
340
- tasks.put(task, "stopCompletion-" + contextId);
341
- }
342
-
343
- public void tokenize(double id, final String text, final Promise promise) {
344
- final int contextId = (int) id;
345
- AsyncTask task = new AsyncTask<Void, Void, WritableMap>() {
346
- private Exception exception;
347
-
348
- @Override
349
- protected WritableMap doInBackground(Void... voids) {
350
- try {
351
- LlamaContext context = contexts.get(contextId);
352
- if (context == null) {
353
- throw new Exception("Context not found");
354
- }
355
- return context.tokenize(text);
356
- } catch (Exception e) {
357
- exception = e;
358
- }
359
- return null;
360
- }
361
-
362
- @Override
363
- protected void onPostExecute(WritableMap result) {
364
- if (exception != null) {
365
- promise.reject(exception);
366
- return;
367
- }
368
- promise.resolve(result);
369
- tasks.remove(this);
370
- }
371
- }.executeOnExecutor(singleThreadExecutor);
372
- tasks.put(task, "tokenize-" + contextId);
373
- }
374
-
375
- public void tokenize(double id, final String text, final ReadableArray mediaPaths, final Promise promise) {
376
- final int contextId = (int) id;
377
- AsyncTask task = new AsyncTask<Void, Void, WritableMap>() {
378
- private Exception exception;
379
-
380
- @Override
381
- protected WritableMap doInBackground(Void... voids) {
382
- try {
383
- LlamaContext context = contexts.get(contextId);
384
- if (context == null) {
385
- throw new Exception("Context not found");
386
- }
387
- return context.tokenize(text, mediaPaths);
388
- } catch (Exception e) {
389
- exception = e;
390
- }
391
- return null;
392
- }
393
-
394
- @Override
395
- protected void onPostExecute(WritableMap result) {
396
- if (exception != null) {
397
- promise.reject(exception);
398
- return;
399
- }
400
- promise.resolve(result);
401
- tasks.remove(this);
402
- }
403
- }.executeOnExecutor(singleThreadExecutor);
404
- tasks.put(task, "tokenize-" + contextId);
405
- }
406
-
407
- public void detokenize(double id, final ReadableArray tokens, final Promise promise) {
408
- final int contextId = (int) id;
409
- AsyncTask task = new AsyncTask<Void, Void, String>() {
410
- private Exception exception;
411
-
412
- @Override
413
- protected String doInBackground(Void... voids) {
414
- try {
415
- LlamaContext context = contexts.get(contextId);
416
- if (context == null) {
417
- throw new Exception("Context not found");
418
- }
419
- return context.detokenize(tokens);
420
- } catch (Exception e) {
421
- exception = e;
422
- }
423
- return null;
424
- }
425
-
426
- @Override
427
- protected void onPostExecute(String result) {
428
- if (exception != null) {
429
- promise.reject(exception);
430
- return;
431
- }
432
- promise.resolve(result);
433
- tasks.remove(this);
434
- }
435
- }.executeOnExecutor(singleThreadExecutor);
436
- tasks.put(task, "detokenize-" + contextId);
437
- }
438
-
439
- public void embedding(double id, final String text, final ReadableMap params, final Promise promise) {
440
- final int contextId = (int) id;
441
- AsyncTask task = new AsyncTask<Void, Void, WritableMap>() {
442
- private Exception exception;
443
-
444
- @Override
445
- protected WritableMap doInBackground(Void... voids) {
446
- try {
447
- LlamaContext context = contexts.get(contextId);
448
- if (context == null) {
449
- throw new Exception("Context not found");
450
- }
451
- return context.getEmbedding(text, params);
452
- } catch (Exception e) {
453
- exception = e;
454
- }
455
- return null;
456
- }
457
-
458
- @Override
459
- protected void onPostExecute(WritableMap result) {
460
- if (exception != null) {
461
- promise.reject(exception);
462
- return;
463
- }
464
- promise.resolve(result);
465
- tasks.remove(this);
466
- }
467
- }.executeOnExecutor(singleThreadExecutor);
468
- tasks.put(task, "embedding-" + contextId);
469
- }
470
-
471
- public void bench(double id, final double pp, final double tg, final double pl, final double nr, final Promise promise) {
472
- final int contextId = (int) id;
473
- AsyncTask task = new AsyncTask<Void, Void, String>() {
474
- private Exception exception;
475
-
476
- @Override
477
- protected String doInBackground(Void... voids) {
478
- try {
479
- LlamaContext context = contexts.get(contextId);
480
- if (context == null) {
481
- throw new Exception("Context not found");
482
- }
483
- return context.bench((int) pp, (int) tg, (int) pl, (int) nr);
484
- } catch (Exception e) {
485
- exception = e;
486
- }
487
- return null;
488
- }
489
-
490
- @Override
491
- protected void onPostExecute(String result) {
492
- if (exception != null) {
493
- promise.reject(exception);
494
- return;
495
- }
496
- promise.resolve(result);
497
- tasks.remove(this);
498
- }
499
- }.executeOnExecutor(singleThreadExecutor);
500
- tasks.put(task, "bench-" + contextId);
501
- }
502
-
503
- public void applyLoraAdapters(double id, final ReadableArray loraAdapters, final Promise promise) {
504
- final int contextId = (int) id;
505
- AsyncTask task = new AsyncTask<Void, Void, Void>() {
506
- private Exception exception;
507
-
508
- @Override
509
- protected Void doInBackground(Void... voids) {
510
- try {
511
- LlamaContext context = contexts.get(contextId);
512
- if (context == null) {
513
- throw new Exception("Context not found");
514
- }
515
- if (context.isPredicting()) {
516
- throw new Exception("Context is busy");
517
- }
518
- context.applyLoraAdapters(loraAdapters);
519
- } catch (Exception e) {
520
- exception = e;
521
- }
522
- return null;
523
- }
524
-
525
- @Override
526
- protected void onPostExecute(Void result) {
527
- if (exception != null) {
528
- promise.reject(exception);
529
- return;
530
- }
531
- }
532
- }.executeOnExecutor(singleThreadExecutor);
533
- tasks.put(task, "applyLoraAdapters-" + contextId);
534
- }
535
-
536
- public void removeLoraAdapters(double id, final Promise promise) {
537
- final int contextId = (int) id;
538
- AsyncTask task = new AsyncTask<Void, Void, Void>() {
539
- private Exception exception;
540
-
541
- @Override
542
- protected Void doInBackground(Void... voids) {
543
- try {
544
- LlamaContext context = contexts.get(contextId);
545
- if (context == null) {
546
- throw new Exception("Context not found");
547
- }
548
- if (context.isPredicting()) {
549
- throw new Exception("Context is busy");
550
- }
551
- context.removeLoraAdapters();
552
- } catch (Exception e) {
553
- exception = e;
554
- }
555
- return null;
556
- }
557
-
558
- @Override
559
- protected void onPostExecute(Void result) {
560
- if (exception != null) {
561
- promise.reject(exception);
562
- return;
563
- }
564
- promise.resolve(null);
565
- }
566
- }.executeOnExecutor(singleThreadExecutor);
567
- tasks.put(task, "removeLoraAdapters-" + contextId);
568
- }
569
-
570
- public void getLoadedLoraAdapters(double id, final Promise promise) {
571
- final int contextId = (int) id;
572
- AsyncTask task = new AsyncTask<Void, Void, ReadableArray>() {
573
- private Exception exception;
574
-
575
- @Override
576
- protected ReadableArray doInBackground(Void... voids) {
577
- try {
578
- LlamaContext context = contexts.get(contextId);
579
- if (context == null) {
580
- throw new Exception("Context not found");
581
- }
582
- return context.getLoadedLoraAdapters();
583
- } catch (Exception e) {
584
- exception = e;
585
- }
586
- return null;
587
- }
588
-
589
- @Override
590
- protected void onPostExecute(ReadableArray result) {
591
- if (exception != null) {
592
- promise.reject(exception);
593
- return;
594
- }
595
- promise.resolve(result);
596
- }
597
- }.executeOnExecutor(singleThreadExecutor);
598
- tasks.put(task, "getLoadedLoraAdapters-" + contextId);
599
- }
600
-
601
- public void rewind(double id, Promise promise) {
602
- final int contextId = (int) id;
603
- AsyncTask task = new AsyncTask<Void, Void, Void>() {
604
- private Exception exception;
605
-
606
- @Override
607
- protected Void doInBackground(Void... voids) {
608
- try {
609
- LlamaContext context = contexts.get(contextId);
610
- if (context == null) {
611
- throw new Exception("Context not found");
612
- }
613
- if (context.isPredicting()) {
614
- throw new Exception("Context is busy");
615
- }
616
- context.rewind();
617
- } catch (Exception e) {
618
- exception = e;
619
- }
620
- return null;
621
- }
622
-
623
- @Override
624
- protected void onPostExecute(Void result) {
625
- if (exception != null) {
626
- promise.reject(exception);
627
- return;
628
- }
629
- promise.resolve(null);
630
- tasks.remove(this);
631
- }
632
- }.executeOnExecutor(singleThreadExecutor);
633
- tasks.put(task, "rewind-" + contextId);
634
- }
635
-
636
- public void releaseContext(double id, Promise promise) {
637
- final int contextId = (int) id;
638
- AsyncTask task = new AsyncTask<Void, Void, Void>() {
639
- private Exception exception;
640
-
641
- @Override
642
- protected Void doInBackground(Void... voids) {
643
- try {
644
- LlamaContext context = contexts.get(contextId);
645
- if (context == null) {
646
- throw new Exception("Context " + id + " not found");
647
- }
648
- context.interruptLoad();
649
- context.stopCompletion();
650
- AsyncTask completionTask = null;
651
- for (AsyncTask task : tasks.keySet()) {
652
- if (tasks.get(task).equals("completion-" + contextId)) {
653
- task.get();
654
- break;
655
- }
656
- }
657
- context.release();
658
- contexts.remove(contextId);
659
- } catch (Exception e) {
660
- exception = e;
661
- }
662
- return null;
663
- }
664
-
665
- @Override
666
- protected void onPostExecute(Void result) {
667
- if (exception != null) {
668
- promise.reject(exception);
669
- return;
670
- }
671
- promise.resolve(null);
672
- tasks.remove(this);
673
- }
674
- }.executeOnExecutor(singleThreadExecutor);
675
- tasks.put(task, "releaseContext-" + contextId);
676
- }
677
-
678
- public void releaseAllContexts(Promise promise) {
679
- AsyncTask task = new AsyncTask<Void, Void, Void>() {
680
- private Exception exception;
681
-
682
- @Override
683
- protected Void doInBackground(Void... voids) {
684
- try {
685
- onHostDestroy();
686
- } catch (Exception e) {
687
- exception = e;
688
- }
689
- return null;
690
- }
691
-
692
- @Override
693
- protected void onPostExecute(Void result) {
694
- if (exception != null) {
695
- promise.reject(exception);
696
- return;
697
- }
698
- promise.resolve(null);
699
- tasks.remove(this);
700
- }
701
- }.executeOnExecutor(singleThreadExecutor);
702
- tasks.put(task, "releaseAllContexts");
703
- }
704
-
705
- @Override
706
- public void onHostResume() {
707
- }
708
-
709
- @Override
710
- public void onHostPause() {
711
- }
712
-
713
- @Override
714
- public void onHostDestroy() {
715
- for (LlamaContext context : contexts.values()) {
716
- context.stopCompletion();
717
- }
718
- for (AsyncTask task : tasks.keySet()) {
719
- try {
720
- task.get();
721
- } catch (Exception e) {
722
- Log.e(NAME, "Failed to wait for task", e);
723
- }
724
- }
725
- tasks.clear();
726
- for (LlamaContext context : contexts.values()) {
727
- context.release();
728
- }
729
- contexts.clear();
730
- }
731
-
732
- public void initMultimodal(double id, final String mmprojPath, final boolean useGpu, final Promise promise) {
733
- final int contextId = (int) id;
734
- AsyncTask task = new AsyncTask<Void, Void, Boolean>() {
735
- private Exception exception;
736
-
737
- @Override
738
- protected Boolean doInBackground(Void... voids) {
739
- try {
740
- LlamaContext context = contexts.get(contextId);
741
- if (context == null) {
742
- throw new Exception("Context not found");
743
- }
744
- return context.initMultimodal(mmprojPath, useGpu);
745
- } catch (Exception e) {
746
- exception = e;
747
- }
748
- return false;
749
- }
750
-
751
- @Override
752
- protected void onPostExecute(Boolean result) {
753
- if (exception != null) {
754
- promise.reject(exception);
755
- return;
756
- }
757
- promise.resolve(result);
758
- tasks.remove(this);
759
- }
760
- }.executeOnExecutor(singleThreadExecutor);
761
- tasks.put(task, "initMultimodal-" + contextId);
762
- }
763
-
764
- public void isMultimodalEnabled(double id, final Promise promise) {
765
- final int contextId = (int) id;
766
- AsyncTask task = new AsyncTask<Void, Void, Boolean>() {
767
- private Exception exception;
768
-
769
- @Override
770
- protected Boolean doInBackground(Void... voids) {
771
- try {
772
- LlamaContext context = contexts.get(contextId);
773
- if (context == null) {
774
- throw new Exception("Context not found");
775
- }
776
- return context.isMultimodalEnabled();
777
- } catch (Exception e) {
778
- exception = e;
779
- }
780
- return false;
781
- }
782
-
783
- @Override
784
- protected void onPostExecute(Boolean result) {
785
- if (exception != null) {
786
- promise.reject(exception);
787
- return;
788
- }
789
- promise.resolve(result);
790
- tasks.remove(this);
791
- }
792
- }.executeOnExecutor(singleThreadExecutor);
793
- tasks.put(task, "isMultimodalEnabled-" + contextId);
794
- }
795
-
796
- public void isMultimodalSupportVision(double id, final Promise promise) {
797
- final int contextId = (int) id;
798
- AsyncTask task = new AsyncTask<Void, Void, Boolean>() {
799
- private Exception exception;
800
-
801
- @Override
802
- protected Boolean doInBackground(Void... voids) {
803
- try {
804
- LlamaContext context = contexts.get(contextId);
805
- if (context == null) {
806
- throw new Exception("Context not found");
807
- }
808
- return context.isMultimodalSupportVision();
809
- } catch (Exception e) {
810
- exception = e;
811
- }
812
- return false;
813
- }
814
-
815
- @Override
816
- protected void onPostExecute(Boolean result) {
817
- if (exception != null) {
818
- promise.reject(exception);
819
- return;
820
- }
821
- promise.resolve(result);
822
- tasks.remove(this);
823
- }
824
- }.executeOnExecutor(singleThreadExecutor);
825
- tasks.put(task, "isMultimodalSupportVision-" + contextId);
826
- }
827
-
828
- public void isMultimodalSupportAudio(double id, final Promise promise) {
829
- final int contextId = (int) id;
830
- AsyncTask task = new AsyncTask<Void, Void, Boolean>() {
831
- private Exception exception;
832
-
833
- @Override
834
- protected Boolean doInBackground(Void... voids) {
835
- try {
836
- LlamaContext context = contexts.get(contextId);
837
- if (context == null) {
838
- throw new Exception("Context not found");
839
- }
840
- return context.isMultimodalSupportAudio();
841
- } catch (Exception e) {
842
- exception = e;
843
- }
844
- return false;
845
- }
846
-
847
- @Override
848
- protected void onPostExecute(Boolean result) {
849
- if (exception != null) {
850
- promise.reject(exception);
851
- return;
852
- }
853
- promise.resolve(result);
854
- tasks.remove(this);
855
- }
856
- }.executeOnExecutor(singleThreadExecutor);
857
- tasks.put(task, "isMultimodalSupportAudio-" + contextId);
858
- }
859
-
860
- public void releaseMultimodal(double id, final Promise promise) {
861
- final int contextId = (int) id;
862
- AsyncTask task = new AsyncTask<Void, Void, Void>() {
863
- private Exception exception;
864
-
865
- @Override
866
- protected Void doInBackground(Void... voids) {
867
- try {
868
- LlamaContext context = contexts.get(contextId);
869
- if (context == null) {
870
- throw new Exception("Context not found");
871
- }
872
- context.releaseMultimodal();
873
- } catch (Exception e) {
874
- exception = e;
875
- }
876
- return null;
877
- }
878
-
879
- @Override
880
- protected void onPostExecute(Void result) {
881
- if (exception != null) {
882
- promise.reject(exception);
883
- return;
884
- }
885
- promise.resolve(null);
886
- tasks.remove(this);
887
- }
888
- }.executeOnExecutor(singleThreadExecutor);
889
- tasks.put(task, "releaseMultimodal-" + contextId);
890
- }
891
-
892
- public void multimodalCompletion(double id, final String prompt, final ReadableArray mediaPaths, final ReadableMap params, final Promise promise) {
893
- final int contextId = (int) id;
894
- AsyncTask task = new AsyncTask<Void, Void, WritableMap>() {
895
- private Exception exception;
896
-
897
- @Override
898
- protected WritableMap doInBackground(Void... voids) {
899
- try {
900
- LlamaContext context = contexts.get(contextId);
901
- if (context == null) {
902
- throw new Exception("Context not found");
903
- }
904
- if (context.isPredicting()) {
905
- throw new Exception("Context is busy");
906
- }
907
- return context.multimodalCompletion(prompt, mediaPaths, params);
908
- } catch (Exception e) {
909
- exception = e;
910
- }
911
- return null;
912
- }
913
-
914
- @Override
915
- protected void onPostExecute(WritableMap result) {
916
- if (exception != null) {
917
- promise.reject(exception);
918
- return;
919
- }
920
- promise.resolve(result);
921
- tasks.remove(this);
922
- }
923
- }.executeOnExecutor(singleThreadExecutor);
924
- tasks.put(task, "multimodalCompletion-" + contextId);
925
- }
926
-
927
- public void initVocoder(double id, final String vocoderModelPath, final Promise promise) {
928
- final int contextId = (int) id;
929
- AsyncTask task = new AsyncTask<Void, Void, Boolean>() {
930
- private Exception exception;
931
-
932
- @Override
933
- protected Boolean doInBackground(Void... voids) {
934
- try {
935
- LlamaContext context = contexts.get(contextId);
936
- if (context == null) {
937
- throw new Exception("Context not found");
938
- }
939
- return context.initVocoder(vocoderModelPath);
940
- } catch (Exception e) {
941
- exception = e;
942
- }
943
- return false;
944
- }
945
-
946
- @Override
947
- protected void onPostExecute(Boolean result) {
948
- if (exception != null) {
949
- promise.reject(exception);
950
- return;
951
- }
952
- promise.resolve(result);
953
- tasks.remove(this);
954
- }
955
- }.executeOnExecutor(singleThreadExecutor);
956
- tasks.put(task, "initVocoder-" + contextId);
957
- }
958
-
959
- public void isVocoderEnabled(double id, final Promise promise) {
960
- final int contextId = (int) id;
961
- AsyncTask task = new AsyncTask<Void, Void, Boolean>() {
962
- private Exception exception;
963
-
964
- @Override
965
- protected Boolean doInBackground(Void... voids) {
966
- try {
967
- LlamaContext context = contexts.get(contextId);
968
- if (context == null) {
969
- throw new Exception("Context not found");
970
- }
971
- return context.isVocoderEnabled();
972
- } catch (Exception e) {
973
- exception = e;
974
- }
975
- return false;
976
- }
977
-
978
- @Override
979
- protected void onPostExecute(Boolean result) {
980
- if (exception != null) {
981
- promise.reject(exception);
982
- return;
983
- }
984
- promise.resolve(result);
985
- tasks.remove(this);
986
- }
987
- }.executeOnExecutor(singleThreadExecutor);
988
- tasks.put(task, "isVocoderEnabled-" + contextId);
989
- }
990
-
991
- public void getTTSType(double id, final Promise promise) {
992
- final int contextId = (int) id;
993
- AsyncTask task = new AsyncTask<Void, Void, Integer>() {
994
- private Exception exception;
995
-
996
- @Override
997
- protected Integer doInBackground(Void... voids) {
998
- try {
999
- LlamaContext context = contexts.get(contextId);
1000
- if (context == null) {
1001
- throw new Exception("Context not found");
1002
- }
1003
- return context.getTTSType();
1004
- } catch (Exception e) {
1005
- exception = e;
1006
- }
1007
- return -1;
1008
- }
1009
-
1010
- @Override
1011
- protected void onPostExecute(Integer result) {
1012
- if (exception != null) {
1013
- promise.reject(exception);
1014
- return;
1015
- }
1016
- promise.resolve(result);
1017
- tasks.remove(this);
1018
- }
1019
- }.executeOnExecutor(singleThreadExecutor);
1020
- tasks.put(task, "getTTSType-" + contextId);
1021
- }
1022
-
1023
- public void getFormattedAudioCompletion(double id, final String speakerJsonStr, final String textToSpeak, final Promise promise) {
1024
- final int contextId = (int) id;
1025
- AsyncTask task = new AsyncTask<Void, Void, String>() {
1026
- private Exception exception;
1027
-
1028
- @Override
1029
- protected String doInBackground(Void... voids) {
1030
- try {
1031
- LlamaContext context = contexts.get(contextId);
1032
- if (context == null) {
1033
- throw new Exception("Context not found");
1034
- }
1035
- return context.getFormattedAudioCompletion(speakerJsonStr, textToSpeak);
1036
- } catch (Exception e) {
1037
- exception = e;
1038
- }
1039
- return null;
1040
- }
1041
-
1042
- @Override
1043
- protected void onPostExecute(String result) {
1044
- if (exception != null) {
1045
- promise.reject(exception);
1046
- return;
1047
- }
1048
- promise.resolve(result);
1049
- tasks.remove(this);
1050
- }
1051
- }.executeOnExecutor(singleThreadExecutor);
1052
- tasks.put(task, "getFormattedAudioCompletion-" + contextId);
1053
- }
1054
-
1055
- public void getAudioCompletionGuideTokens(double id, final String textToSpeak, final Promise promise) {
1056
- final int contextId = (int) id;
1057
- AsyncTask task = new AsyncTask<Void, Void, WritableArray>() {
1058
- private Exception exception;
1059
-
1060
- @Override
1061
- protected WritableArray doInBackground(Void... voids) {
1062
- try {
1063
- LlamaContext context = contexts.get(contextId);
1064
- if (context == null) {
1065
- throw new Exception("Context not found");
1066
- }
1067
- return context.getAudioCompletionGuideTokens(textToSpeak);
1068
- } catch (Exception e) {
1069
- exception = e;
1070
- }
1071
- return null;
1072
- }
1073
-
1074
- @Override
1075
- protected void onPostExecute(WritableArray result) {
1076
- if (exception != null) {
1077
- promise.reject(exception);
1078
- return;
1079
- }
1080
- promise.resolve(result);
1081
- tasks.remove(this);
1082
- }
1083
- }.executeOnExecutor(singleThreadExecutor);
1084
- tasks.put(task, "getAudioCompletionGuideTokens-" + contextId);
1085
- }
1086
-
1087
- public void decodeAudioTokens(double id, final ReadableArray tokens, final Promise promise) {
1088
- final int contextId = (int) id;
1089
- AsyncTask task = new AsyncTask<Void, Void, WritableArray>() {
1090
- private Exception exception;
1091
-
1092
- @Override
1093
- protected WritableArray doInBackground(Void... voids) {
1094
- try {
1095
- LlamaContext context = contexts.get(contextId);
1096
- if (context == null) {
1097
- throw new Exception("Context not found");
1098
- }
1099
- return context.decodeAudioTokens(tokens);
1100
- } catch (Exception e) {
1101
- exception = e;
1102
- }
1103
- return null;
1104
- }
1105
-
1106
- @Override
1107
- protected void onPostExecute(WritableArray result) {
1108
- if (exception != null) {
1109
- promise.reject(exception);
1110
- return;
1111
- }
1112
- promise.resolve(result);
1113
- tasks.remove(this);
1114
- }
1115
- }.executeOnExecutor(singleThreadExecutor);
1116
- tasks.put(task, "decodeAudioTokens-" + contextId);
1117
- }
1118
-
1119
- @ReactMethod
1120
- public void getDeviceInfo(double id, final Promise promise) {
1121
- AsyncTask task = new AsyncTask<Void, Void, WritableMap>() {
1122
- private Exception exception;
1123
-
1124
- @Override
1125
- protected WritableMap doInBackground(Void... voids) {
1126
- try {
1127
- WritableMap deviceInfo = Arguments.createMap();
1128
-
1129
- String deviceId = Settings.Secure.getString(reactContext.getContentResolver(), Settings.Secure.ANDROID_ID);
1130
-
1131
- String make = Build.MANUFACTURER;
1132
- String model = Build.MODEL;
1133
- String osVersion = Build.VERSION.RELEASE;
1134
-
1135
- deviceInfo.putString("deviceId", deviceId);
1136
- deviceInfo.putString("make", make);
1137
- deviceInfo.putString("model", model);
1138
- deviceInfo.putString("os", "Android");
1139
- deviceInfo.putString("osVersion", osVersion);
1140
-
1141
- return deviceInfo;
1142
- } catch (Exception e) {
1143
- exception = e;
1144
- }
1145
- return null;
1146
- }
1147
-
1148
- @Override
1149
- protected void onPostExecute(WritableMap result) {
1150
- if (exception != null) {
1151
- promise.reject(exception);
1152
- return;
1153
- }
1154
- promise.resolve(result);
1155
- }
1156
- }.executeOnExecutor(singleThreadExecutor);
1157
- }
1158
-
1159
- public void releaseVocoder(double id, final Promise promise) {
1160
- final int contextId = (int) id;
1161
- AsyncTask task = new AsyncTask<Void, Void, Void>() {
1162
- private Exception exception;
1163
-
1164
- @Override
1165
- protected Void doInBackground(Void... voids) {
1166
- try {
1167
- LlamaContext context = contexts.get(contextId);
1168
- if (context == null) {
1169
- throw new Exception("Context not found");
1170
- }
1171
- context.releaseVocoder();
1172
- } catch (Exception e) {
1173
- exception = e;
1174
- }
1175
- return null;
1176
- }
1177
-
1178
- @Override
1179
- protected void onPostExecute(Void result) {
1180
- if (exception != null) {
1181
- promise.reject(exception);
1182
- return;
1183
- }
1184
- promise.resolve(null);
1185
- tasks.remove(this);
1186
- }
1187
- }.executeOnExecutor(singleThreadExecutor);
1188
- tasks.put(task, "releaseVocoder-" + contextId);
1189
- }
1190
- }