react-native-executorch 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/README.md +30 -13
  2. package/android/build.gradle +1 -1
  3. package/android/libs/executorch.aar +0 -0
  4. package/android/src/main/java/com/swmansion/rnexecutorch/ETModule.kt +1 -2
  5. package/android/src/main/java/com/swmansion/rnexecutorch/ImageSegmentation.kt +58 -0
  6. package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +13 -49
  7. package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +37 -0
  8. package/android/src/main/java/com/swmansion/rnexecutorch/StyleTransfer.kt +1 -1
  9. package/android/src/main/java/com/swmansion/rnexecutorch/TextEmbeddings.kt +51 -0
  10. package/android/src/main/java/com/swmansion/rnexecutorch/Tokenizer.kt +86 -0
  11. package/android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt +3 -4
  12. package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsModel.kt +48 -0
  13. package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsUtils.kt +37 -0
  14. package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/ClassificationModel.kt +1 -0
  15. package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/Constants.kt +26 -0
  16. package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/ImageSegmentationModel.kt +142 -0
  17. package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/RecognizerUtils.kt +3 -0
  18. package/android/src/main/java/com/swmansion/rnexecutorch/models/{StyleTransferModel.kt → styleTransfer/StyleTransferModel.kt} +2 -1
  19. package/android/src/main/java/com/swmansion/rnexecutorch/utils/ArrayUtils.kt +0 -8
  20. package/android/src/main/java/com/swmansion/rnexecutorch/{models/classification/Utils.kt → utils/Numerical.kt} +1 -1
  21. package/ios/ExecutorchLib.xcframework/Info.plist +4 -4
  22. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
  23. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +14 -0
  24. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/LLaMARunner.h +1 -23
  25. package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
  26. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
  27. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +14 -0
  28. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/LLaMARunner.h +1 -23
  29. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
  30. package/ios/RnExecutorch/Classification.mm +15 -18
  31. package/ios/RnExecutorch/ETModule.mm +6 -5
  32. package/ios/RnExecutorch/ImageSegmentation.h +5 -0
  33. package/ios/RnExecutorch/ImageSegmentation.mm +60 -0
  34. package/ios/RnExecutorch/LLM.mm +12 -53
  35. package/ios/RnExecutorch/OCR.mm +39 -43
  36. package/ios/RnExecutorch/ObjectDetection.mm +20 -20
  37. package/ios/RnExecutorch/SpeechToText.mm +6 -7
  38. package/ios/RnExecutorch/StyleTransfer.mm +16 -19
  39. package/ios/RnExecutorch/TextEmbeddings.h +5 -0
  40. package/ios/RnExecutorch/TextEmbeddings.mm +62 -0
  41. package/ios/RnExecutorch/Tokenizer.h +5 -0
  42. package/ios/RnExecutorch/Tokenizer.mm +83 -0
  43. package/ios/RnExecutorch/VerticalOCR.mm +36 -36
  44. package/ios/RnExecutorch/models/BaseModel.h +2 -5
  45. package/ios/RnExecutorch/models/BaseModel.mm +5 -15
  46. package/ios/RnExecutorch/models/classification/ClassificationModel.mm +2 -3
  47. package/ios/RnExecutorch/models/classification/Constants.mm +0 -1
  48. package/ios/RnExecutorch/models/image_segmentation/Constants.h +4 -0
  49. package/ios/RnExecutorch/models/image_segmentation/Constants.mm +8 -0
  50. package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.h +10 -0
  51. package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.mm +146 -0
  52. package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.mm +1 -2
  53. package/ios/RnExecutorch/models/ocr/Detector.h +0 -2
  54. package/ios/RnExecutorch/models/ocr/Detector.mm +2 -1
  55. package/ios/RnExecutorch/models/ocr/RecognitionHandler.h +5 -4
  56. package/ios/RnExecutorch/models/ocr/RecognitionHandler.mm +9 -26
  57. package/ios/RnExecutorch/models/ocr/Recognizer.mm +1 -2
  58. package/ios/RnExecutorch/models/ocr/VerticalDetector.h +0 -2
  59. package/ios/RnExecutorch/models/ocr/VerticalDetector.mm +2 -1
  60. package/ios/RnExecutorch/models/ocr/utils/OCRUtils.mm +0 -1
  61. package/ios/RnExecutorch/models/stt/Moonshine.mm +1 -6
  62. package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.mm +7 -11
  63. package/ios/RnExecutorch/models/stt/Whisper.mm +0 -5
  64. package/ios/RnExecutorch/models/{StyleTransferModel.h → style_transfer/StyleTransferModel.h} +1 -1
  65. package/ios/RnExecutorch/models/{StyleTransferModel.mm → style_transfer/StyleTransferModel.mm} +2 -3
  66. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.h +15 -0
  67. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.mm +45 -0
  68. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.h +8 -0
  69. package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.mm +49 -0
  70. package/ios/RnExecutorch/utils/Conversions.h +15 -0
  71. package/ios/RnExecutorch/utils/ImageProcessor.h +0 -1
  72. package/ios/RnExecutorch/{models/classification/Utils.h → utils/Numerical.h} +0 -2
  73. package/ios/RnExecutorch/{models/classification/Utils.mm → utils/Numerical.mm} +0 -2
  74. package/ios/RnExecutorch/utils/ObjectDetectionUtils.mm +0 -2
  75. package/ios/RnExecutorch/utils/SFFT.mm +1 -1
  76. package/ios/RnExecutorch/utils/ScalarType.h +0 -2
  77. package/lib/module/Error.js +16 -2
  78. package/lib/module/Error.js.map +1 -1
  79. package/lib/module/constants/{llamaDefaults.js → llmDefaults.js} +7 -3
  80. package/lib/module/constants/llmDefaults.js.map +1 -0
  81. package/lib/module/constants/modelUrls.js +88 -27
  82. package/lib/module/constants/modelUrls.js.map +1 -1
  83. package/lib/module/constants/ocr/models.js +290 -0
  84. package/lib/module/constants/ocr/models.js.map +1 -0
  85. package/lib/module/constants/ocr/symbols.js +137 -2
  86. package/lib/module/constants/ocr/symbols.js.map +1 -1
  87. package/lib/module/constants/sttDefaults.js +50 -25
  88. package/lib/module/constants/sttDefaults.js.map +1 -1
  89. package/lib/module/controllers/LLMController.js +205 -0
  90. package/lib/module/controllers/LLMController.js.map +1 -0
  91. package/lib/module/controllers/OCRController.js +5 -10
  92. package/lib/module/controllers/OCRController.js.map +1 -1
  93. package/lib/module/controllers/SpeechToTextController.js +225 -122
  94. package/lib/module/controllers/SpeechToTextController.js.map +1 -1
  95. package/lib/module/controllers/VerticalOCRController.js +6 -10
  96. package/lib/module/controllers/VerticalOCRController.js.map +1 -1
  97. package/lib/module/hooks/computer_vision/useClassification.js +8 -23
  98. package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
  99. package/lib/module/hooks/computer_vision/useImageSegmentation.js +13 -0
  100. package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -0
  101. package/lib/module/hooks/computer_vision/useOCR.js +11 -6
  102. package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
  103. package/lib/module/hooks/computer_vision/useObjectDetection.js +8 -23
  104. package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
  105. package/lib/module/hooks/computer_vision/useStyleTransfer.js +8 -23
  106. package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
  107. package/lib/module/hooks/computer_vision/useVerticalOCR.js +10 -7
  108. package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
  109. package/lib/module/hooks/general/useExecutorchModule.js +8 -36
  110. package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
  111. package/lib/module/hooks/natural_language_processing/useLLM.js +54 -63
  112. package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
  113. package/lib/module/hooks/natural_language_processing/useSpeechToText.js +15 -11
  114. package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
  115. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +14 -0
  116. package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -0
  117. package/lib/module/hooks/natural_language_processing/useTokenizer.js +54 -0
  118. package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -0
  119. package/lib/module/hooks/useModule.js +18 -62
  120. package/lib/module/hooks/useModule.js.map +1 -1
  121. package/lib/module/index.js +16 -2
  122. package/lib/module/index.js.map +1 -1
  123. package/lib/module/modules/BaseModule.js +9 -10
  124. package/lib/module/modules/BaseModule.js.map +1 -1
  125. package/lib/module/modules/computer_vision/ClassificationModule.js +8 -5
  126. package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
  127. package/lib/module/modules/computer_vision/ImageSegmentationModule.js +28 -0
  128. package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -0
  129. package/lib/module/modules/computer_vision/ObjectDetectionModule.js +8 -5
  130. package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
  131. package/lib/module/modules/computer_vision/StyleTransferModule.js +8 -5
  132. package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
  133. package/lib/module/modules/general/ExecutorchModule.js +8 -5
  134. package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
  135. package/lib/module/modules/natural_language_processing/LLMModule.js +46 -27
  136. package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
  137. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +8 -5
  138. package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
  139. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +14 -0
  140. package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -0
  141. package/lib/module/modules/natural_language_processing/TokenizerModule.js +26 -0
  142. package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -0
  143. package/lib/module/native/NativeClassification.js.map +1 -1
  144. package/lib/module/native/NativeImageSegmentation.js +5 -0
  145. package/lib/module/native/NativeImageSegmentation.js.map +1 -0
  146. package/lib/module/native/NativeLLM.js.map +1 -1
  147. package/lib/module/native/NativeTextEmbeddings.js +5 -0
  148. package/lib/module/native/NativeTextEmbeddings.js.map +1 -0
  149. package/lib/module/native/NativeTokenizer.js +5 -0
  150. package/lib/module/native/NativeTokenizer.js.map +1 -0
  151. package/lib/module/native/RnExecutorchModules.js +18 -113
  152. package/lib/module/native/RnExecutorchModules.js.map +1 -1
  153. package/lib/module/types/common.js.map +1 -1
  154. package/lib/module/types/imageSegmentation.js +29 -0
  155. package/lib/module/types/imageSegmentation.js.map +1 -0
  156. package/lib/module/types/llm.js +7 -0
  157. package/lib/module/types/llm.js.map +1 -0
  158. package/lib/module/types/{object_detection.js → objectDetection.js} +1 -1
  159. package/lib/module/types/objectDetection.js.map +1 -0
  160. package/lib/module/types/ocr.js +2 -0
  161. package/lib/module/types/stt.js +82 -0
  162. package/lib/module/types/stt.js.map +1 -0
  163. package/lib/module/utils/ResourceFetcher.js +156 -0
  164. package/lib/module/utils/ResourceFetcher.js.map +1 -0
  165. package/lib/module/utils/llm.js +25 -0
  166. package/lib/module/utils/llm.js.map +1 -0
  167. package/lib/module/utils/stt.js +22 -0
  168. package/lib/module/utils/stt.js.map +1 -0
  169. package/lib/typescript/Error.d.ts +4 -1
  170. package/lib/typescript/Error.d.ts.map +1 -1
  171. package/lib/typescript/constants/{llamaDefaults.d.ts → llmDefaults.d.ts} +5 -5
  172. package/lib/typescript/constants/llmDefaults.d.ts.map +1 -0
  173. package/lib/typescript/constants/modelUrls.d.ts +74 -28
  174. package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
  175. package/lib/typescript/constants/ocr/models.d.ts +285 -0
  176. package/lib/typescript/constants/ocr/models.d.ts.map +1 -0
  177. package/lib/typescript/constants/ocr/symbols.d.ts +73 -1
  178. package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
  179. package/lib/typescript/constants/sttDefaults.d.ts +8 -13
  180. package/lib/typescript/constants/sttDefaults.d.ts.map +1 -1
  181. package/lib/typescript/controllers/LLMController.d.ts +46 -0
  182. package/lib/typescript/controllers/LLMController.d.ts.map +1 -0
  183. package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
  184. package/lib/typescript/controllers/SpeechToTextController.d.ts +30 -16
  185. package/lib/typescript/controllers/SpeechToTextController.d.ts.map +1 -1
  186. package/lib/typescript/controllers/VerticalOCRController.d.ts +1 -1
  187. package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
  188. package/lib/typescript/hooks/computer_vision/useClassification.d.ts +5 -5
  189. package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
  190. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +37 -0
  191. package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -0
  192. package/lib/typescript/hooks/computer_vision/useOCR.d.ts +2 -1
  193. package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
  194. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +5 -4
  195. package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
  196. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +4 -2
  197. package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
  198. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +2 -1
  199. package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
  200. package/lib/typescript/hooks/general/useExecutorchModule.d.ts +5 -6
  201. package/lib/typescript/hooks/general/useExecutorchModule.d.ts.map +1 -1
  202. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +6 -6
  203. package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
  204. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +7 -3
  205. package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
  206. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +13 -0
  207. package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -0
  208. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +16 -0
  209. package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -0
  210. package/lib/typescript/hooks/useModule.d.ts +11 -10
  211. package/lib/typescript/hooks/useModule.d.ts.map +1 -1
  212. package/lib/typescript/index.d.ts +15 -2
  213. package/lib/typescript/index.d.ts.map +1 -1
  214. package/lib/typescript/modules/BaseModule.d.ts +4 -5
  215. package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
  216. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +7 -7
  217. package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
  218. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +32 -0
  219. package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -0
  220. package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
  221. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +6 -5
  222. package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
  223. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +6 -5
  224. package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
  225. package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
  226. package/lib/typescript/modules/general/ExecutorchModule.d.ts +4 -3
  227. package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
  228. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +19 -5
  229. package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
  230. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +7 -4
  231. package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
  232. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +8 -0
  233. package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -0
  234. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +12 -0
  235. package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -0
  236. package/lib/typescript/native/NativeClassification.d.ts.map +1 -1
  237. package/lib/typescript/native/NativeImageSegmentation.d.ts +10 -0
  238. package/lib/typescript/native/NativeImageSegmentation.d.ts.map +1 -0
  239. package/lib/typescript/native/NativeLLM.d.ts +3 -4
  240. package/lib/typescript/native/NativeLLM.d.ts.map +1 -1
  241. package/lib/typescript/native/NativeObjectDetection.d.ts +1 -1
  242. package/lib/typescript/native/NativeObjectDetection.d.ts.map +1 -1
  243. package/lib/typescript/native/NativeSpeechToText.d.ts +2 -2
  244. package/lib/typescript/native/NativeSpeechToText.d.ts.map +1 -1
  245. package/lib/typescript/native/NativeTextEmbeddings.d.ts +8 -0
  246. package/lib/typescript/native/NativeTextEmbeddings.d.ts.map +1 -0
  247. package/lib/typescript/native/NativeTokenizer.d.ts +12 -0
  248. package/lib/typescript/native/NativeTokenizer.d.ts.map +1 -0
  249. package/lib/typescript/native/RnExecutorchModules.d.ts +18 -41
  250. package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
  251. package/lib/typescript/types/common.d.ts +1 -26
  252. package/lib/typescript/types/common.d.ts.map +1 -1
  253. package/lib/typescript/types/imageSegmentation.d.ts +25 -0
  254. package/lib/typescript/types/imageSegmentation.d.ts.map +1 -0
  255. package/lib/typescript/types/llm.d.ts +38 -0
  256. package/lib/typescript/types/llm.d.ts.map +1 -0
  257. package/lib/typescript/types/{object_detection.d.ts → objectDetection.d.ts} +1 -1
  258. package/lib/typescript/types/objectDetection.d.ts.map +1 -0
  259. package/lib/typescript/types/ocr.d.ts +2 -1
  260. package/lib/typescript/types/ocr.d.ts.map +1 -1
  261. package/lib/typescript/types/stt.d.ts +91 -0
  262. package/lib/typescript/types/stt.d.ts.map +1 -0
  263. package/lib/typescript/utils/ResourceFetcher.d.ts +17 -0
  264. package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -0
  265. package/lib/typescript/utils/llm.d.ts +3 -0
  266. package/lib/typescript/utils/llm.d.ts.map +1 -0
  267. package/lib/typescript/utils/stt.d.ts +2 -0
  268. package/lib/typescript/utils/stt.d.ts.map +1 -0
  269. package/package.json +12 -48
  270. package/react-native-executorch.podspec +1 -1
  271. package/src/Error.ts +16 -3
  272. package/src/constants/llmDefaults.ts +14 -0
  273. package/src/constants/modelUrls.ts +146 -39
  274. package/src/constants/ocr/models.ts +453 -0
  275. package/src/constants/ocr/symbols.ts +147 -3
  276. package/src/constants/sttDefaults.ts +55 -37
  277. package/src/controllers/LLMController.ts +286 -0
  278. package/src/controllers/OCRController.ts +14 -28
  279. package/src/controllers/SpeechToTextController.ts +318 -180
  280. package/src/controllers/VerticalOCRController.ts +17 -32
  281. package/src/hooks/computer_vision/useClassification.ts +11 -26
  282. package/src/hooks/computer_vision/useImageSegmentation.ts +18 -0
  283. package/src/hooks/computer_vision/useOCR.ts +17 -5
  284. package/src/hooks/computer_vision/useObjectDetection.ts +10 -24
  285. package/src/hooks/computer_vision/useStyleTransfer.ts +9 -25
  286. package/src/hooks/computer_vision/useVerticalOCR.ts +11 -4
  287. package/src/hooks/general/useExecutorchModule.ts +10 -50
  288. package/src/hooks/natural_language_processing/useLLM.ts +80 -97
  289. package/src/hooks/natural_language_processing/useSpeechToText.ts +39 -12
  290. package/src/hooks/natural_language_processing/useTextEmbeddings.ts +18 -0
  291. package/src/hooks/natural_language_processing/useTokenizer.ts +61 -0
  292. package/src/hooks/useModule.ts +32 -92
  293. package/src/index.tsx +16 -2
  294. package/src/modules/BaseModule.ts +16 -26
  295. package/src/modules/computer_vision/ClassificationModule.ts +13 -8
  296. package/src/modules/computer_vision/ImageSegmentationModule.ts +39 -0
  297. package/src/modules/computer_vision/ObjectDetectionModule.ts +13 -8
  298. package/src/modules/computer_vision/StyleTransferModule.ts +13 -8
  299. package/src/modules/general/ExecutorchModule.ts +11 -6
  300. package/src/modules/natural_language_processing/LLMModule.ts +64 -51
  301. package/src/modules/natural_language_processing/SpeechToTextModule.ts +25 -10
  302. package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +18 -0
  303. package/src/modules/natural_language_processing/TokenizerModule.ts +34 -0
  304. package/src/native/NativeClassification.ts +0 -1
  305. package/src/native/NativeImageSegmentation.ts +14 -0
  306. package/src/native/NativeLLM.ts +3 -10
  307. package/src/native/NativeObjectDetection.ts +1 -1
  308. package/src/native/NativeSpeechToText.ts +2 -2
  309. package/src/native/NativeTextEmbeddings.ts +9 -0
  310. package/src/native/NativeTokenizer.ts +13 -0
  311. package/src/native/RnExecutorchModules.ts +54 -234
  312. package/src/types/common.ts +1 -44
  313. package/src/types/imageSegmentation.ts +25 -0
  314. package/src/types/llm.ts +57 -0
  315. package/src/types/ocr.ts +3 -1
  316. package/src/types/stt.ts +93 -0
  317. package/src/utils/ResourceFetcher.ts +196 -0
  318. package/src/utils/llm.ts +34 -0
  319. package/src/utils/stt.ts +28 -0
  320. package/android/src/main/java/com/swmansion/rnexecutorch/utils/llms/ConversationManager.kt +0 -68
  321. package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/_CodeSignature/CodeResources +0 -124
  322. package/ios/RnExecutorch/utils/llms/Constants.h +0 -6
  323. package/ios/RnExecutorch/utils/llms/Constants.mm +0 -23
  324. package/ios/RnExecutorch/utils/llms/ConversationManager.h +0 -26
  325. package/ios/RnExecutorch/utils/llms/ConversationManager.mm +0 -71
  326. package/lib/module/constants/llamaDefaults.js.map +0 -1
  327. package/lib/module/modules/computer_vision/BaseCVModule.js +0 -14
  328. package/lib/module/modules/computer_vision/BaseCVModule.js.map +0 -1
  329. package/lib/module/types/object_detection.js.map +0 -1
  330. package/lib/module/utils/fetchResource.js +0 -93
  331. package/lib/module/utils/fetchResource.js.map +0 -1
  332. package/lib/module/utils/listDownloadedResources.js +0 -13
  333. package/lib/module/utils/listDownloadedResources.js.map +0 -1
  334. package/lib/typescript/constants/llamaDefaults.d.ts.map +0 -1
  335. package/lib/typescript/modules/computer_vision/BaseCVModule.d.ts +0 -9
  336. package/lib/typescript/modules/computer_vision/BaseCVModule.d.ts.map +0 -1
  337. package/lib/typescript/types/object_detection.d.ts.map +0 -1
  338. package/lib/typescript/utils/fetchResource.d.ts +0 -3
  339. package/lib/typescript/utils/fetchResource.d.ts.map +0 -1
  340. package/lib/typescript/utils/listDownloadedResources.d.ts +0 -3
  341. package/lib/typescript/utils/listDownloadedResources.d.ts.map +0 -1
  342. package/src/constants/llamaDefaults.ts +0 -9
  343. package/src/modules/computer_vision/BaseCVModule.ts +0 -22
  344. package/src/utils/fetchResource.ts +0 -106
  345. package/src/utils/listDownloadedResources.ts +0 -12
  346. /package/src/types/{object_detection.ts → objectDetection.ts} +0 -0
