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,141 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TTSError = exports.CactusTTS = void 0;
7
- var _index = require("./index");
8
- class TTSError extends Error {
9
- constructor(message, code, contextId) {
10
- super(message);
11
- this.code = code;
12
- this.contextId = contextId;
13
- this.name = 'TTSError';
14
- }
15
- }
16
- exports.TTSError = TTSError;
17
- class CactusTTS {
18
- isInitialized = false;
19
- isReleased = false;
20
- constructor(context, vocoderPath) {
21
- this.context = context;
22
- this.vocoderPath = vocoderPath;
23
- }
24
- static async init(context, vocoderModelPath) {
25
- if (!context) {
26
- throw new TTSError('LlamaContext is required', 'INVALID_CONTEXT');
27
- }
28
- if (!vocoderModelPath || typeof vocoderModelPath !== 'string') {
29
- throw new TTSError('Valid vocoder model path is required', 'INVALID_VOCODER_PATH');
30
- }
31
- try {
32
- await (0, _index.initVocoder)(context.id, vocoderModelPath);
33
- const instance = new CactusTTS(context, vocoderModelPath);
34
- instance.isInitialized = true;
35
- instance.ttsType = await (0, _index.getTTSType)(context.id);
36
- return instance;
37
- } catch (error) {
38
- throw new TTSError(`Failed to initialize TTS: ${error instanceof Error ? error.message : 'Unknown error'}`, 'INITIALIZATION_FAILED', context.id);
39
- }
40
- }
41
- async generate(textToSpeak, speaker, options) {
42
- this.validateState();
43
- this.validateInputs(textToSpeak, speaker);
44
- const speakerConfig = typeof speaker === 'string' ? speaker : JSON.stringify(speaker.config);
45
- const startTime = Date.now();
46
- try {
47
- const {
48
- formatted_prompt
49
- } = await (0, _index.getFormattedAudioCompletion)(this.context.id, speakerConfig, textToSpeak);
50
- if (!formatted_prompt) {
51
- throw new TTSError('Failed to format audio prompt', 'FORMATTING_FAILED', this.context.id);
52
- }
53
- const tokenizeResult = await this.context.tokenize(formatted_prompt);
54
- if (!tokenizeResult?.tokens || tokenizeResult.tokens.length === 0) {
55
- throw new TTSError('Failed to tokenize prompt', 'TOKENIZATION_FAILED', this.context.id);
56
- }
57
- const audioResult = await (0, _index.decodeAudioTokens)(this.context.id, tokenizeResult.tokens);
58
- const endTime = Date.now();
59
- return {
60
- ...audioResult,
61
- metadata: {
62
- duration: endTime - startTime,
63
- sampleRate: options?.sampleRate,
64
- format: options?.format || 'wav',
65
- channels: 1 // Assuming mono output
66
- }
67
- };
68
- } catch (error) {
69
- if (error instanceof TTSError) {
70
- throw error;
71
- }
72
- throw new TTSError(`Audio generation failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'GENERATION_FAILED', this.context.id);
73
- }
74
- }
75
- async isVocoderReady() {
76
- if (!this.isInitialized || this.isReleased) {
77
- return false;
78
- }
79
- try {
80
- return await (0, _index.isVocoderEnabled)(this.context.id);
81
- } catch {
82
- return false;
83
- }
84
- }
85
- getTTSType() {
86
- return this.ttsType;
87
- }
88
- getContextId() {
89
- return this.context.id;
90
- }
91
- getVocoderPath() {
92
- return this.vocoderPath;
93
- }
94
- isReady() {
95
- return this.isInitialized && !this.isReleased;
96
- }
97
- static createSpeaker(id, config, metadata) {
98
- return {
99
- id,
100
- config,
101
- ...metadata
102
- };
103
- }
104
- validateState() {
105
- if (this.isReleased) {
106
- throw new TTSError('TTS instance has been released', 'INSTANCE_RELEASED', this.context.id);
107
- }
108
- if (!this.isInitialized) {
109
- throw new TTSError('TTS instance not initialized', 'NOT_INITIALIZED', this.context.id);
110
- }
111
- }
112
- validateInputs(textToSpeak, speaker) {
113
- if (!textToSpeak || typeof textToSpeak !== 'string' || textToSpeak.trim().length === 0) {
114
- throw new TTSError('Valid text input is required', 'INVALID_TEXT_INPUT');
115
- }
116
- if (textToSpeak.length > 10000) {
117
- // Reasonable limit
118
- throw new TTSError('Text input too long (max 10000 characters)', 'TEXT_TOO_LONG');
119
- }
120
- if (!speaker) {
121
- throw new TTSError('Speaker configuration is required', 'INVALID_SPEAKER');
122
- }
123
- if (typeof speaker === 'object' && (!speaker.id || !speaker.config)) {
124
- throw new TTSError('Speaker must have id and config properties', 'INVALID_SPEAKER_FORMAT');
125
- }
126
- }
127
- async release() {
128
- if (this.isReleased) {
129
- return; // Already released, no-op
130
- }
131
- try {
132
- await (0, _index.releaseVocoder)(this.context.id);
133
- this.isReleased = true;
134
- this.isInitialized = false;
135
- } catch (error) {
136
- throw new TTSError(`Failed to release TTS resources: ${error instanceof Error ? error.message : 'Unknown error'}`, 'RELEASE_FAILED', this.context.id);
137
- }
138
- }
139
- }
140
- exports.CactusTTS = CactusTTS;
141
- //# sourceMappingURL=tts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_index","require","TTSError","Error","constructor","message","code","contextId","name","exports","CactusTTS","isInitialized","isReleased","context","vocoderPath","init","vocoderModelPath","initVocoder","id","instance","ttsType","getTTSType","error","generate","textToSpeak","speaker","options","validateState","validateInputs","speakerConfig","JSON","stringify","config","startTime","Date","now","formatted_prompt","getFormattedAudioCompletion","tokenizeResult","tokenize","tokens","length","audioResult","decodeAudioTokens","endTime","metadata","duration","sampleRate","format","channels","isVocoderReady","isVocoderEnabled","getContextId","getVocoderPath","isReady","createSpeaker","trim","release","releaseVocoder"],"sourceRoot":"../../src","sources":["tts.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAqCO,MAAMC,QAAQ,SAASC,KAAK,CAAC;EAClCC,WAAWA,CACTC,OAAe,EACRC,IAAa,EACbC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EACf,CAAC;IACH;EACF;AACF;AAACT,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -1,221 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CactusVLM = void 0;
7
- var _index = require("./index");
8
- var _telemetry = require("./telemetry");
9
- var _remote = require("./remote");
10
- var _chat = require("./chat");
11
- class CactusVLM {
12
- static _initCache = new Map();
13
- static getCacheKey(params, cactusToken, retryOptions) {
14
- return JSON.stringify({
15
- params,
16
- cactusToken,
17
- retryOptions
18
- });
19
- }
20
- constructor(context) {
21
- this.context = context;
22
- this.conversationHistoryManager = new _chat.ConversationHistoryManager();
23
- }
24
- static async init(params, onProgress, cactusToken, retryOptions) {
25
- if (cactusToken) {
26
- (0, _remote.setCactusToken)(cactusToken);
27
- }
28
- const key = CactusVLM.getCacheKey(params, cactusToken, retryOptions);
29
- if (CactusVLM._initCache.has(key)) {
30
- return CactusVLM._initCache.get(key);
31
- }
32
- const initPromise = (async () => {
33
- const maxRetries = retryOptions?.maxRetries ?? 3;
34
- const delayMs = retryOptions?.delayMs ?? 1000;
35
- const configs = [params, {
36
- ...params,
37
- n_gpu_layers: 0
38
- }];
39
- const sleep = ms => {
40
- return new Promise(resolve => {
41
- const start = Date.now();
42
- const wait = () => {
43
- if (Date.now() - start >= ms) {
44
- resolve();
45
- } else {
46
- Promise.resolve().then(wait);
47
- }
48
- };
49
- wait();
50
- });
51
- };
52
- for (const config of configs) {
53
- let lastError = null;
54
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
55
- try {
56
- const context = await (0, _index.initLlama)(config, onProgress);
57
- await (0, _index.initMultimodal)(context.id, params.mmproj, false);
58
- return {
59
- vlm: new CactusVLM(context),
60
- error: null
61
- };
62
- } catch (e) {
63
- lastError = e;
64
- const isLastConfig = configs.indexOf(config) === configs.length - 1;
65
- const isLastAttempt = attempt === maxRetries;
66
- _telemetry.Telemetry.error(e, {
67
- n_gpu_layers: config.n_gpu_layers ?? null,
68
- n_ctx: config.n_ctx ?? null,
69
- model: config.model ?? null
70
- });
71
- if (!isLastAttempt) {
72
- const delay = delayMs * Math.pow(2, attempt - 1);
73
- await sleep(delay);
74
- } else if (!isLastConfig) {
75
- break;
76
- }
77
- }
78
- }
79
- if (configs.indexOf(config) === configs.length - 1 && lastError) {
80
- return {
81
- vlm: null,
82
- error: lastError
83
- };
84
- }
85
- }
86
- return {
87
- vlm: null,
88
- error: new Error('Failed to initialize CactusVLM')
89
- };
90
- })();
91
- CactusVLM._initCache.set(key, initPromise);
92
- const result = await initPromise;
93
- if (result.error) {
94
- CactusVLM._initCache.delete(key);
95
- }
96
- return result;
97
- }
98
- async completion(messages, params = {}, callback) {
99
- const mode = params.mode || 'local';
100
- let result;
101
- let lastError = null;
102
- if (mode === 'remote') {
103
- result = await this._handleRemoteCompletion(messages, params, callback);
104
- } else if (mode === 'local') {
105
- result = await this._handleLocalCompletion(messages, params, callback);
106
- } else if (mode === 'localfirst') {
107
- try {
108
- result = await this._handleLocalCompletion(messages, params, callback);
109
- } catch (e) {
110
- lastError = e;
111
- try {
112
- result = await this._handleRemoteCompletion(messages, params, callback);
113
- } catch (remoteError) {
114
- throw lastError;
115
- }
116
- }
117
- } else if (mode === 'remotefirst') {
118
- try {
119
- result = await this._handleRemoteCompletion(messages, params, callback);
120
- } catch (e) {
121
- lastError = e;
122
- try {
123
- result = await this._handleLocalCompletion(messages, params, callback);
124
- } catch (localError) {
125
- throw lastError;
126
- }
127
- }
128
- } else {
129
- throw new Error('Invalid mode: ' + mode + '. Must be "local", "remote", "localfirst", or "remotefirst"');
130
- }
131
- return result;
132
- }
133
- _handleLocalCompletion = async (messages, params, callback) => {
134
- const {
135
- newMessages,
136
- requiresReset
137
- } = this.conversationHistoryManager.processNewMessages(messages);
138
- if (requiresReset) {
139
- this.context?.rewind();
140
- this.conversationHistoryManager.reset();
141
- }
142
- if (newMessages.length === 0) {
143
- console.warn('No messages to complete!');
144
- }
145
- let result;
146
- if (params.images && params.images.length > 0) {
147
- const formattedPrompt = await this.context.getFormattedChat(newMessages);
148
- const prompt = typeof formattedPrompt === 'string' ? formattedPrompt : formattedPrompt.prompt;
149
- result = await (0, _index.multimodalCompletion)(this.context.id, prompt, params.images, {
150
- ...params,
151
- prompt,
152
- emit_partial_completion: !!callback
153
- });
154
- } else {
155
- result = await this.context.completion({
156
- messages: newMessages,
157
- ...params
158
- }, callback);
159
- }
160
- this.conversationHistoryManager.update(newMessages, {
161
- role: 'assistant',
162
- content: result.content || result.text
163
- });
164
- return result;
165
- };
166
- async _handleRemoteCompletion(messages, params, callback) {
167
- const prompt = messages.map(m => `${m.role}: ${m.content}`).join('\n');
168
- const imagePath = params.images && params.images.length > 0 ? params.images[0] : '';
169
- let responseText;
170
- if (imagePath) {
171
- responseText = await (0, _remote.getVisionCompletion)(messages, imagePath);
172
- } else {
173
- responseText = await (0, _remote.getTextCompletion)(messages);
174
- }
175
- if (callback) {
176
- for (let i = 0; i < responseText.length; i++) {
177
- callback({
178
- token: responseText[i]
179
- });
180
- }
181
- }
182
- return {
183
- text: responseText,
184
- reasoning_content: '',
185
- tool_calls: [],
186
- content: responseText,
187
- tokens_predicted: responseText.split(' ').length,
188
- tokens_evaluated: prompt.split(' ').length,
189
- truncated: false,
190
- stopped_eos: true,
191
- stopped_word: '',
192
- stopped_limit: 0,
193
- stopping_word: '',
194
- tokens_cached: 0,
195
- timings: {
196
- prompt_n: prompt.split(' ').length,
197
- prompt_ms: 0,
198
- prompt_per_token_ms: 0,
199
- prompt_per_second: 0,
200
- predicted_n: responseText.split(' ').length,
201
- predicted_ms: 0,
202
- predicted_per_token_ms: 0,
203
- predicted_per_second: 0
204
- }
205
- };
206
- }
207
- async rewind() {
208
- return this.context?.rewind();
209
- }
210
- async release() {
211
- return this.context.release();
212
- }
213
- async stopCompletion() {
214
- return await this.context.stopCompletion();
215
- }
216
- isJinjaSupported() {
217
- return this.context.isJinjaSupported();
218
- }
219
- }
220
- exports.CactusVLM = CactusVLM;
221
- //# sourceMappingURL=vlm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_index","require","_telemetry","_remote","_chat","CactusVLM","_initCache","Map","getCacheKey","params","cactusToken","retryOptions","JSON","stringify","constructor","context","conversationHistoryManager","ConversationHistoryManager","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","initLlama","initMultimodal","id","mmproj","vlm","error","e","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","reset","console","warn","images","formattedPrompt","getFormattedChat","prompt","multimodalCompletion","emit_partial_completion","update","role","content","text","map","m","join","imagePath","responseText","getVisionCompletion","getTextCompletion","i","token","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","release","stopCompletion","isJinjaSupported","exports"],"sourceRoot":"../../src","sources":["vlm.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAWA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAgBO,MAAMI,SAAS,CAAC;EAIrB,OAAeC,UAAU,GAA0C,IAAIC,GAAG,CAAC,CAAC;EAE5E,OAAeC,WAAWA,CAACC,MAAwB,EAAEC,WAAoB,EAAEC,YAAwD,EAAU;IAC3I,OAAOC,IAAI,CAACC,SAAS,CAAC;MAAEJ,MAAM;MAAEC,WAAW;MAAEC;IAAa,CAAC,CAAC;EAC9D;EAEQG,WAAWA,CAACC,OAAqB,EAAE;IACzC,IAAI,C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,OAAO,CAACsG,cAAc,CAAC,CAAC;EAC5C;EAEAC,gBAAgBA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACvG,OAAO,CAACuG,gBAAgB,CAAC,CAAC;EACxC;AACF;AAACC,OAAA,CAAAlH,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- import { TurboModuleRegistry } from 'react-native';
4
- export default TurboModuleRegistry.get('Cactus');
5
- //# sourceMappingURL=NativeCactus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["TurboModuleRegistry","get"],"sourceRoot":"../../src","sources":["NativeCactus.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AA2TlD,eAAeA,mBAAmB,CAACC,GAAG,CAAO,QAAQ,CAAC","ignoreList":[]}
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- import { CactusLM } from './lm';
4
- import { Tools } from './tools';
5
- export class CactusAgent extends CactusLM {
6
- static async init(params, onProgress, cactusToken, retryOptions) {
7
- const result = await CactusLM.init(params, onProgress, cactusToken, retryOptions);
8
- if (result.error || !result.lm) {
9
- return {
10
- agent: null,
11
- error: result.error,
12
- lm: null
13
- };
14
- }
15
- const agent = Object.setPrototypeOf(result.lm, CactusAgent.prototype);
16
- agent.tools = new Tools();
17
- return {
18
- agent,
19
- error: null,
20
- lm: agent
21
- };
22
- }
23
- addTool(func, description, parameters) {
24
- return this.tools.add(func, description, parameters);
25
- }
26
- getTools() {
27
- return this.tools;
28
- }
29
- async completionWithTools(messages, params = {}, callback, recursionCount = 0, recursionLimit = 3) {
30
- const tools = params.tools || this.tools;
31
- if (!messages?.length) {
32
- return this.completion([], params, callback);
33
- }
34
- if (!tools || tools.getSchemas().length === 0) {
35
- return this.completion(messages, params, callback);
36
- }
37
- if (recursionCount >= recursionLimit) {
38
- return this.completion(messages, {
39
- ...params,
40
- jinja: true,
41
- tools: tools.getSchemas()
42
- }, callback);
43
- }
44
- const {
45
- newMessages,
46
- requiresReset
47
- } = this.conversationHistoryManager.processNewMessages(messages);
48
- if (requiresReset) {
49
- this.context?.rewind();
50
- this.conversationHistoryManager.reset();
51
- }
52
- const result = await this.context.completionWithTools({
53
- ...params,
54
- messages: newMessages.length > 0 ? newMessages : messages,
55
- tools: tools
56
- }, callback, recursionCount, recursionLimit);
57
- this.conversationHistoryManager.update(newMessages.length > 0 ? newMessages : messages, {
58
- role: 'assistant',
59
- content: result.content,
60
- tool_calls: result.tool_calls
61
- });
62
- return result;
63
- }
64
- isJinjaSupported() {
65
- return this.context.isJinjaSupported();
66
- }
67
- }
68
- //# sourceMappingURL=agent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["CactusLM","Tools","CactusAgent","init","params","onProgress","cactusToken","retryOptions","result","error","lm","agent","Object","setPrototypeOf","prototype","tools","addTool","func","description","parameters","add","getTools","completionWithTools","messages","callback","recursionCount","recursionLimit","length","completion","getSchemas","jinja","newMessages","requiresReset","conversationHistoryManager","processNewMessages","context","rewind","reset","update","role","content","tool_calls","isJinjaSupported"],"sourceRoot":"../../src","sources":["agent.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,MAAM;AAU/B,SAASC,KAAK,QAAQ,SAAS;AAkB/B,OAAO,MAAMC,WAAW,SAASF,QAAQ,CAAC;EAGxC,aAAaG,IAAIA,CACfC,MAAqB,EACrBC,UAAuC,EACvCC,WAAoB,EACpBC,YAAwD,EAC5B;IAC5B,MAAMC,MAAM,GAAG,MAAMR,QAAQ,CAACG,IAAI,CAACC,MAAM,EAAEC,UAAU,EAAEC,WAAW,EAAEC,YAAY,CAAC;IAEjF,IAAIC,MAAM,CAACC,KAAK,IAAI,CAACD,MAAM,CAACE,EAAE,EAAE;MAC9B,OAAO;QAAEC,KAAK,EAAE,IAAI;QAAEF,KAAK,EAAED,MAAM,CAACC,KAAK;QAAEC,EAAE,EAAE;MAAK,CAAC;IACvD;IAEA,MAAMC,KAAK,GAAGC,MAAM,CAACC,cAAc,CAACL,MAA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ACX,QAAQ,CAAC;IAE9D,IAAIS,aAAa,EAAE;MACjB,IAAI,CAACG,OAAO,EAAEC,MAAM,CAAC,CAAC;MACtB,IAAI,CAACH,0BAA0B,CAACI,KAAK,CAAC,CAAC;IACzC;IAEA,MAAM7B,MAAM,GAAG,MAAM,IAAI,CAAC2B,OAAO,CAACb,mBAAmB,CAAC;MACpD,GAAGlB,MAAM;MACTmB,QAAQ,EAAEQ,WAAW,CAACJ,MAAM,GAAG,CAAC,GAAGI,WAAW,GAAGR,QAAQ;MACzDR,KAAK,EAAEA;IACT,CAAC,EAAES,QAAQ,EAAEC,cAAc,EAAEC,cAAc,CAAC;IAE5C,IAAI,CAACO,0BAA0B,CAACK,MAAM,CACpCP,WAAW,CAACJ,MAAM,GAAG,CAAC,GAAGI,WAAW,GAAGR,QAAQ,EAC/C;MACEgB,IAAI,EAAE,WAAW;MACjBC,OAAO,EAAEhC,MAAM,CAACgC,OAAO;MACvBC,UAAU,EAAEjC,MAAM,CAACiC;IACrB,CACF,CAAC;IAED,OAAOjC,MAAM;EACf;EACAkC,gBAAgBA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACP,OAAO,CAACO,gBAAgB,CAAC,CAAC;EACxC;AACF","ignoreList":[]}
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- export function formatChat(messages) {
4
- const chat = [];
5
- messages.forEach(currMsg => {
6
- const role = currMsg.role || '';
7
- let content = '';
8
- if ('content' in currMsg) {
9
- if (typeof currMsg.content === 'string') {
10
- ;
11
- ({
12
- content
13
- } = currMsg);
14
- } else if (Array.isArray(currMsg.content)) {
15
- currMsg.content.forEach(part => {
16
- if ('text' in part) {
17
- content += `${content ? '\n' : ''}${part.text}`;
18
- }
19
- });
20
- } else {
21
- throw new TypeError("Invalid 'content' type (ref: https://github.com/ggerganov/llama.cpp/issues/8367)");
22
- }
23
- } else {
24
- throw new Error("Missing 'content' (ref: https://github.com/ggerganov/llama.cpp/issues/8367)");
25
- }
26
- chat.push({
27
- role,
28
- content
29
- });
30
- });
31
- return chat;
32
- }
33
- export class ConversationHistoryManager {
34
- history = [];
35
- processNewMessages(fullMessageHistory) {
36
- let divergent = fullMessageHistory.length < this.history.length;
37
- if (!divergent) {
38
- for (let i = 0; i < this.history.length; i++) {
39
- if (JSON.stringify(this.history[i]) !== JSON.stringify(fullMessageHistory[i])) {
40
- divergent = true;
41
- break;
42
- }
43
- }
44
- }
45
- if (divergent) {
46
- return {
47
- newMessages: fullMessageHistory,
48
- requiresReset: true
49
- };
50
- }
51
- const newMessages = fullMessageHistory.slice(this.history.length);
52
- return {
53
- newMessages,
54
- requiresReset: false
55
- };
56
- }
57
- update(newMessages, assistantResponse) {
58
- this.history.push(...newMessages, assistantResponse);
59
- }
60
- reset() {
61
- this.history = [];
62
- }
63
- getMessages() {
64
- return this.history;
65
- }
66
- }
67
- //# sourceMappingURL=chat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["formatChat","messages","chat","forEach","currMsg","role","content","Array","isArray","part","text","TypeError","Error","push","ConversationHistoryManager","history","processNewMessages","fullMessageHistory","divergent","length","i","JSON","stringify","newMessages","requiresReset","slice","update","assistantResponse","reset","getMessages"],"sourceRoot":"../../src","sources":["chat.ts"],"mappings":";;AAaA,OAAO,SAASA,UAAUA,CACxBC,QAAsC,EACZ;EAC1B,MAAMC,IAA8B,GAAG,EAAE;EAEzCD,QAAQ,CAACE,OAAO,CAAEC,OAAO,IAAK;IAC5B,MAAMC,IAAY,GAAGD,OAAO,CAACC,IAAI,IAAI,EAAE;IAEvC,IAAIC,OAAe,GAAG,EAAE;IACxB,IAAI,SAAS,IAAIF,OAAO,EAAE;MACxB,IAAI,OAAOA,OAAO,CAACE,OAAO,KAAK,QAAQ,EAAE;QACvC;QAAC,CAAC;UAAEA;QAAQ,CAAC,GAAGF,OAAO;MACzB,CAAC,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,OAAO,CAACE,OAAO,CAAC,EAAE;QACzCF,OAAO,CAACE,OAAO,CA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