react-native-executorch 0.3.3 → 0.4.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.
- package/README.md +30 -13
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/ETModule.kt +1 -2
- package/android/src/main/java/com/swmansion/rnexecutorch/ImageSegmentation.kt +58 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/LLM.kt +13 -49
- package/android/src/main/java/com/swmansion/rnexecutorch/RnExecutorchPackage.kt +37 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/StyleTransfer.kt +1 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/TextEmbeddings.kt +51 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/Tokenizer.kt +86 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/BaseModel.kt +3 -4
- package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsModel.kt +48 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/TextEmbeddings/TextEmbeddingsUtils.kt +37 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/classification/ClassificationModel.kt +1 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/Constants.kt +26 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/imageSegmentation/ImageSegmentationModel.kt +142 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/ocr/utils/RecognizerUtils.kt +3 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/models/{StyleTransferModel.kt → styleTransfer/StyleTransferModel.kt} +2 -1
- package/android/src/main/java/com/swmansion/rnexecutorch/utils/ArrayUtils.kt +0 -8
- package/android/src/main/java/com/swmansion/rnexecutorch/{models/classification/Utils.kt → utils/Numerical.kt} +1 -1
- package/ios/ExecutorchLib.xcframework/Info.plist +4 -4
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/ExecutorchLib +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +14 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Headers/LLaMARunner.h +1 -23
- package/ios/ExecutorchLib.xcframework/ios-arm64/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/ExecutorchLib +0 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/HuggingFaceTokenizer.h +14 -0
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Headers/LLaMARunner.h +1 -23
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/Info.plist +0 -0
- package/ios/RnExecutorch/Classification.mm +15 -18
- package/ios/RnExecutorch/ETModule.mm +6 -5
- package/ios/RnExecutorch/ImageSegmentation.h +5 -0
- package/ios/RnExecutorch/ImageSegmentation.mm +60 -0
- package/ios/RnExecutorch/LLM.mm +12 -53
- package/ios/RnExecutorch/OCR.mm +39 -43
- package/ios/RnExecutorch/ObjectDetection.mm +20 -20
- package/ios/RnExecutorch/SpeechToText.mm +6 -7
- package/ios/RnExecutorch/StyleTransfer.mm +16 -19
- package/ios/RnExecutorch/TextEmbeddings.h +5 -0
- package/ios/RnExecutorch/TextEmbeddings.mm +62 -0
- package/ios/RnExecutorch/Tokenizer.h +5 -0
- package/ios/RnExecutorch/Tokenizer.mm +83 -0
- package/ios/RnExecutorch/VerticalOCR.mm +36 -36
- package/ios/RnExecutorch/models/BaseModel.h +2 -5
- package/ios/RnExecutorch/models/BaseModel.mm +5 -15
- package/ios/RnExecutorch/models/classification/ClassificationModel.mm +2 -3
- package/ios/RnExecutorch/models/classification/Constants.mm +0 -1
- package/ios/RnExecutorch/models/image_segmentation/Constants.h +4 -0
- package/ios/RnExecutorch/models/image_segmentation/Constants.mm +8 -0
- package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.h +10 -0
- package/ios/RnExecutorch/models/image_segmentation/ImageSegmentationModel.mm +146 -0
- package/ios/RnExecutorch/models/object_detection/SSDLiteLargeModel.mm +1 -2
- package/ios/RnExecutorch/models/ocr/Detector.h +0 -2
- package/ios/RnExecutorch/models/ocr/Detector.mm +2 -1
- package/ios/RnExecutorch/models/ocr/RecognitionHandler.h +5 -4
- package/ios/RnExecutorch/models/ocr/RecognitionHandler.mm +9 -26
- package/ios/RnExecutorch/models/ocr/Recognizer.mm +1 -2
- package/ios/RnExecutorch/models/ocr/VerticalDetector.h +0 -2
- package/ios/RnExecutorch/models/ocr/VerticalDetector.mm +2 -1
- package/ios/RnExecutorch/models/ocr/utils/OCRUtils.mm +0 -1
- package/ios/RnExecutorch/models/stt/Moonshine.mm +1 -6
- package/ios/RnExecutorch/models/stt/SpeechToTextBaseModel.mm +7 -11
- package/ios/RnExecutorch/models/stt/Whisper.mm +0 -5
- package/ios/RnExecutorch/models/{StyleTransferModel.h → style_transfer/StyleTransferModel.h} +1 -1
- package/ios/RnExecutorch/models/{StyleTransferModel.mm → style_transfer/StyleTransferModel.mm} +2 -3
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.h +15 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsModel.mm +45 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.h +8 -0
- package/ios/RnExecutorch/models/text_embeddings/TextEmbeddingsUtils.mm +49 -0
- package/ios/RnExecutorch/utils/Conversions.h +15 -0
- package/ios/RnExecutorch/utils/ImageProcessor.h +0 -1
- package/ios/RnExecutorch/{models/classification/Utils.h → utils/Numerical.h} +0 -2
- package/ios/RnExecutorch/{models/classification/Utils.mm → utils/Numerical.mm} +0 -2
- package/ios/RnExecutorch/utils/ObjectDetectionUtils.mm +0 -2
- package/ios/RnExecutorch/utils/SFFT.mm +1 -1
- package/ios/RnExecutorch/utils/ScalarType.h +0 -2
- package/lib/module/Error.js +16 -2
- package/lib/module/Error.js.map +1 -1
- package/lib/module/constants/{llamaDefaults.js → llmDefaults.js} +7 -3
- package/lib/module/constants/llmDefaults.js.map +1 -0
- package/lib/module/constants/modelUrls.js +88 -27
- package/lib/module/constants/modelUrls.js.map +1 -1
- package/lib/module/constants/ocr/models.js +290 -0
- package/lib/module/constants/ocr/models.js.map +1 -0
- package/lib/module/constants/ocr/symbols.js +137 -2
- package/lib/module/constants/ocr/symbols.js.map +1 -1
- package/lib/module/constants/sttDefaults.js +50 -25
- package/lib/module/constants/sttDefaults.js.map +1 -1
- package/lib/module/controllers/LLMController.js +205 -0
- package/lib/module/controllers/LLMController.js.map +1 -0
- package/lib/module/controllers/OCRController.js +5 -10
- package/lib/module/controllers/OCRController.js.map +1 -1
- package/lib/module/controllers/SpeechToTextController.js +225 -122
- package/lib/module/controllers/SpeechToTextController.js.map +1 -1
- package/lib/module/controllers/VerticalOCRController.js +6 -10
- package/lib/module/controllers/VerticalOCRController.js.map +1 -1
- package/lib/module/hooks/computer_vision/useClassification.js +8 -23
- package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageSegmentation.js +13 -0
- package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -0
- package/lib/module/hooks/computer_vision/useOCR.js +11 -6
- package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
- package/lib/module/hooks/computer_vision/useObjectDetection.js +8 -23
- package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
- package/lib/module/hooks/computer_vision/useStyleTransfer.js +8 -23
- package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
- package/lib/module/hooks/computer_vision/useVerticalOCR.js +10 -7
- package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
- package/lib/module/hooks/general/useExecutorchModule.js +8 -36
- package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useLLM.js +54 -63
- package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useSpeechToText.js +15 -11
- package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +14 -0
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -0
- package/lib/module/hooks/natural_language_processing/useTokenizer.js +54 -0
- package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -0
- package/lib/module/hooks/useModule.js +18 -62
- package/lib/module/hooks/useModule.js.map +1 -1
- package/lib/module/index.js +16 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/BaseModule.js +9 -10
- package/lib/module/modules/BaseModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ClassificationModule.js +8 -5
- package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js +28 -0
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -0
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js +8 -5
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
- package/lib/module/modules/computer_vision/StyleTransferModule.js +8 -5
- package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
- package/lib/module/modules/general/ExecutorchModule.js +8 -5
- package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/LLMModule.js +46 -27
- package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +8 -5
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +14 -0
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -0
- package/lib/module/modules/natural_language_processing/TokenizerModule.js +26 -0
- package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -0
- package/lib/module/native/NativeClassification.js.map +1 -1
- package/lib/module/native/NativeImageSegmentation.js +5 -0
- package/lib/module/native/NativeImageSegmentation.js.map +1 -0
- package/lib/module/native/NativeLLM.js.map +1 -1
- package/lib/module/native/NativeTextEmbeddings.js +5 -0
- package/lib/module/native/NativeTextEmbeddings.js.map +1 -0
- package/lib/module/native/NativeTokenizer.js +5 -0
- package/lib/module/native/NativeTokenizer.js.map +1 -0
- package/lib/module/native/RnExecutorchModules.js +18 -113
- package/lib/module/native/RnExecutorchModules.js.map +1 -1
- package/lib/module/types/common.js.map +1 -1
- package/lib/module/types/imageSegmentation.js +29 -0
- package/lib/module/types/imageSegmentation.js.map +1 -0
- package/lib/module/types/llm.js +7 -0
- package/lib/module/types/llm.js.map +1 -0
- package/lib/module/types/{object_detection.js → objectDetection.js} +1 -1
- package/lib/module/types/objectDetection.js.map +1 -0
- package/lib/module/types/ocr.js +2 -0
- package/lib/module/types/stt.js +82 -0
- package/lib/module/types/stt.js.map +1 -0
- package/lib/module/utils/ResourceFetcher.js +156 -0
- package/lib/module/utils/ResourceFetcher.js.map +1 -0
- package/lib/module/utils/llm.js +25 -0
- package/lib/module/utils/llm.js.map +1 -0
- package/lib/module/utils/stt.js +22 -0
- package/lib/module/utils/stt.js.map +1 -0
- package/lib/typescript/Error.d.ts +4 -1
- package/lib/typescript/Error.d.ts.map +1 -1
- package/lib/typescript/constants/{llamaDefaults.d.ts → llmDefaults.d.ts} +5 -5
- package/lib/typescript/constants/llmDefaults.d.ts.map +1 -0
- package/lib/typescript/constants/modelUrls.d.ts +74 -28
- package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
- package/lib/typescript/constants/ocr/models.d.ts +285 -0
- package/lib/typescript/constants/ocr/models.d.ts.map +1 -0
- package/lib/typescript/constants/ocr/symbols.d.ts +73 -1
- package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
- package/lib/typescript/constants/sttDefaults.d.ts +8 -13
- package/lib/typescript/constants/sttDefaults.d.ts.map +1 -1
- package/lib/typescript/controllers/LLMController.d.ts +46 -0
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -0
- package/lib/typescript/controllers/OCRController.d.ts.map +1 -1
- package/lib/typescript/controllers/SpeechToTextController.d.ts +30 -16
- package/lib/typescript/controllers/SpeechToTextController.d.ts.map +1 -1
- package/lib/typescript/controllers/VerticalOCRController.d.ts +1 -1
- package/lib/typescript/controllers/VerticalOCRController.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useClassification.d.ts +5 -5
- package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +37 -0
- package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -0
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts +2 -1
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +5 -4
- package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +4 -2
- package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +2 -1
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/general/useExecutorchModule.d.ts +5 -6
- package/lib/typescript/hooks/general/useExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +6 -6
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +7 -3
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +13 -0
- package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -0
- package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +16 -0
- package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -0
- package/lib/typescript/hooks/useModule.d.ts +11 -10
- package/lib/typescript/hooks/useModule.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +15 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modules/BaseModule.d.ts +4 -5
- package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +7 -7
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +32 -0
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -0
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +6 -5
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +6 -5
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
- package/lib/typescript/modules/general/ExecutorchModule.d.ts +4 -3
- package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +19 -5
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +7 -4
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +8 -0
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -0
- package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +12 -0
- package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -0
- package/lib/typescript/native/NativeClassification.d.ts.map +1 -1
- package/lib/typescript/native/NativeImageSegmentation.d.ts +10 -0
- package/lib/typescript/native/NativeImageSegmentation.d.ts.map +1 -0
- package/lib/typescript/native/NativeLLM.d.ts +3 -4
- package/lib/typescript/native/NativeLLM.d.ts.map +1 -1
- package/lib/typescript/native/NativeObjectDetection.d.ts +1 -1
- package/lib/typescript/native/NativeObjectDetection.d.ts.map +1 -1
- package/lib/typescript/native/NativeSpeechToText.d.ts +2 -2
- package/lib/typescript/native/NativeSpeechToText.d.ts.map +1 -1
- package/lib/typescript/native/NativeTextEmbeddings.d.ts +8 -0
- package/lib/typescript/native/NativeTextEmbeddings.d.ts.map +1 -0
- package/lib/typescript/native/NativeTokenizer.d.ts +12 -0
- package/lib/typescript/native/NativeTokenizer.d.ts.map +1 -0
- package/lib/typescript/native/RnExecutorchModules.d.ts +18 -41
- package/lib/typescript/native/RnExecutorchModules.d.ts.map +1 -1
- package/lib/typescript/types/common.d.ts +1 -26
- package/lib/typescript/types/common.d.ts.map +1 -1
- package/lib/typescript/types/imageSegmentation.d.ts +25 -0
- package/lib/typescript/types/imageSegmentation.d.ts.map +1 -0
- package/lib/typescript/types/llm.d.ts +38 -0
- package/lib/typescript/types/llm.d.ts.map +1 -0
- package/lib/typescript/types/{object_detection.d.ts → objectDetection.d.ts} +1 -1
- package/lib/typescript/types/objectDetection.d.ts.map +1 -0
- package/lib/typescript/types/ocr.d.ts +2 -1
- package/lib/typescript/types/ocr.d.ts.map +1 -1
- package/lib/typescript/types/stt.d.ts +91 -0
- package/lib/typescript/types/stt.d.ts.map +1 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts +17 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -0
- package/lib/typescript/utils/llm.d.ts +3 -0
- package/lib/typescript/utils/llm.d.ts.map +1 -0
- package/lib/typescript/utils/stt.d.ts +2 -0
- package/lib/typescript/utils/stt.d.ts.map +1 -0
- package/package.json +13 -49
- package/react-native-executorch.podspec +1 -1
- package/src/Error.ts +16 -3
- package/src/constants/llmDefaults.ts +14 -0
- package/src/constants/modelUrls.ts +146 -39
- package/src/constants/ocr/models.ts +453 -0
- package/src/constants/ocr/symbols.ts +147 -3
- package/src/constants/sttDefaults.ts +55 -37
- package/src/controllers/LLMController.ts +286 -0
- package/src/controllers/OCRController.ts +14 -28
- package/src/controllers/SpeechToTextController.ts +318 -180
- package/src/controllers/VerticalOCRController.ts +17 -32
- package/src/hooks/computer_vision/useClassification.ts +11 -26
- package/src/hooks/computer_vision/useImageSegmentation.ts +18 -0
- package/src/hooks/computer_vision/useOCR.ts +17 -5
- package/src/hooks/computer_vision/useObjectDetection.ts +10 -24
- package/src/hooks/computer_vision/useStyleTransfer.ts +9 -25
- package/src/hooks/computer_vision/useVerticalOCR.ts +11 -4
- package/src/hooks/general/useExecutorchModule.ts +10 -50
- package/src/hooks/natural_language_processing/useLLM.ts +80 -97
- package/src/hooks/natural_language_processing/useSpeechToText.ts +39 -12
- package/src/hooks/natural_language_processing/useTextEmbeddings.ts +18 -0
- package/src/hooks/natural_language_processing/useTokenizer.ts +61 -0
- package/src/hooks/useModule.ts +32 -92
- package/src/index.tsx +16 -2
- package/src/modules/BaseModule.ts +16 -26
- package/src/modules/computer_vision/ClassificationModule.ts +13 -8
- package/src/modules/computer_vision/ImageSegmentationModule.ts +39 -0
- package/src/modules/computer_vision/ObjectDetectionModule.ts +13 -8
- package/src/modules/computer_vision/StyleTransferModule.ts +13 -8
- package/src/modules/general/ExecutorchModule.ts +11 -6
- package/src/modules/natural_language_processing/LLMModule.ts +64 -51
- package/src/modules/natural_language_processing/SpeechToTextModule.ts +25 -10
- package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +18 -0
- package/src/modules/natural_language_processing/TokenizerModule.ts +34 -0
- package/src/native/NativeClassification.ts +0 -1
- package/src/native/NativeImageSegmentation.ts +14 -0
- package/src/native/NativeLLM.ts +3 -10
- package/src/native/NativeObjectDetection.ts +1 -1
- package/src/native/NativeSpeechToText.ts +2 -2
- package/src/native/NativeTextEmbeddings.ts +9 -0
- package/src/native/NativeTokenizer.ts +13 -0
- package/src/native/RnExecutorchModules.ts +54 -234
- package/src/types/common.ts +1 -44
- package/src/types/imageSegmentation.ts +25 -0
- package/src/types/llm.ts +57 -0
- package/src/types/ocr.ts +3 -1
- package/src/types/stt.ts +93 -0
- package/src/utils/ResourceFetcher.ts +196 -0
- package/src/utils/llm.ts +34 -0
- package/src/utils/stt.ts +28 -0
- package/android/src/main/java/com/swmansion/rnexecutorch/utils/llms/ConversationManager.kt +0 -68
- package/ios/ExecutorchLib.xcframework/ios-arm64-simulator/ExecutorchLib.framework/_CodeSignature/CodeResources +0 -124
- package/ios/RnExecutorch/utils/llms/Constants.h +0 -6
- package/ios/RnExecutorch/utils/llms/Constants.mm +0 -23
- package/ios/RnExecutorch/utils/llms/ConversationManager.h +0 -26
- package/ios/RnExecutorch/utils/llms/ConversationManager.mm +0 -71
- package/lib/module/constants/llamaDefaults.js.map +0 -1
- package/lib/module/modules/computer_vision/BaseCVModule.js +0 -14
- package/lib/module/modules/computer_vision/BaseCVModule.js.map +0 -1
- package/lib/module/types/object_detection.js.map +0 -1
- package/lib/module/utils/fetchResource.js +0 -93
- package/lib/module/utils/fetchResource.js.map +0 -1
- package/lib/module/utils/listDownloadedResources.js +0 -13
- package/lib/module/utils/listDownloadedResources.js.map +0 -1
- package/lib/typescript/constants/llamaDefaults.d.ts.map +0 -1
- package/lib/typescript/modules/computer_vision/BaseCVModule.d.ts +0 -9
- package/lib/typescript/modules/computer_vision/BaseCVModule.d.ts.map +0 -1
- package/lib/typescript/types/object_detection.d.ts.map +0 -1
- package/lib/typescript/utils/fetchResource.d.ts +0 -3
- package/lib/typescript/utils/fetchResource.d.ts.map +0 -1
- package/lib/typescript/utils/listDownloadedResources.d.ts +0 -3
- package/lib/typescript/utils/listDownloadedResources.d.ts.map +0 -1
- package/src/constants/llamaDefaults.ts +0 -9
- package/src/modules/computer_vision/BaseCVModule.ts +0 -22
- package/src/utils/fetchResource.ts +0 -106
- package/src/utils/listDownloadedResources.ts +0 -12
- /package/src/types/{object_detection.ts → objectDetection.ts} +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#import "Constants.h"
|
|
2
|
-
#import "ConversationManager.h"
|
|
3
|
-
#import <string>
|
|
4
|
-
|
|
5
|
-
NSString *const END_OF_TEXT_TOKEN_NS =
|
|
6
|
-
[[NSString alloc] initWithBytes:END_OF_TEXT_TOKEN.data()
|
|
7
|
-
length:END_OF_TEXT_TOKEN.size()
|
|
8
|
-
encoding:NSUTF8StringEncoding];
|
|
9
|
-
|
|
10
|
-
NSString *const BEGIN_OF_TEXT_TOKEN_NS =
|
|
11
|
-
[[NSString alloc] initWithBytes:BEGIN_OF_TEXT_TOKEN.data()
|
|
12
|
-
length:BEGIN_OF_TEXT_TOKEN.size()
|
|
13
|
-
encoding:NSUTF8StringEncoding];
|
|
14
|
-
|
|
15
|
-
NSString *const START_HEADER_ID_TOKEN_NS =
|
|
16
|
-
[[NSString alloc] initWithBytes:START_HEADER_ID_TOKEN.data()
|
|
17
|
-
length:START_HEADER_ID_TOKEN.size()
|
|
18
|
-
encoding:NSUTF8StringEncoding];
|
|
19
|
-
|
|
20
|
-
NSString *const END_HEADER_ID_TOKEN_NS =
|
|
21
|
-
[[NSString alloc] initWithBytes:END_HEADER_ID_TOKEN.data()
|
|
22
|
-
length:END_HEADER_ID_TOKEN.size()
|
|
23
|
-
encoding:NSUTF8StringEncoding];
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
#import <deque>
|
|
3
|
-
#import <string>
|
|
4
|
-
#import <string_view>
|
|
5
|
-
|
|
6
|
-
enum class ChatRole { SYSTEM, USER, ASSISTANT };
|
|
7
|
-
|
|
8
|
-
inline constexpr std::string_view BEGIN_OF_TEXT_TOKEN = "<|begin_of_text|>";
|
|
9
|
-
inline constexpr std::string_view END_OF_TEXT_TOKEN = "<|eot_id|>";
|
|
10
|
-
inline constexpr std::string_view START_HEADER_ID_TOKEN = "<|start_header_id|>";
|
|
11
|
-
inline constexpr std::string_view END_HEADER_ID_TOKEN = "<|end_header_id|>";
|
|
12
|
-
|
|
13
|
-
@interface ConversationManager : NSObject {
|
|
14
|
-
NSUInteger numMessagesContextWindow;
|
|
15
|
-
std::string basePrompt;
|
|
16
|
-
std::deque<std::string> messages;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
- (instancetype)initWithNumMessagesContextWindow:(NSUInteger)numMessages
|
|
20
|
-
systemPrompt:(NSString *)systemPrompt
|
|
21
|
-
messageHistory:(NSArray *)messageHistory;
|
|
22
|
-
|
|
23
|
-
- (void)addResponse:(NSString *)text senderRole:(ChatRole)senderRole;
|
|
24
|
-
- (NSString *)getConversation;
|
|
25
|
-
|
|
26
|
-
@end
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
#import "ConversationManager.h"
|
|
2
|
-
|
|
3
|
-
@implementation ConversationManager
|
|
4
|
-
|
|
5
|
-
- (instancetype)initWithNumMessagesContextWindow:(NSUInteger)numMessages
|
|
6
|
-
systemPrompt:(NSString *)systemPrompt
|
|
7
|
-
messageHistory:(NSArray *)messageHistory {
|
|
8
|
-
self = [super init];
|
|
9
|
-
if (self) {
|
|
10
|
-
numMessagesContextWindow = numMessages;
|
|
11
|
-
basePrompt += std::string(BEGIN_OF_TEXT_TOKEN);
|
|
12
|
-
basePrompt += [self getHeaderTokenFromRole:ChatRole::SYSTEM];
|
|
13
|
-
basePrompt += [systemPrompt UTF8String];
|
|
14
|
-
basePrompt += std::string(END_OF_TEXT_TOKEN);
|
|
15
|
-
basePrompt += [self getHeaderTokenFromRole:ChatRole::USER];
|
|
16
|
-
|
|
17
|
-
for (const NSDictionary *message in messageHistory) {
|
|
18
|
-
NSString *role = message[@"role"];
|
|
19
|
-
NSString *content = message[@"content"];
|
|
20
|
-
if ([role isEqualToString:@"user"]) {
|
|
21
|
-
[self addResponse:content senderRole:ChatRole::USER];
|
|
22
|
-
} else if ([role isEqualToString:@"assistant"]) {
|
|
23
|
-
[self addResponse:content senderRole:ChatRole::ASSISTANT];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return self;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
- (void)addResponse:(NSString *)text senderRole:(ChatRole)senderRole {
|
|
31
|
-
if (messages.size() >= numMessagesContextWindow) {
|
|
32
|
-
messages.pop_front();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
std::string formattedMessage;
|
|
36
|
-
if (senderRole == ChatRole::ASSISTANT) {
|
|
37
|
-
formattedMessage = [text UTF8String];
|
|
38
|
-
formattedMessage += [self getHeaderTokenFromRole:ChatRole::USER];
|
|
39
|
-
} else {
|
|
40
|
-
formattedMessage += [text UTF8String];
|
|
41
|
-
formattedMessage += std::string(END_OF_TEXT_TOKEN);
|
|
42
|
-
formattedMessage += [self getHeaderTokenFromRole:ChatRole::ASSISTANT];
|
|
43
|
-
}
|
|
44
|
-
messages.push_back(formattedMessage);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
- (NSString *)getConversation {
|
|
48
|
-
std::string prompt = basePrompt;
|
|
49
|
-
for (const auto &elem : messages) {
|
|
50
|
-
prompt += elem;
|
|
51
|
-
}
|
|
52
|
-
return [NSString stringWithUTF8String:prompt.c_str()];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
- (std::string)getHeaderTokenFromRole:(ChatRole)role {
|
|
56
|
-
switch (role) {
|
|
57
|
-
case ChatRole::SYSTEM:
|
|
58
|
-
return std::string(START_HEADER_ID_TOKEN) + "system" +
|
|
59
|
-
std::string(END_HEADER_ID_TOKEN);
|
|
60
|
-
case ChatRole::USER:
|
|
61
|
-
return std::string(START_HEADER_ID_TOKEN) + "user" +
|
|
62
|
-
std::string(END_HEADER_ID_TOKEN);
|
|
63
|
-
case ChatRole::ASSISTANT:
|
|
64
|
-
return std::string(START_HEADER_ID_TOKEN) + "assistant" +
|
|
65
|
-
std::string(END_HEADER_ID_TOKEN);
|
|
66
|
-
default:
|
|
67
|
-
return "";
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_SYSTEM_PROMPT","DEFAULT_MESSAGE_HISTORY","DEFAULT_CONTEXT_WINDOW_LENGTH","EOT_TOKEN"],"sourceRoot":"../../../src","sources":["constants/llamaDefaults.ts"],"mappings":";;AAEA,OAAO,MAAMA,qBAAqB,GAChC,+QAA+Q;AAEjR,OAAO,MAAMC,uBAAsC,GAAG,EAAE;AAExD,OAAO,MAAMC,6BAA6B,GAAG,CAAC;AAC9C,OAAO,MAAMC,SAAS,GAAG,YAAY","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { BaseModule } from '../BaseModule';
|
|
4
|
-
import { getError } from '../../Error';
|
|
5
|
-
export class BaseCVModule extends BaseModule {
|
|
6
|
-
static async forward(input) {
|
|
7
|
-
try {
|
|
8
|
-
return await this.module.forward(input);
|
|
9
|
-
} catch (e) {
|
|
10
|
-
throw new Error(getError(e));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=BaseCVModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["BaseModule","getError","BaseCVModule","forward","input","module","e","Error"],"sourceRoot":"../../../../src","sources":["modules/computer_vision/BaseCVModule.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,eAAe;AAM1C,SAASC,QAAQ,QAAQ,aAAa;AAEtC,OAAO,MAAMC,YAAY,SAASF,UAAU,CAAC;EAM3C,aAAaG,OAAOA,CAACC,KAAa,EAAE;IAClC,IAAI;MACF,OAAO,MAAM,IAAI,CAACC,MAAM,CAACF,OAAO,CAACC,KAAK,CAAC;IACzC,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV,MAAM,IAAIC,KAAK,CAACN,QAAQ,CAACK,CAAC,CAAC,CAAC;IAC9B;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CocoLabel"],"sourceRoot":"../../../src","sources":["types/object_detection.ts"],"mappings":";;IAaKA,SAAS,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA,EAATA,SAAS","ignoreList":[]}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { cacheDirectory, createDownloadResumable, getInfoAsync, makeDirectoryAsync, moveAsync, FileSystemSessionType } from 'expo-file-system';
|
|
4
|
-
import { Asset } from 'expo-asset';
|
|
5
|
-
import { RNEDirectory } from '../constants/directories';
|
|
6
|
-
const getFilenameFromUri = uri => {
|
|
7
|
-
const filename = uri.split('/').pop()?.split('?')[0];
|
|
8
|
-
if (!filename) {
|
|
9
|
-
throw new Error('Cannot derive filename from URI');
|
|
10
|
-
}
|
|
11
|
-
return filename;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Increments the Hugging Face download counter if the URI points to a Software Mansion Hugging Face repo.
|
|
16
|
-
* More information: https://huggingface.co/docs/hub/models-download-stats
|
|
17
|
-
*/
|
|
18
|
-
const triggerHuggingFaceDownloadCounter = uri => {
|
|
19
|
-
const url = new URL(uri);
|
|
20
|
-
if (url.host === 'huggingface.co' && url.pathname.startsWith('/software-mansion/')) {
|
|
21
|
-
const baseUrl = `${url.protocol}//${url.host}${url.pathname.split('resolve')[0]}`;
|
|
22
|
-
fetch(`${baseUrl}resolve/main/config.json`, {
|
|
23
|
-
method: 'HEAD'
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
export const fetchResource = async (source, callback = () => {}) => {
|
|
28
|
-
const uri = typeof source === 'number' ? Asset.fromModule(source).uri : source;
|
|
29
|
-
|
|
30
|
-
// Handle local files
|
|
31
|
-
if (uri.startsWith('file://')) {
|
|
32
|
-
return uri;
|
|
33
|
-
}
|
|
34
|
-
const filename = getFilenameFromUri(uri);
|
|
35
|
-
const fileUri = `${RNEDirectory}${filename}`;
|
|
36
|
-
|
|
37
|
-
// Check if the file already exists
|
|
38
|
-
if ((await getInfoAsync(fileUri)).exists) {
|
|
39
|
-
return fileUri;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Create the RNEDirectory if it doesn't exist
|
|
43
|
-
if (!(await getInfoAsync(RNEDirectory)).exists) {
|
|
44
|
-
await makeDirectoryAsync(RNEDirectory, {
|
|
45
|
-
intermediates: true
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Handle local asset files in release mode
|
|
50
|
-
if (!uri.includes('://')) {
|
|
51
|
-
const asset = Asset.fromModule(source);
|
|
52
|
-
const fileUriWithType = `${fileUri}.${asset.type}`;
|
|
53
|
-
await asset.downloadAsync();
|
|
54
|
-
await moveAsync({
|
|
55
|
-
from: asset.localUri,
|
|
56
|
-
to: fileUriWithType
|
|
57
|
-
});
|
|
58
|
-
return fileUriWithType;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Handle remote file download
|
|
62
|
-
const cacheFileUri = `${cacheDirectory}${filename}`;
|
|
63
|
-
const downloadResumable = createDownloadResumable(uri, cacheFileUri, {
|
|
64
|
-
sessionType: FileSystemSessionType.BACKGROUND
|
|
65
|
-
}, ({
|
|
66
|
-
totalBytesWritten,
|
|
67
|
-
totalBytesExpectedToWrite
|
|
68
|
-
}) => {
|
|
69
|
-
callback(totalBytesWritten / totalBytesExpectedToWrite);
|
|
70
|
-
});
|
|
71
|
-
const result = await downloadResumable.downloadAsync();
|
|
72
|
-
if (!result || result.status !== 200) {
|
|
73
|
-
throw new Error(`Failed to fetch resource from '${uri}'`);
|
|
74
|
-
}
|
|
75
|
-
await moveAsync({
|
|
76
|
-
from: cacheFileUri,
|
|
77
|
-
to: fileUri
|
|
78
|
-
});
|
|
79
|
-
triggerHuggingFaceDownloadCounter(uri);
|
|
80
|
-
return fileUri;
|
|
81
|
-
};
|
|
82
|
-
export const calculateDownloadProgres = (numberOfFiles, currentFileIndex, setProgress) => progress => {
|
|
83
|
-
if (progress === 1 && currentFileIndex === numberOfFiles - 1) {
|
|
84
|
-
setProgress(1);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const contributionPerFile = 1 / numberOfFiles;
|
|
88
|
-
const baseProgress = contributionPerFile * currentFileIndex;
|
|
89
|
-
const scaledProgress = progress * contributionPerFile;
|
|
90
|
-
const updatedProgress = baseProgress + scaledProgress;
|
|
91
|
-
setProgress(updatedProgress);
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=fetchResource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["cacheDirectory","createDownloadResumable","getInfoAsync","makeDirectoryAsync","moveAsync","FileSystemSessionType","Asset","RNEDirectory","getFilenameFromUri","uri","filename","split","pop","Error","triggerHuggingFaceDownloadCounter","url","URL","host","pathname","startsWith","baseUrl","protocol","fetch","method","fetchResource","source","callback","fromModule","fileUri","exists","intermediates","includes","asset","fileUriWithType","type","downloadAsync","from","localUri","to","cacheFileUri","downloadResumable","sessionType","BACKGROUND","totalBytesWritten","totalBytesExpectedToWrite","result","status","calculateDownloadProgres","numberOfFiles","currentFileIndex","setProgress","progress","contributionPerFile","baseProgress","scaledProgress","updatedProgress"],"sourceRoot":"../../../src","sources":["utils/fetchResource.ts"],"mappings":";;AAAA,SACEA,cAAc,EACdC,uBAAuB,EACvBC,YAAY,EACZC,kBAAkB,EAClBC,SAAS,EACTC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,KAAK,QAAQ,YAAY;AAClC,SAASC,YAAY,QAAQ,0BAA0B;AAEvD,MAAMC,kBAAkB,GAAIC,GAAW,IAAK;EAC1C,MAAMC,QAAQ,GAAGD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,EAAED,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EACpD,IAAI,CAACD,QAAQ,EAAE;IACb,MAAM,IAAIG,KAAK,CAAC,iCAAiC,CAAC;EACpD;EACA,OAAOH,QAAQ;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMI,iCAAiC,GAAIL,GAAW,IAAK;EACzD,MAAMM,GAAG,GAAG,IAAIC,GAAG,CAACP,GAAG,CAAC;EACxB,IACEM,GAAG,CAACE,IAAI,KAAK,gBAAgB,IAC7BF,GAAG,CAACG,QAAQ,CAACC,UAAU,CAAC,oBAAoB,CAAC,EAC7C;I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;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { readDirectoryAsync } from 'expo-file-system';
|
|
4
|
-
import { RNEDirectory } from '../constants/directories';
|
|
5
|
-
export const listDownloadedFiles = async () => {
|
|
6
|
-
const files = await readDirectoryAsync(RNEDirectory);
|
|
7
|
-
return files.map(file => `${RNEDirectory}${file}`);
|
|
8
|
-
};
|
|
9
|
-
export const listDownloadedModels = async () => {
|
|
10
|
-
const files = await listDownloadedFiles();
|
|
11
|
-
return files.filter(file => file.endsWith('.pte'));
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=listDownloadedResources.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["readDirectoryAsync","RNEDirectory","listDownloadedFiles","files","map","file","listDownloadedModels","filter","endsWith"],"sourceRoot":"../../../src","sources":["utils/listDownloadedResources.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,kBAAkB;AACrD,SAASC,YAAY,QAAQ,0BAA0B;AAEvD,OAAO,MAAMC,mBAAmB,GAAG,MAAAA,CAAA,KAAY;EAC7C,MAAMC,KAAK,GAAG,MAAMH,kBAAkB,CAACC,YAAY,CAAC;EACpD,OAAOE,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,GAAGJ,YAAY,GAAGI,IAAI,EAAE,CAAC;AACtD,CAAC;AAED,OAAO,MAAMC,oBAAoB,GAAG,MAAAA,CAAA,KAAY;EAC9C,MAAMH,KAAK,GAAG,MAAMD,mBAAmB,CAAC,CAAC;EACzC,OAAOC,KAAK,CAACI,MAAM,CAAEF,IAAI,IAAKA,IAAI,CAACG,QAAQ,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"llamaDefaults.d.ts","sourceRoot":"","sources":["../../../src/constants/llamaDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,eAAO,MAAM,qBAAqB,kRAC+O,CAAC;AAElR,eAAO,MAAM,uBAAuB,EAAE,WAAW,EAAO,CAAC;AAEzD,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,eAAO,MAAM,SAAS,eAAe,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseModule } from '../BaseModule';
|
|
2
|
-
import { _StyleTransferModule, _ObjectDetectionModule, _ClassificationModule } from '../../native/RnExecutorchModules';
|
|
3
|
-
export declare class BaseCVModule extends BaseModule {
|
|
4
|
-
static module: _StyleTransferModule | _ObjectDetectionModule | _ClassificationModule;
|
|
5
|
-
static forward(input: string): Promise<string | {
|
|
6
|
-
[category: string]: number;
|
|
7
|
-
} | import("../..").Detection[]>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=BaseCVModule.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCVModule.d.ts","sourceRoot":"","sources":["../../../../src/modules/computer_vision/BaseCVModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,kCAAkC,CAAC;AAG1C,qBAAa,YAAa,SAAQ,UAAU;IAC1C,MAAM,CAAC,MAAM,EACT,oBAAoB,GACpB,sBAAsB,GACtB,qBAAqB,CAAC;WAEb,OAAO,CAAC,KAAK,EAAE,MAAM;;;CAOnC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object_detection.d.ts","sourceRoot":"","sources":["../../../src/types/object_detection.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,M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ACV,YAAY,KAAK;IACjB,GAAG,KAAK;IACR,MAAM,KAAK;IACX,YAAY,KAAK;IACjB,MAAM,KAAK;IACX,IAAI,KAAK;IACT,MAAM,KAAK;IACX,IAAI,KAAK;IACT,EAAE,KAAK;IACP,MAAM,KAAK;IACX,KAAK,KAAK;IACV,MAAM,KAAK;IACX,QAAQ,KAAK;IACb,UAAU,KAAK;IACf,SAAS,KAAK;IACd,IAAI,KAAK;IACT,OAAO,KAAK;IACZ,IAAI,KAAK;IACT,YAAY,KAAK;IACjB,OAAO,KAAK;IACZ,IAAI,KAAK;IACT,KAAK,KAAK;IACV,IAAI,KAAK;IACT,QAAQ,KAAK;IACb,UAAU,KAAK;IACf,UAAU,KAAK;IACf,UAAU,KAAK;IACf,UAAU,KAAK;CAChB"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const fetchResource: (source: string | number, callback?: (downloadProgress: number) => void) => Promise<string>;
|
|
2
|
-
export declare const calculateDownloadProgres: (numberOfFiles: number, currentFileIndex: number, setProgress: (downloadProgress: number) => void) => (progress: number) => void;
|
|
3
|
-
//# sourceMappingURL=fetchResource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchResource.d.ts","sourceRoot":"","sources":["../../../src/utils/fetchResource.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,GAAG,MAAM,EACvB,WAAU,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAe,oBAmDxD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAEjC,eAAe,MAAM,EACrB,kBAAkB,MAAM,EACxB,aAAa,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,MAEhD,UAAU,MAAM,SAUhB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listDownloadedResources.d.ts","sourceRoot":"","sources":["../../../src/utils/listDownloadedResources.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,yBAG/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,yBAGhC,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MessageType } from '../types/common';
|
|
2
|
-
|
|
3
|
-
export const DEFAULT_SYSTEM_PROMPT =
|
|
4
|
-
"You are a knowledgeable, efficient, and direct AI assistant. Provide concise answers, focusing on the key information needed. Offer suggestions tactfully when appropriate to improve outcomes. Engage in productive collaboration with the user. Don't return too much text.";
|
|
5
|
-
|
|
6
|
-
export const DEFAULT_MESSAGE_HISTORY: MessageType[] = [];
|
|
7
|
-
|
|
8
|
-
export const DEFAULT_CONTEXT_WINDOW_LENGTH = 3;
|
|
9
|
-
export const EOT_TOKEN = '<|eot_id|>';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseModule } from '../BaseModule';
|
|
2
|
-
import {
|
|
3
|
-
_StyleTransferModule,
|
|
4
|
-
_ObjectDetectionModule,
|
|
5
|
-
_ClassificationModule,
|
|
6
|
-
} from '../../native/RnExecutorchModules';
|
|
7
|
-
import { getError } from '../../Error';
|
|
8
|
-
|
|
9
|
-
export class BaseCVModule extends BaseModule {
|
|
10
|
-
static module:
|
|
11
|
-
| _StyleTransferModule
|
|
12
|
-
| _ObjectDetectionModule
|
|
13
|
-
| _ClassificationModule;
|
|
14
|
-
|
|
15
|
-
static async forward(input: string) {
|
|
16
|
-
try {
|
|
17
|
-
return await this.module.forward(input);
|
|
18
|
-
} catch (e) {
|
|
19
|
-
throw new Error(getError(e));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cacheDirectory,
|
|
3
|
-
createDownloadResumable,
|
|
4
|
-
getInfoAsync,
|
|
5
|
-
makeDirectoryAsync,
|
|
6
|
-
moveAsync,
|
|
7
|
-
FileSystemSessionType,
|
|
8
|
-
} from 'expo-file-system';
|
|
9
|
-
import { Asset } from 'expo-asset';
|
|
10
|
-
import { RNEDirectory } from '../constants/directories';
|
|
11
|
-
|
|
12
|
-
const getFilenameFromUri = (uri: string) => {
|
|
13
|
-
const filename = uri.split('/').pop()?.split('?')[0];
|
|
14
|
-
if (!filename) {
|
|
15
|
-
throw new Error('Cannot derive filename from URI');
|
|
16
|
-
}
|
|
17
|
-
return filename;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Increments the Hugging Face download counter if the URI points to a Software Mansion Hugging Face repo.
|
|
22
|
-
* More information: https://huggingface.co/docs/hub/models-download-stats
|
|
23
|
-
*/
|
|
24
|
-
const triggerHuggingFaceDownloadCounter = (uri: string) => {
|
|
25
|
-
const url = new URL(uri);
|
|
26
|
-
if (
|
|
27
|
-
url.host === 'huggingface.co' &&
|
|
28
|
-
url.pathname.startsWith('/software-mansion/')
|
|
29
|
-
) {
|
|
30
|
-
const baseUrl = `${url.protocol}//${url.host}${url.pathname.split('resolve')[0]}`;
|
|
31
|
-
fetch(`${baseUrl}resolve/main/config.json`, { method: 'HEAD' });
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const fetchResource = async (
|
|
36
|
-
source: string | number,
|
|
37
|
-
callback: (downloadProgress: number) => void = () => {}
|
|
38
|
-
) => {
|
|
39
|
-
const uri =
|
|
40
|
-
typeof source === 'number' ? Asset.fromModule(source).uri : source;
|
|
41
|
-
|
|
42
|
-
// Handle local files
|
|
43
|
-
if (uri.startsWith('file://')) {
|
|
44
|
-
return uri;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const filename = getFilenameFromUri(uri);
|
|
48
|
-
const fileUri = `${RNEDirectory}${filename}`;
|
|
49
|
-
|
|
50
|
-
// Check if the file already exists
|
|
51
|
-
if ((await getInfoAsync(fileUri)).exists) {
|
|
52
|
-
return fileUri;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Create the RNEDirectory if it doesn't exist
|
|
56
|
-
if (!(await getInfoAsync(RNEDirectory)).exists) {
|
|
57
|
-
await makeDirectoryAsync(RNEDirectory, { intermediates: true });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Handle local asset files in release mode
|
|
61
|
-
if (!uri.includes('://')) {
|
|
62
|
-
const asset = Asset.fromModule(source);
|
|
63
|
-
const fileUriWithType = `${fileUri}.${asset.type}`;
|
|
64
|
-
await asset.downloadAsync();
|
|
65
|
-
await moveAsync({ from: asset.localUri!, to: fileUriWithType });
|
|
66
|
-
return fileUriWithType;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Handle remote file download
|
|
70
|
-
const cacheFileUri = `${cacheDirectory}${filename}`;
|
|
71
|
-
const downloadResumable = createDownloadResumable(
|
|
72
|
-
uri,
|
|
73
|
-
cacheFileUri,
|
|
74
|
-
{ sessionType: FileSystemSessionType.BACKGROUND },
|
|
75
|
-
({ totalBytesWritten, totalBytesExpectedToWrite }) => {
|
|
76
|
-
callback(totalBytesWritten / totalBytesExpectedToWrite);
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
const result = await downloadResumable.downloadAsync();
|
|
80
|
-
if (!result || result.status !== 200) {
|
|
81
|
-
throw new Error(`Failed to fetch resource from '${uri}'`);
|
|
82
|
-
}
|
|
83
|
-
await moveAsync({ from: cacheFileUri, to: fileUri });
|
|
84
|
-
|
|
85
|
-
triggerHuggingFaceDownloadCounter(uri);
|
|
86
|
-
|
|
87
|
-
return fileUri;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const calculateDownloadProgres =
|
|
91
|
-
(
|
|
92
|
-
numberOfFiles: number,
|
|
93
|
-
currentFileIndex: number,
|
|
94
|
-
setProgress: (downloadProgress: number) => void
|
|
95
|
-
) =>
|
|
96
|
-
(progress: number) => {
|
|
97
|
-
if (progress === 1 && currentFileIndex === numberOfFiles - 1) {
|
|
98
|
-
setProgress(1);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const contributionPerFile = 1 / numberOfFiles;
|
|
102
|
-
const baseProgress = contributionPerFile * currentFileIndex;
|
|
103
|
-
const scaledProgress = progress * contributionPerFile;
|
|
104
|
-
const updatedProgress = baseProgress + scaledProgress;
|
|
105
|
-
setProgress(updatedProgress);
|
|
106
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { readDirectoryAsync } from 'expo-file-system';
|
|
2
|
-
import { RNEDirectory } from '../constants/directories';
|
|
3
|
-
|
|
4
|
-
export const listDownloadedFiles = async () => {
|
|
5
|
-
const files = await readDirectoryAsync(RNEDirectory);
|
|
6
|
-
return files.map((file) => `${RNEDirectory}${file}`);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const listDownloadedModels = async () => {
|
|
10
|
-
const files = await listDownloadedFiles();
|
|
11
|
-
return files.filter((file) => file.endsWith('.pte'));
|
|
12
|
-
};
|
|
File without changes
|