@@ -1,62 +1,75 @@
1
- import { LLM } from '../../native/RnExecutorchModules';
2
- import { fetchResource } from '../../utils/fetchResource';
3
- import {
4
- DEFAULT_CONTEXT_WINDOW_LENGTH,
5
- DEFAULT_MESSAGE_HISTORY,
6
- DEFAULT_SYSTEM_PROMPT,
7
- } from '../../constants/llamaDefaults';
1
+ import { LLMController } from '../../controllers/LLMController';
8
2
  import { ResourceSource } from '../../types/common';
3
+ import { ChatConfig, LLMTool, Message, ToolsConfig } from '../../types/llm';
9
4
 
10
5
  export class LLMModule {
11
- static onDownloadProgressCallback = (_downloadProgress: number) => {};
12
-
13
- static async load(
14
- modelSource: ResourceSource,
15
- tokenizerSource: ResourceSource,
16
- systemPrompt = DEFAULT_SYSTEM_PROMPT,
17
- messageHistory = DEFAULT_MESSAGE_HISTORY,
18
- contextWindowLength = DEFAULT_CONTEXT_WINDOW_LENGTH
19
- ) {
20
- try {
21
- const tokenizerFileUri = await fetchResource(tokenizerSource);
22
- const modelFileUri = await fetchResource(
23
- modelSource,
24
- this.onDownloadProgressCallback
25
- );
26
-
27
- await LLM.loadLLM(
28
- modelFileUri,
29
- tokenizerFileUri,
30
- systemPrompt,
31
- messageHistory,
32
- contextWindowLength
33
- );
34
- } catch (err) {
35
- throw new Error((err as Error).message);
36
- }
37
- }
38
-
39
- static async generate(input: string) {
40
- try {
41
- await LLM.runInference(input);
42
- } catch (err) {
43
- throw new Error((err as Error).message);
44
- }
45
- }
46
-
47
- static onDownloadProgress(callback: (downloadProgress: number) => void) {
48
- this.onDownloadProgressCallback = callback;
49
- }
50
-
51
- static onToken(callback: (data: string | undefined) => void) {
52
- return LLM.onToken(callback);
6
+ static controller: LLMController;
7
+
8
+ static async load({
9
+ modelSource,
10
+ tokenizerSource,
11
+ tokenizerConfigSource,
12
+ onDownloadProgressCallback,
13
+ responseCallback,
14
+ messageHistoryCallback,
15
+ }: {
16
+ modelSource: ResourceSource;
17
+ tokenizerSource: ResourceSource;
18
+ tokenizerConfigSource: ResourceSource;
19
+ onDownloadProgressCallback?: (_downloadProgress: number) => void;
20
+ responseCallback?: (response: string) => void;
21
+ messageHistoryCallback?: (messageHistory: Message[]) => void;
22
+ }) {
23
+ this.controller = new LLMController({
24
+ responseCallback: responseCallback,
25
+ messageHistoryCallback: messageHistoryCallback,
26
+ onDownloadProgressCallback: onDownloadProgressCallback,
27
+ });
28
+ await this.controller.load({
29
+ modelSource,
30
+ tokenizerSource,
31
+ tokenizerConfigSource,
32
+ });
33
+ }
34
+
35
+ static configure({
36
+ chatConfig,
37
+ toolsConfig,
38
+ }: {
39
+ chatConfig?: Partial<ChatConfig>;
40
+ toolsConfig?: ToolsConfig;
41
+ }) {
42
+ this.controller.configure({ chatConfig, toolsConfig });
43
+ }
44
+
45
+ static async forward(input: string): Promise<string> {
46
+ await this.controller.forward(input);
47
+ return this.controller.response;
48
+ }
49
+
50
+ static async generate(
51
+ messages: Message[],
52
+ tools?: LLMTool[]
53
+ ): Promise<string> {
54
+ await this.controller.generate(messages, tools);
55
+ return this.controller.response;
56
+ }
57
+
58
+ static async sendMessage(message: string): Promise<Message[]> {
59
+ await this.controller.sendMessage(message);
60
+ return this.controller.messageHistory;
61
+ }
62
+
63
+ static async deleteMessage(index: number): Promise<Message[]> {
64
+ await this.controller.deleteMessage(index);
65
+ return this.controller.messageHistory;
53
66
  }
54
67
 
55
68
  static interrupt() {
56
- LLM.interrupt();
69
+ this.controller.interrupt();
57
70
  }
58
71
 
59
72
  static delete() {
60
- LLM.deleteModule();
73
+ this.controller.delete();
61
74
  }
62
75
  }
@@ -1,5 +1,7 @@
1
1
  import { ResourceSource } from '../../types/common';
2
2
  import { SpeechToTextController } from '../../controllers/SpeechToTextController';
3
+ import { AvailableModels, SpeechToTextLanguage } from '../../types/stt';
4
+ import { STREAMING_ACTION } from '../../constants/sttDefaults';
3
5
 
4
6
  export class SpeechToText {
5
7
  static module: SpeechToTextController;
@@ -7,9 +9,9 @@ export class SpeechToText {
7
9
  static onDownloadProgressCallback = (_downloadProgress: number) => {};
8
10
 
9
11
  static async load(
10
- modelName: 'moonshine' | 'whisper',
12
+ modelName: AvailableModels,
11
13
  transcribeCallback: (sequence: string) => void,
12
- modelDownloadProgessCallback?: (downloadProgress: number) => void,
14
+ modelDownloadProgressCallback?: (downloadProgress: number) => void,
13
15
  encoderSource?: ResourceSource,
14
16
  decoderSource?: ResourceSource,
15
17
  tokenizerSource?: ResourceSource,
@@ -25,7 +27,7 @@ export class SpeechToText {
25
27
  ) {
26
28
  this.module = new SpeechToTextController({
27
29
  transcribeCallback: transcribeCallback,
28
- modelDownloadProgessCallback: modelDownloadProgessCallback,
30
+ modelDownloadProgressCallback: modelDownloadProgressCallback,
29
31
  overlapSeconds: overlapSeconds,
30
32
  windowSize: windowSize,
31
33
  streamingConfig: streamingConfig,
@@ -50,17 +52,30 @@ export class SpeechToText {
50
52
  );
51
53
  }
52
54
 
53
- static async transcribe(
54
- waveform: number[]
55
- ): ReturnType<SpeechToTextController['transcribe']> {
56
- return await this.module.transcribe(waveform);
57
- }
58
-
59
55
  static async encode(waveform: number[]) {
60
56
  return await this.module.encode(waveform);
61
57
  }
62
58
 
63
- static async decode(seq: number[], encodings?: number[]) {
59
+ static async decode(seq: number[], encodings: number[]) {
64
60
  return await this.module.decode(seq, encodings);
65
61
  }
62
+
63
+ static async transcribe(
64
+ waveform: number[],
65
+ audioLanguage?: SpeechToTextLanguage
66
+ ): ReturnType<SpeechToTextController['transcribe']> {
67
+ return await this.module.transcribe(waveform, audioLanguage);
68
+ }
69
+
70
+ static async streamingTranscribe(
71
+ streamAction: STREAMING_ACTION,
72
+ waveform?: number[],
73
+ audioLanguage?: SpeechToTextLanguage
74
+ ): ReturnType<SpeechToTextController['streamingTranscribe']> {
75
+ return await this.module.streamingTranscribe(
76
+ streamAction,
77
+ waveform,
78
+ audioLanguage
79
+ );
80
+ }
66
81
  }
@@ -0,0 +1,18 @@
1
+ import { TextEmbeddingsNativeModule } from '../../native/RnExecutorchModules';
2
+ import { ResourceSource } from '../../types/common';
3
+ import { BaseModule } from '../BaseModule';
4
+
5
+ export class TextEmbeddingsModule extends BaseModule {
6
+ protected static override nativeModule = TextEmbeddingsNativeModule;
7
+
8
+ static override async load(
9
+ modelSource: ResourceSource,
10
+ tokenizerSource: ResourceSource
11
+ ) {
12
+ await super.load(modelSource, tokenizerSource);
13
+ }
14
+
15
+ static override async forward(input: string): Promise<number[]> {
16
+ return this.nativeModule.forward(input);
17
+ }
18
+ }
@@ -0,0 +1,34 @@
1
+ import { TokenizerNativeModule } from '../../native/RnExecutorchModules';
2
+ import { ResourceSource } from '../../types/common';
3
+ import { BaseModule } from '../BaseModule';
4
+
5
+ export class TokenizerModule extends BaseModule {
6
+ protected static override nativeModule = TokenizerNativeModule;
7
+
8
+ static override async load(tokenizerSource: ResourceSource) {
9
+ await super.load(tokenizerSource);
10
+ }
11
+
12
+ static async decode(
13
+ input: number[],
14
+ skipSpecialTokens = false
15
+ ): Promise<string> {
16
+ return await this.nativeModule.decode(input, skipSpecialTokens);
17
+ }
18
+
19
+ static async encode(input: string): Promise<number[]> {
20
+ return await this.nativeModule.encode(input);
21
+ }
22
+
23
+ static async getVocabSize(): Promise<number> {
24
+ return await this.nativeModule.getVocabSize();
25
+ }
26
+
27
+ static async idToToken(tokenId: number): Promise<string> {
28
+ return await this.nativeModule.idToToken(tokenId);
29
+ }
30
+
31
+ static async tokenToId(token: string): Promise<number> {
32
+ return await this.nativeModule.tokenToId(token);
33
+ }
34
+ }
@@ -3,7 +3,6 @@ import { TurboModuleRegistry } from 'react-native';
3
3
 
4
4
  export interface Spec extends TurboModule {
5
5
  loadModule(modelSource: string): Promise<number>;
6
-
7
6
  forward(input: string): Promise<{ [category: string]: number }>;
8
7
  }
9
8
 
@@ -0,0 +1,14 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ loadModule(modelSource: string): Promise<number>;
6
+
7
+ forward(
8
+ input: string,
9
+ classesOfInterest: string[],
10
+ resize: boolean
11
+ ): Promise<{ [category: string]: number[] }>;
12
+ }
13
+
14
+ export default TurboModuleRegistry.get<Spec>('ImageSegmentation');
@@ -1,19 +1,12 @@
1
1
  import type { TurboModule } from 'react-native';
2
2
  import { TurboModuleRegistry } from 'react-native';
3
3
  import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
4
- import { MessageType } from '../types/common';
5
4
 
6
5
  export interface Spec extends TurboModule {
7
- loadLLM(
8
- modelSource: string,
9
- tokenizerSource: string,
10
- systemPrompt: string,
11
- messageHistory: MessageType[],
12
- contextWindowLength: number
13
- ): Promise<string>;
14
- runInference(input: string): Promise<string>;
6
+ loadLLM(modelSource: string, tokenizerSource: string): Promise<string>;
7
+ forward(input: string): Promise<string>;
15
8
  interrupt(): void;
16
- deleteModule(): void;
9
+ releaseResources(): void;
17
10
 
18
11
  readonly onToken: EventEmitter<string>;
19
12
  }
@@ -1,6 +1,6 @@
1
1
  import type { TurboModule } from 'react-native';
2
2
  import { TurboModuleRegistry } from 'react-native';
3
- import { Detection } from '../types/object_detection';
3
+ import { Detection } from '../types/objectDetection';
4
4
 
5
5
  export interface Spec extends TurboModule {
6
6
  loadModule(modelSource: string): Promise<number>;
@@ -8,8 +8,8 @@ export interface Spec extends TurboModule {
8
8
  modelSources: (string | number)[]
9
9
  ): Promise<number>;
10
10
  generate(waveform: number[]): Promise<number[]>;
11
- encode(input: number[][]): Promise<number[]>;
12
- decode(prevTokens: number[], encoderOutput: number[]): Promise<number[]>;
11
+ encode(input: number[]): Promise<number[]>;
12
+ decode(prevTokens: number[], encoderOutput: number[]): Promise<number>;
13
13
 
14
14
  readonly onToken: EventEmitter<number>;
15
15
  }
@@ -0,0 +1,9 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ loadModule(modelSource: string, tokenizerSource: string): Promise<number>;
6
+ forward(input: string): Promise<number[]>;
7
+ }
8
+
9
+ export default TurboModuleRegistry.get<Spec>('TextEmbeddings');
@@ -0,0 +1,13 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ loadModule(tokenizerSource: string): Promise<number>;
6
+ decode(input: number[], skipSpecialTokens: boolean): Promise<string>;
7
+ encode(input: string): Promise<number[]>;
8
+ getVocabSize(): Promise<number>;
9
+ idToToken(tokenId: number): Promise<string>;
10
+ tokenToId(token: string): Promise<number>;
11
+ }
12
+
13
+ export default TurboModuleRegistry.get<Spec>('Tokenizer');
@@ -1,10 +1,15 @@
1
1
  import { Platform } from 'react-native';
2
- import { Spec as ClassificationInterface } from './NativeClassification';
3
2
  import { Spec as ObjectDetectionInterface } from './NativeObjectDetection';
4
3
  import { Spec as StyleTransferInterface } from './NativeStyleTransfer';
4
+ import { Spec as ImageSegmentationInterface } from './NativeImageSegmentation';
5
5
  import { Spec as ETModuleInterface } from './NativeETModule';
6
6
  import { Spec as OCRInterface } from './NativeOCR';
7
7
  import { Spec as VerticalOCRInterface } from './NativeVerticalOCR';
8
+ import { Spec as SpeechToTextInterface } from './NativeSpeechToText';
9
+ import { Spec as TextEmbeddingsInterface } from './NativeTextEmbeddings';
10
+ import { Spec as LLMInterface } from './NativeLLM';
11
+ import { Spec as ClassificationInterface } from './NativeClassification';
12
+ import { Spec as TokenizerInterface } from './NativeTokenizer';
8
13
 
9
14
  const LINKING_ERROR =
10
15
  `The package 'react-native-executorch' doesn't seem to be linked. Make sure: \n\n` +
@@ -12,241 +17,56 @@ const LINKING_ERROR =
12
17
  '- You rebuilt the app after installing the package\n' +
13
18
  '- You are not using Expo Go\n';
14
19
 
15
- const LLMSpec = require('./NativeLLM').default;
16
-
17
- const LLM = LLMSpec
18
- ? LLMSpec
19
- : new Proxy(
20
- {},
21
- {
22
- get() {
23
- throw new Error(LINKING_ERROR);
24
- },
25
- }
26
- );
27
-
28
- const ETModuleSpec = require('./NativeETModule').default;
29
-
30
- const ETModule = ETModuleSpec
31
- ? ETModuleSpec
32
- : new Proxy(
33
- {},
34
- {
35
- get() {
36
- throw new Error(LINKING_ERROR);
37
- },
38
- }
39
- );
40
-
41
- const ClassificationSpec = require('./NativeClassification').default;
42
-
43
- const Classification = ClassificationSpec
44
- ? ClassificationSpec
45
- : new Proxy(
46
- {},
47
- {
48
- get() {
49
- throw new Error(LINKING_ERROR);
50
- },
51
- }
52
- );
53
-
54
- const ObjectDetectionSpec = require('./NativeObjectDetection').default;
55
-
56
- const ObjectDetection = ObjectDetectionSpec
57
- ? ObjectDetectionSpec
58
- : new Proxy(
59
- {},
60
- {
61
- get() {
62
- throw new Error(LINKING_ERROR);
63
- },
64
- }
65
- );
66
-
67
- const StyleTransferSpec = require('./NativeStyleTransfer').default;
68
-
69
- const StyleTransfer = StyleTransferSpec
70
- ? StyleTransferSpec
71
- : new Proxy(
72
- {},
73
- {
74
- get() {
75
- throw new Error(LINKING_ERROR);
76
- },
77
- }
78
- );
79
-
80
- const SpeechToTextSpec = require('./NativeSpeechToText').default;
81
-
82
- const SpeechToText = SpeechToTextSpec
83
- ? SpeechToTextSpec
84
- : new Proxy(
85
- {},
86
- {
87
- get() {
88
- throw new Error(LINKING_ERROR);
89
- },
90
- }
91
- );
92
-
93
- const OCRSpec = require('./NativeOCR').default;
94
-
95
- const OCR = OCRSpec
96
- ? OCRSpec
97
- : new Proxy(
98
- {},
99
- {
100
- get() {
101
- throw new Error(LINKING_ERROR);
102
- },
103
- }
104
- );
105
-
106
- const VerticalOCRSpec = require('./NativeVerticalOCR').default;
107
-
108
- const VerticalOCR = VerticalOCRSpec
109
- ? VerticalOCRSpec
110
- : new Proxy(
111
- {},
112
- {
113
- get() {
114
- throw new Error(LINKING_ERROR);
115
- },
116
- }
117
- );
118
-
119
- class _ObjectDetectionModule {
120
- async forward(
121
- input: string
122
- ): ReturnType<ObjectDetectionInterface['forward']> {
123
- return await ObjectDetection.forward(input);
124
- }
125
- async loadModule(
126
- modelSource: string | number
127
- ): ReturnType<ObjectDetectionInterface['loadModule']> {
128
- return await ObjectDetection.loadModule(modelSource);
129
- }
130
- }
131
-
132
- class _StyleTransferModule {
133
- async forward(input: string): ReturnType<StyleTransferInterface['forward']> {
134
- return await StyleTransfer.forward(input);
135
- }
136
- async loadModule(
137
- modelSource: string | number
138
- ): ReturnType<StyleTransferInterface['loadModule']> {
139
- return await StyleTransfer.loadModule(modelSource);
140
- }
20
+ function returnSpecOrThrowLinkingError(spec: any) {
21
+ return spec
22
+ ? spec
23
+ : new Proxy(
24
+ {},
25
+ {
26
+ get() {
27
+ throw new Error(LINKING_ERROR);
28
+ },
29
+ }
30
+ );
141
31
  }
142
32
 
143
- class _SpeechToTextModule {
144
- async generate(waveform: number[][]): Promise<number[]> {
145
- return await SpeechToText.generate(waveform);
146
- }
147
-
148
- async loadModule(modelName: String, modelSources: (string | number)[]) {
149
- return await SpeechToText.loadModule(modelName, modelSources);
150
- }
151
-
152
- async encode(input: number[]) {
153
- return await SpeechToText.encode(input);
154
- }
155
-
156
- async decode(prevTokens: number[], encoderOutput?: number[]) {
157
- return await SpeechToText.decode(prevTokens, encoderOutput || []);
158
- }
159
- }
160
-
161
- class _ClassificationModule {
162
- async forward(input: string): ReturnType<ClassificationInterface['forward']> {
163
- return await Classification.forward(input);
164
- }
165
- async loadModule(
166
- modelSource: string | number
167
- ): ReturnType<ClassificationInterface['loadModule']> {
168
- return await Classification.loadModule(modelSource);
169
- }
170
- }
171
-
172
- class _OCRModule {
173
- async forward(input: string): ReturnType<OCRInterface['forward']> {
174
- return await OCR.forward(input);
175
- }
176
-
177
- async loadModule(
178
- detectorSource: string,
179
- recognizerSourceLarge: string,
180
- recognizerSourceMedium: string,
181
- recognizerSourceSmall: string,
182
- symbols: string
183
- ) {
184
- return await OCR.loadModule(
185
- detectorSource,
186
- recognizerSourceLarge,
187
- recognizerSourceMedium,
188
- recognizerSourceSmall,
189
- symbols
190
- );
191
- }
192
- }
193
-
194
- class _VerticalOCRModule {
195
- async forward(input: string): ReturnType<VerticalOCRInterface['forward']> {
196
- return await VerticalOCR.forward(input);
197
- }
198
-
199
- async loadModule(
200
- detectorLargeSource: string,
201
- detectorMediumSource: string,
202
- recognizerSource: string,
203
- symbols: string,
204
- independentCharacters: boolean
205
- ): ReturnType<VerticalOCRInterface['loadModule']> {
206
- return await VerticalOCR.loadModule(
207
- detectorLargeSource,
208
- detectorMediumSource,
209
- recognizerSource,
210
- symbols,
211
- independentCharacters
212
- );
213
- }
214
- }
215
-
216
- class _ETModule {
217
- async forward(
218
- inputs: number[][],
219
- shapes: number[][],
220
- inputTypes: number[]
221
- ): ReturnType<ETModuleInterface['forward']> {
222
- return await ETModule.forward(inputs, shapes, inputTypes);
223
- }
224
- async loadModule(
225
- modelSource: string
226
- ): ReturnType<ETModuleInterface['loadModule']> {
227
- return await ETModule.loadModule(modelSource);
228
- }
229
- async loadMethod(
230
- methodName: string
231
- ): ReturnType<ETModuleInterface['loadMethod']> {
232
- return await ETModule.loadMethod(methodName);
233
- }
234
- }
33
+ const LLMNativeModule: LLMInterface = returnSpecOrThrowLinkingError(
34
+ require('./NativeLLM').default
35
+ );
36
+ const ETModuleNativeModule: ETModuleInterface = returnSpecOrThrowLinkingError(
37
+ require('./NativeETModule').default
38
+ );
39
+ const ClassificationNativeModule: ClassificationInterface =
40
+ returnSpecOrThrowLinkingError(require('./NativeClassification').default);
41
+ const ImageSegmentationNativeModule: ImageSegmentationInterface =
42
+ returnSpecOrThrowLinkingError(require('./NativeImageSegmentation').default);
43
+ const ObjectDetectionNativeModule: ObjectDetectionInterface =
44
+ returnSpecOrThrowLinkingError(require('./NativeObjectDetection').default);
45
+ const StyleTransferNativeModule: StyleTransferInterface =
46
+ returnSpecOrThrowLinkingError(require('./NativeStyleTransfer').default);
47
+ const SpeechToTextNativeModule: SpeechToTextInterface =
48
+ returnSpecOrThrowLinkingError(require('./NativeSpeechToText').default);
49
+ const OCRNativeModule: OCRInterface = returnSpecOrThrowLinkingError(
50
+ require('./NativeOCR').default
51
+ );
52
+ const VerticalOCRNativeModule: VerticalOCRInterface =
53
+ returnSpecOrThrowLinkingError(require('./NativeVerticalOCR').default);
54
+ const TokenizerNativeModule: TokenizerInterface = returnSpecOrThrowLinkingError(
55
+ require('./NativeTokenizer').default
56
+ );
57
+ const TextEmbeddingsNativeModule: TextEmbeddingsInterface =
58
+ returnSpecOrThrowLinkingError(require('./NativeTextEmbeddings').default);
235
59
 
236
60
  export {
237
- LLM,
238
- ETModule,
239
- Classification,
240
- ObjectDetection,
241
- StyleTransfer,
242
- SpeechToText,
243
- OCR,
244
- VerticalOCR,
245
- _ETModule,
246
- _ClassificationModule,
247
- _StyleTransferModule,
248
- _ObjectDetectionModule,
249
- _SpeechToTextModule,
250
- _OCRModule,
251
- _VerticalOCRModule,
61
+ LLMNativeModule,
62
+ ETModuleNativeModule,
63
+ ClassificationNativeModule,
64
+ ObjectDetectionNativeModule,
65
+ StyleTransferNativeModule,
66
+ ImageSegmentationNativeModule,
67
+ SpeechToTextNativeModule,
68
+ OCRNativeModule,
69
+ VerticalOCRNativeModule,
70
+ TextEmbeddingsNativeModule,
71
+ TokenizerNativeModule,
252
72
  };