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,674 +0,0 @@
1
- // Various helper functions and utilities
2
-
3
- #pragma once
4
-
5
- #include "llama-cpp.h"
6
-
7
- #include <set>
8
- #include <string>
9
- #include <string_view>
10
- #include <vector>
11
- #include <sstream>
12
-
13
- #ifdef _WIN32
14
- #define DIRECTORY_SEPARATOR '\\'
15
- #else
16
- #define DIRECTORY_SEPARATOR '/'
17
- #endif // _WIN32
18
-
19
- #define die(msg) do { fputs("error: " msg "\n", stderr); exit(1); } while (0)
20
- #define die_fmt(fmt, ...) do { fprintf(stderr, "error: " fmt "\n", __VA_ARGS__); exit(1); } while (0)
21
-
22
- #define print_build_info() do { \
23
- fprintf(stderr, "%s: build = %d (%s)\n", __func__, LLAMA_BUILD_NUMBER, LLAMA_COMMIT); \
24
- fprintf(stderr, "%s: built with %s for %s\n", __func__, LLAMA_COMPILER, LLAMA_BUILD_TARGET); \
25
- } while(0)
26
-
27
- #define DEFAULT_MODEL_PATH "models/7B/ggml-model-f16.gguf"
28
-
29
- struct common_adapter_lora_info {
30
- std::string path;
31
- float scale;
32
-
33
- struct llama_adapter_lora * ptr;
34
- };
35
-
36
- using llama_tokens = std::vector<llama_token>;
37
-
38
- // build info
39
- extern int LLAMA_BUILD_NUMBER;
40
- extern const char * LLAMA_COMMIT;
41
- extern const char * LLAMA_COMPILER;
42
- extern const char * LLAMA_BUILD_TARGET;
43
-
44
- struct common_control_vector_load_info;
45
-
46
- //
47
- // CPU utils
48
- //
49
-
50
- struct cpu_params {
51
- int n_threads = -1;
52
- bool cpumask[LM_GGML_MAX_N_THREADS] = {false}; // CPU affinity mask.
53
- bool mask_valid = false; // Default: any CPU
54
- enum lm_ggml_sched_priority priority = LM_GGML_SCHED_PRIO_NORMAL; // Scheduling prio : (0 - normal, 1 - medium, 2 - high, 3 - realtime)
55
- bool strict_cpu = false; // Use strict CPU placement
56
- uint32_t poll = 50; // Polling (busywait) level (0 - no polling, 100 - mostly polling)
57
- };
58
-
59
- int32_t cpu_get_num_physical_cores();
60
- int32_t cpu_get_num_math();
61
-
62
- //
63
- // Common params
64
- //
65
-
66
- enum llama_example {
67
- LLAMA_EXAMPLE_COMMON,
68
- LLAMA_EXAMPLE_SPECULATIVE,
69
- LLAMA_EXAMPLE_MAIN,
70
- LLAMA_EXAMPLE_EMBEDDING,
71
- LLAMA_EXAMPLE_PERPLEXITY,
72
- LLAMA_EXAMPLE_RETRIEVAL,
73
- LLAMA_EXAMPLE_PASSKEY,
74
- LLAMA_EXAMPLE_IMATRIX,
75
- LLAMA_EXAMPLE_BENCH,
76
- LLAMA_EXAMPLE_SERVER,
77
- LLAMA_EXAMPLE_CVECTOR_GENERATOR,
78
- LLAMA_EXAMPLE_EXPORT_LORA,
79
- LLAMA_EXAMPLE_MTMD,
80
- LLAMA_EXAMPLE_LOOKUP,
81
- LLAMA_EXAMPLE_PARALLEL,
82
- LLAMA_EXAMPLE_TTS,
83
-
84
- LLAMA_EXAMPLE_COUNT,
85
- };
86
-
87
- enum common_sampler_type {
88
- COMMON_SAMPLER_TYPE_NONE = 0,
89
- COMMON_SAMPLER_TYPE_DRY = 1,
90
- COMMON_SAMPLER_TYPE_TOP_K = 2,
91
- COMMON_SAMPLER_TYPE_TOP_P = 3,
92
- COMMON_SAMPLER_TYPE_MIN_P = 4,
93
- //COMMON_SAMPLER_TYPE_TFS_Z = 5,
94
- COMMON_SAMPLER_TYPE_TYPICAL_P = 6,
95
- COMMON_SAMPLER_TYPE_TEMPERATURE = 7,
96
- COMMON_SAMPLER_TYPE_XTC = 8,
97
- COMMON_SAMPLER_TYPE_INFILL = 9,
98
- COMMON_SAMPLER_TYPE_PENALTIES = 10,
99
- COMMON_SAMPLER_TYPE_TOP_N_SIGMA = 11,
100
- };
101
-
102
- // dimensionality reduction methods, used by cvector-generator
103
- enum dimre_method {
104
- DIMRE_METHOD_PCA,
105
- DIMRE_METHOD_MEAN,
106
- };
107
-
108
- enum common_conversation_mode {
109
- COMMON_CONVERSATION_MODE_DISABLED = 0,
110
- COMMON_CONVERSATION_MODE_ENABLED = 1,
111
- COMMON_CONVERSATION_MODE_AUTO = 2,
112
- };
113
-
114
- enum common_grammar_trigger_type {
115
- COMMON_GRAMMAR_TRIGGER_TYPE_TOKEN,
116
- COMMON_GRAMMAR_TRIGGER_TYPE_WORD,
117
- COMMON_GRAMMAR_TRIGGER_TYPE_PATTERN,
118
- COMMON_GRAMMAR_TRIGGER_TYPE_PATTERN_START,
119
- };
120
-
121
- struct common_grammar_trigger {
122
- common_grammar_trigger_type type;
123
- std::string value;
124
- llama_token token = LLAMA_TOKEN_NULL;
125
- };
126
-
127
- // sampling parameters
128
- struct common_params_sampling {
129
- uint32_t seed = LLAMA_DEFAULT_SEED; // the seed used to initialize llama_sampler
130
-
131
- int32_t n_prev = 64; // number of previous tokens to remember
132
- int32_t n_probs = 0; // if greater than 0, output the probabilities of top n_probs tokens.
133
- int32_t min_keep = 0; // 0 = disabled, otherwise samplers should return at least min_keep tokens
134
- int32_t top_k = 40; // <= 0 to use vocab size
135
- float top_p = 0.95f; // 1.0 = disabled
136
- float min_p = 0.05f; // 0.0 = disabled
137
- float xtc_probability = 0.00f; // 0.0 = disabled
138
- float xtc_threshold = 0.10f; // > 0.5 disables XTC
139
- float typ_p = 1.00f; // typical_p, 1.0 = disabled
140
- float temp = 0.80f; // <= 0.0 to sample greedily, 0.0 to not output probabilities
141
- float dynatemp_range = 0.00f; // 0.0 = disabled
142
- float dynatemp_exponent = 1.00f; // controls how entropy maps to temperature in dynamic temperature sampler
143
- int32_t penalty_last_n = 64; // last n tokens to penalize (0 = disable penalty, -1 = context size)
144
- float penalty_repeat = 1.00f; // 1.0 = disabled
145
- float penalty_freq = 0.00f; // 0.0 = disabled
146
- float penalty_present = 0.00f; // 0.0 = disabled
147
- float dry_multiplier = 0.0f; // 0.0 = disabled; DRY repetition penalty for tokens extending repetition:
148
- float dry_base = 1.75f; // 0.0 = disabled; multiplier * base ^ (length of sequence before token - allowed length)
149
- int32_t dry_allowed_length = 2; // tokens extending repetitions beyond this receive penalty
150
- int32_t dry_penalty_last_n = -1; // how many tokens to scan for repetitions (0 = disable penalty, -1 = context size)
151
- int32_t mirostat = 0; // 0 = disabled, 1 = mirostat, 2 = mirostat 2.0
152
- float top_n_sigma = -1.00f;// -1.0 = disabled
153
- float mirostat_tau = 5.00f; // target entropy
154
- float mirostat_eta = 0.10f; // learning rate
155
- bool ignore_eos = false;
156
- bool no_perf = false; // disable performance metrics
157
- bool timing_per_token = false;
158
-
159
- std::vector<std::string> dry_sequence_breakers = {"\n", ":", "\"", "*"}; // default sequence breakers for DRY
160
-
161
-
162
- std::vector<enum common_sampler_type> samplers = {
163
- COMMON_SAMPLER_TYPE_PENALTIES,
164
- COMMON_SAMPLER_TYPE_DRY,
165
- COMMON_SAMPLER_TYPE_TOP_N_SIGMA,
166
- COMMON_SAMPLER_TYPE_TOP_K,
167
- COMMON_SAMPLER_TYPE_TYPICAL_P,
168
- COMMON_SAMPLER_TYPE_TOP_P,
169
- COMMON_SAMPLER_TYPE_MIN_P,
170
- COMMON_SAMPLER_TYPE_XTC,
171
- COMMON_SAMPLER_TYPE_TEMPERATURE,
172
- };
173
-
174
- std::string grammar; // optional BNF-like grammar to constrain sampling
175
- bool grammar_lazy = false;
176
- std::vector<common_grammar_trigger> grammar_triggers; // optional triggers (for lazy grammars)
177
- std::set<llama_token> preserved_tokens;
178
-
179
- std::vector<llama_logit_bias> logit_bias; // logit biases to apply
180
-
181
- // print the parameters into a string
182
- std::string print() const;
183
- };
184
-
185
- struct common_params_model {
186
- std::string path = ""; // model local path // NOLINT
187
- std::string url = ""; // model url to download // NOLINT
188
- std::string hf_repo = ""; // HF repo // NOLINT
189
- std::string hf_file = ""; // HF file // NOLINT
190
- };
191
-
192
- struct common_params_speculative {
193
- std::vector<lm_ggml_backend_dev_t> devices; // devices to use for offloading
194
-
195
- int32_t n_ctx = 0; // draft context size
196
- int32_t n_max = 16; // maximum number of tokens to draft during speculative decoding
197
- int32_t n_min = 0; // minimum number of draft tokens to use for speculative decoding
198
- int32_t n_gpu_layers = -1; // number of layers to store in VRAM for the draft model (-1 - use default)
199
- float p_split = 0.1f; // speculative decoding split probability
200
- float p_min = 0.75f; // minimum speculative decoding probability (greedy)
201
-
202
- struct cpu_params cpuparams;
203
- struct cpu_params cpuparams_batch;
204
-
205
- struct common_params_model model;
206
- };
207
-
208
- struct common_params_vocoder {
209
- struct common_params_model model;
210
-
211
- std::string speaker_file = ""; // speaker file path // NOLINT
212
-
213
- bool use_guide_tokens = false; // enable guide tokens to improve TTS accuracy // NOLINT
214
- };
215
-
216
- enum common_reasoning_format {
217
- COMMON_REASONING_FORMAT_NONE,
218
- COMMON_REASONING_FORMAT_DEEPSEEK, // Extract thinking tag contents and return as `message.reasoning_content`
219
- };
220
-
221
- struct common_params {
222
- bool vocab_only = false;
223
- int32_t n_predict = -1; // new tokens to predict
224
- int32_t n_ctx = 4096; // context size
225
- int32_t n_batch = 2048; // logical batch size for prompt processing (must be >=32 to use BLAS)
226
- int32_t n_ubatch = 512; // physical batch size for prompt processing (must be >=32 to use BLAS)
227
- int32_t n_keep = 0; // number of tokens to keep from initial prompt
228
- int32_t n_chunks = -1; // max number of chunks to process (-1 = unlimited)
229
- int32_t n_parallel = 1; // number of parallel sequences to decode
230
- int32_t n_sequences = 1; // number of sequences to decode
231
- int32_t grp_attn_n = 1; // group-attention factor
232
- int32_t grp_attn_w = 512; // group-attention width
233
- int32_t n_print = -1; // print token count every n tokens (-1 = disabled)
234
- float rope_freq_base = 0.0f; // RoPE base frequency
235
- float rope_freq_scale = 0.0f; // RoPE frequency scaling factor
236
- float yarn_ext_factor = -1.0f; // YaRN extrapolation mix factor
237
- float yarn_attn_factor = 1.0f; // YaRN magnitude scaling factor
238
- float yarn_beta_fast = 32.0f; // YaRN low correction dim
239
- float yarn_beta_slow = 1.0f; // YaRN high correction dim
240
- int32_t yarn_orig_ctx = 0; // YaRN original context length
241
- float defrag_thold = 0.1f; // KV cache defragmentation threshold
242
-
243
- // offload params
244
- std::vector<lm_ggml_backend_dev_t> devices; // devices to use for offloading
245
-
246
- int32_t n_gpu_layers = -1; // number of layers to store in VRAM (-1 - use default)
247
- int32_t main_gpu = 0; // the GPU that is used for scratch and small tensors
248
- float tensor_split[128] = {0}; // how split tensors should be distributed across GPUs
249
-
250
- enum llama_split_mode split_mode = LLAMA_SPLIT_MODE_LAYER; // how to split the model across GPUs
251
-
252
- struct cpu_params cpuparams;
253
- struct cpu_params cpuparams_batch;
254
-
255
- lm_ggml_backend_sched_eval_callback cb_eval = nullptr;
256
- void * cb_eval_user_data = nullptr;
257
-
258
- lm_ggml_numa_strategy numa = LM_GGML_NUMA_STRATEGY_DISABLED;
259
-
260
- enum llama_rope_scaling_type rope_scaling_type = LLAMA_ROPE_SCALING_TYPE_UNSPECIFIED;
261
- enum llama_pooling_type pooling_type = LLAMA_POOLING_TYPE_UNSPECIFIED; // pooling type for embeddings
262
- enum llama_attention_type attention_type = LLAMA_ATTENTION_TYPE_UNSPECIFIED; // attention type for embeddings
263
-
264
- struct common_params_sampling sampling;
265
- struct common_params_speculative speculative;
266
- struct common_params_vocoder vocoder;
267
-
268
- struct common_params_model model;
269
-
270
- std::string model_alias = ""; // model alias // NOLINT
271
- std::string hf_token = ""; // HF token // NOLINT
272
- std::string prompt = ""; // NOLINT
273
- std::string system_prompt = ""; // NOLINT
274
- std::string prompt_file = ""; // store the external prompt file name // NOLINT
275
- std::string path_prompt_cache = ""; // path to file for saving/loading prompt eval state // NOLINT
276
- std::string input_prefix = ""; // string to prefix user inputs with // NOLINT
277
- std::string input_suffix = ""; // string to suffix user inputs with // NOLINT
278
- std::string lookup_cache_static = ""; // path of static ngram cache file for lookup decoding // NOLINT
279
- std::string lookup_cache_dynamic = ""; // path of dynamic ngram cache file for lookup decoding // NOLINT
280
- std::string logits_file = ""; // file for saving *all* logits // NOLINT
281
-
282
- std::vector<std::string> in_files; // all input files
283
- std::vector<std::string> antiprompt; // strings upon which more user input is prompted (a.k.a. reverse prompts)
284
- std::vector<llama_model_kv_override> kv_overrides;
285
- std::vector<llama_model_tensor_buft_override> tensor_buft_overrides;
286
-
287
- bool lora_init_without_apply = false; // only load lora to memory, but do not apply it to ctx (user can manually apply lora later using llama_adapter_lora_apply)
288
- std::vector<common_adapter_lora_info> lora_adapters; // lora adapter path with user defined scale
289
-
290
- std::vector<common_control_vector_load_info> control_vectors; // control vector with user defined scale
291
-
292
- int32_t verbosity = 0;
293
- int32_t control_vector_layer_start = -1; // layer range for control vector
294
- int32_t control_vector_layer_end = -1; // layer range for control vector
295
-
296
- int32_t ppl_stride = 0; // stride for perplexity calculations. If left at 0, the pre-existing approach will be used.
297
- int32_t ppl_output_type = 0; // = 0 -> ppl output is as usual, = 1 -> ppl output is num_tokens, ppl, one per line
298
- // (which is more convenient to use for plotting)
299
- //
300
- bool hellaswag = false; // compute HellaSwag score over random tasks from datafile supplied in prompt
301
- size_t hellaswag_tasks = 400; // number of tasks to use when computing the HellaSwag score
302
-
303
- bool winogrande = false; // compute Winogrande score over random tasks from datafile supplied in prompt
304
- size_t winogrande_tasks = 0; // number of tasks to use when computing the Winogrande score. If 0, all tasks will be computed
305
-
306
- bool multiple_choice = false; // compute TruthfulQA score over random tasks from datafile supplied in prompt
307
- size_t multiple_choice_tasks = 0; // number of tasks to use when computing the TruthfulQA score. If 0, all tasks will be computed
308
-
309
- bool kl_divergence = false; // compute KL divergence
310
-
311
- bool usage = false; // print usage
312
- bool completion = false; // print source-able completion script
313
- bool use_color = false; // use color to distinguish generations and inputs
314
- bool special = false; // enable special token output
315
- bool interactive = false; // interactive mode
316
- bool interactive_first = false; // wait for user input immediately
317
- bool prompt_cache_all = false; // save user input and generations to prompt cache
318
- bool prompt_cache_ro = false; // open the prompt cache read-only and do not update it
319
-
320
- bool escape = true; // escape "\n", "\r", "\t", "\'", "\"", and "\\"
321
- bool multiline_input = false; // reverse the usage of `\`
322
- bool simple_io = false; // improves compatibility with subprocesses and limited consoles
323
- bool cont_batching = true; // insert new sequences for decoding on-the-fly
324
- bool flash_attn = false; // flash attention
325
- bool no_perf = false; // disable performance metrics
326
- bool ctx_shift = true; // context shift on inifinite text generation
327
- bool swa_full = false; // use full-size SWA cache (https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055)
328
-
329
- bool input_prefix_bos = false; // prefix BOS to user inputs, preceding input_prefix
330
- bool use_mmap = true; // use mmap for faster loads
331
- bool use_mlock = false; // use mlock to keep model in memory
332
- bool verbose_prompt = false; // print prompt tokens before generation
333
- bool display_prompt = true; // print prompt before generation
334
- bool no_kv_offload = false; // disable KV offloading
335
- bool warmup = true; // warmup run
336
- bool check_tensors = false; // validate tensor data
337
- bool no_op_offload = false; // globally disable offload host tensor operations to device
338
-
339
- bool single_turn = false; // single turn chat conversation
340
-
341
- llama_progress_callback progress_callback = nullptr;
342
- void * progress_callback_user_data = nullptr;
343
-
344
- lm_ggml_type cache_type_k = LM_GGML_TYPE_F16; // KV cache data type for the K
345
- lm_ggml_type cache_type_v = LM_GGML_TYPE_F16; // KV cache data type for the V
346
-
347
- common_conversation_mode conversation_mode = COMMON_CONVERSATION_MODE_AUTO;
348
-
349
- // multimodal models (see tools/mtmd)
350
- struct common_params_model mmproj;
351
- bool mmproj_use_gpu = true; // use GPU for multimodal model
352
- bool no_mmproj = false; // explicitly disable multimodal model
353
- std::vector<std::string> image; // path to image file(s)
354
-
355
- // embedding
356
- bool embedding = false; // get only sentence embedding
357
- int32_t embd_normalize = 2; // normalisation for embeddings (-1=none, 0=max absolute int16, 1=taxicab, 2=euclidean, >2=p-norm)
358
- std::string embd_out = ""; // empty = default, "array" = [[],[]...], "json" = openai style, "json+" = same "json" + cosine similarity matrix
359
- std::string embd_sep = "\n"; // separator of embeddings
360
- bool reranking = false; // enable reranking support on server
361
-
362
- // server params
363
- int32_t port = 8080; // server listens on this network port
364
- int32_t timeout_read = 600; // http read timeout in seconds
365
- int32_t timeout_write = timeout_read; // http write timeout in seconds
366
- int32_t n_threads_http = -1; // number of threads to process HTTP requests (TODO: support threadpool)
367
- int32_t n_cache_reuse = 0; // min chunk size to reuse from the cache via KV shifting
368
-
369
- std::string hostname = "127.0.0.1";
370
- std::string public_path = ""; // NOLINT
371
- std::string chat_template = ""; // NOLINT
372
- bool use_jinja = false; // NOLINT
373
- bool enable_chat_template = true;
374
- common_reasoning_format reasoning_format = COMMON_REASONING_FORMAT_DEEPSEEK;
375
- bool prefill_assistant = true; // if true, any trailing assistant message will be prefilled into the response
376
-
377
- std::vector<std::string> api_keys;
378
-
379
- std::string ssl_file_key = ""; // NOLINT
380
- std::string ssl_file_cert = ""; // NOLINT
381
-
382
- // "advanced" endpoints are disabled by default for better security
383
- bool webui = true;
384
- bool endpoint_slots = false;
385
- bool endpoint_props = false; // only control POST requests, not GET
386
- bool endpoint_metrics = false;
387
-
388
- bool log_json = false;
389
-
390
- std::string slot_save_path;
391
-
392
- float slot_prompt_similarity = 0.5f;
393
-
394
- // batched-bench params
395
- bool is_pp_shared = false;
396
-
397
- std::vector<int32_t> n_pp;
398
- std::vector<int32_t> n_tg;
399
- std::vector<int32_t> n_pl;
400
-
401
- // retrieval params
402
- std::vector<std::string> context_files; // context files to embed
403
-
404
- int32_t chunk_size = 64; // chunk size for context embedding
405
-
406
- std::string chunk_separator = "\n"; // chunk separator for context embedding
407
-
408
- // passkey params
409
- int32_t n_junk = 250; // number of times to repeat the junk text
410
- int32_t i_pos = -1; // position of the passkey in the junk text
411
-
412
- // imatrix params
413
- int32_t n_out_freq = 10; // output the imatrix every n_out_freq iterations
414
- int32_t n_save_freq = 0; // save the imatrix every n_save_freq iterations
415
- int32_t i_chunk = 0; // start processing from this chunk
416
-
417
- bool process_output = false; // collect data for the output tensor
418
- bool compute_ppl = true; // whether to compute perplexity
419
- bool parse_special = false; // whether to parse special tokens during imatrix tokenization
420
-
421
- // cvector-generator params
422
- int n_pca_batch = 100;
423
- int n_pca_iterations = 1000;
424
- dimre_method cvector_dimre_method = DIMRE_METHOD_PCA;
425
- std::string cvector_positive_file = "tools/cvector-generator/positive.txt";
426
- std::string cvector_negative_file = "tools/cvector-generator/negative.txt";
427
-
428
- bool spm_infill = false; // suffix/prefix/middle pattern for infill
429
-
430
- // batched-bench params
431
- bool batched_bench_output_jsonl = false;
432
-
433
- // common params
434
- std::string out_file; // output filename for all example programs
435
- // optional callback for model loading progress and cancellation:
436
- // called with a progress value between 0.0 and 1.0.
437
- // return false from callback to abort model loading or true to continue
438
- llama_progress_callback load_progress_callback = NULL;
439
- void * load_progress_callback_user_data = NULL;
440
- };
441
-
442
- // call once at the start of a program if it uses libcommon
443
- // initializes the logging system and prints info about the build
444
- void common_init();
445
-
446
- std::string common_params_get_system_info(const common_params & params);
447
-
448
- bool parse_cpu_range(const std::string & range, bool(&boolmask)[LM_GGML_MAX_N_THREADS]);
449
- bool parse_cpu_mask(const std::string & mask, bool(&boolmask)[LM_GGML_MAX_N_THREADS]);
450
- void postprocess_cpu_params(cpu_params & cpuparams, const cpu_params * role_model = nullptr);
451
- bool set_process_priority(enum lm_ggml_sched_priority prio);
452
-
453
- //
454
- // String utils
455
- //
456
-
457
- #ifdef __GNUC__
458
- # if defined(__MINGW32__) && !defined(__clang__)
459
- # define LLAMA_COMMON_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
460
- # else
461
- # define LLAMA_COMMON_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))
462
- # endif
463
- #else
464
- # define LLAMA_COMMON_ATTRIBUTE_FORMAT(...)
465
- #endif
466
-
467
- LLAMA_COMMON_ATTRIBUTE_FORMAT(1, 2)
468
- std::string string_format(const char * fmt, ...);
469
-
470
- std::string string_strip(const std::string & str);
471
- std::string string_get_sortable_timestamp();
472
-
473
- std::string string_join(const std::vector<std::string> & values, const std::string & separator);
474
- std::vector<std::string> string_split(const std::string & str, const std::string & delimiter);
475
- std::string string_repeat(const std::string & str, size_t n);
476
-
477
- void string_replace_all(std::string & s, const std::string & search, const std::string & replace);
478
-
479
- std::string regex_escape(const std::string & s);
480
-
481
- template<class T>
482
- static std::vector<T> string_split(const std::string & str, char delim) {
483
- static_assert(!std::is_same<T, std::string>::value, "Please use the specialized version for std::string");
484
- std::vector<T> values;
485
- std::istringstream str_stream(str);
486
- std::string token;
487
- while (std::getline(str_stream, token, delim)) {
488
- T value;
489
- std::istringstream token_stream(token);
490
- token_stream >> value;
491
- values.push_back(value);
492
- }
493
- return values;
494
- }
495
-
496
- template<>
497
- std::vector<std::string> string_split<std::string>(const std::string & input, char separator)
498
- {
499
- std::vector<std::string> parts;
500
- size_t begin_pos = 0;
501
- size_t separator_pos = input.find(separator);
502
- while (separator_pos != std::string::npos) {
503
- std::string part = input.substr(begin_pos, separator_pos - begin_pos);
504
- parts.emplace_back(part);
505
- begin_pos = separator_pos + 1;
506
- separator_pos = input.find(separator, begin_pos);
507
- }
508
- parts.emplace_back(input.substr(begin_pos, separator_pos - begin_pos));
509
- return parts;
510
- }
511
-
512
- static bool string_starts_with(const std::string & str,
513
- const std::string & prefix) { // While we wait for C++20's std::string::starts_with...
514
- return str.rfind(prefix, 0) == 0;
515
- }
516
-
517
- // While we wait for C++20's std::string::ends_with...
518
- bool string_ends_with(const std::string_view & str, const std::string_view & suffix);
519
- size_t string_find_partial_stop(const std::string_view & str, const std::string_view & stop);
520
-
521
- bool string_parse_kv_override(const char * data, std::vector<llama_model_kv_override> & overrides);
522
- void string_process_escapes(std::string & input);
523
-
524
- std::string string_from(bool value);
525
- std::string string_from(const std::vector<int> & values);
526
- std::string string_from(const struct llama_context * ctx, const std::vector<llama_token> & tokens);
527
- std::string string_from(const struct llama_context * ctx, const struct llama_batch & batch);
528
-
529
- //
530
- // Filesystem utils
531
- //
532
-
533
- bool fs_validate_filename(const std::string & filename);
534
- bool fs_create_directory_with_parents(const std::string & path);
535
-
536
- std::string fs_get_cache_directory();
537
- std::string fs_get_cache_file(const std::string & filename);
538
-
539
- //
540
- // Model utils
541
- //
542
-
543
- // note: defines object's lifetime
544
- struct common_init_result {
545
- llama_model_ptr model;
546
- llama_context_ptr context;
547
-
548
- std::vector<llama_adapter_lora_ptr> lora;
549
- };
550
-
551
- struct common_init_result common_init_from_params(common_params & params);
552
-
553
- struct llama_model_params common_model_params_to_llama ( common_params & params);
554
- struct llama_context_params common_context_params_to_llama(const common_params & params);
555
- struct lm_ggml_threadpool_params lm_ggml_threadpool_params_from_cpu_params(const cpu_params & params);
556
-
557
- // clear LoRA adapters from context, then apply new list of adapters
558
- void common_set_adapter_lora(struct llama_context * ctx, std::vector<common_adapter_lora_info> & lora);
559
-
560
- std::string get_model_endpoint();
561
-
562
- //
563
- // Batch utils
564
- //
565
-
566
- void common_batch_clear(struct llama_batch & batch);
567
-
568
- void common_batch_add(
569
- struct llama_batch & batch,
570
- llama_token id,
571
- llama_pos pos,
572
- const std::vector<llama_seq_id> & seq_ids,
573
- bool logits);
574
-
575
- //
576
- // Token utils
577
- //
578
-
579
- // longest common prefix
580
- size_t common_lcp(const llama_tokens & a, const llama_tokens & b);
581
-
582
- // longet common subsequence
583
- size_t common_lcs(const llama_tokens & a, const llama_tokens & b);
584
-
585
- //
586
- // Vocab utils
587
- //
588
-
589
- // tokenizes a string into a vector of tokens
590
- // should work similar to Python's `tokenizer.encode`
591
- std::vector<llama_token> common_tokenize(
592
- const struct llama_context * ctx,
593
- const std::string & text,
594
- bool add_special,
595
- bool parse_special = false);
596
-
597
- std::vector<llama_token> common_tokenize(
598
- const struct llama_vocab * vocab,
599
- const std::string & text,
600
- bool add_special,
601
- bool parse_special = false);
602
-
603
- // tokenizes a token into a piece, optionally renders special/control tokens
604
- // should work similar to Python's `tokenizer.id_to_piece`
605
- std::string common_token_to_piece(
606
- const struct llama_context * ctx,
607
- llama_token token,
608
- bool special = true);
609
-
610
- std::string common_token_to_piece(
611
- const struct llama_vocab * vocab,
612
- llama_token token,
613
- bool special = true);
614
-
615
- // detokenizes a vector of tokens into a string
616
- // should work similar to Python's `tokenizer.decode`
617
- // optionally renders special/control tokens
618
- std::string common_detokenize(
619
- const struct llama_context * ctx,
620
- const std::vector<llama_token> & tokens,
621
- bool special = true);
622
-
623
- std::string common_detokenize(
624
- const struct llama_vocab * vocab,
625
- const std::vector<llama_token> & tokens,
626
- bool special = true);
627
-
628
- //
629
- // Embedding utils
630
- //
631
-
632
- // TODO: repace embd_norm with an enum
633
- void common_embd_normalize(const float * inp, float * out, int n, int embd_norm);
634
-
635
- float common_embd_similarity_cos(const float * embd1, const float * embd2, int n);
636
-
637
- //
638
- // Control vector utils
639
- //
640
-
641
- struct common_control_vector_data {
642
- int n_embd;
643
-
644
- // stores data for layers [1, n_layer] where n_layer = data.size() / n_embd
645
- std::vector<float> data;
646
- };
647
-
648
- struct common_control_vector_load_info {
649
- float strength;
650
-
651
- std::string fname;
652
- };
653
-
654
- // Load control vectors, scale each by strength, and add them together.
655
- // On error, returns {-1, empty}
656
- common_control_vector_data common_control_vector_load(const std::vector<common_control_vector_load_info> & load_infos);
657
-
658
- //
659
- // Split utils
660
- //
661
-
662
- namespace {
663
-
664
- const char * const LLM_KV_SPLIT_NO = "split.no";
665
- const char * const LLM_KV_SPLIT_COUNT = "split.count";
666
- const char * const LLM_KV_SPLIT_TENSORS_COUNT = "split.tensors.count";
667
-
668
- }
669
-
670
- //
671
- // training utils
672
- //
673
-
674
- lm_ggml_opt_dataset_t common_opt_dataset_init(struct llama_context * ctx, const std::vector<llama_token> & tokens, int64_t stride);