react-native-executorch 0.7.0-nightly-b4770df-20260205 → 0.7.0
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/common/rnexecutorch/ErrorCodes.h +15 -30
- package/common/rnexecutorch/host_objects/ModelHostObject.h +5 -0
- package/common/rnexecutorch/models/llm/LLM.cpp +7 -0
- package/common/rnexecutorch/models/llm/LLM.h +1 -0
- package/lib/module/constants/llmDefaults.js +31 -0
- package/lib/module/constants/llmDefaults.js.map +1 -1
- package/lib/module/constants/modelUrls.js +220 -0
- package/lib/module/constants/modelUrls.js.map +1 -1
- package/lib/module/constants/ocr/models.js +255 -73
- package/lib/module/constants/ocr/models.js.map +1 -1
- package/lib/module/constants/ocr/symbols.js +4 -0
- package/lib/module/constants/ocr/symbols.js.map +1 -1
- package/lib/module/constants/tts/models.js +6 -2
- package/lib/module/constants/tts/models.js.map +1 -1
- package/lib/module/constants/tts/voices.js +27 -3
- package/lib/module/constants/tts/voices.js.map +1 -1
- package/lib/module/constants/versions.js +2 -2
- package/lib/module/controllers/LLMController.js +9 -0
- package/lib/module/controllers/LLMController.js.map +1 -1
- package/lib/module/errors/ErrorCodes.js +54 -0
- package/lib/module/errors/ErrorCodes.js.map +1 -1
- package/lib/module/errors/errorUtils.js +30 -6
- package/lib/module/errors/errorUtils.js.map +1 -1
- package/lib/module/hooks/computer_vision/useClassification.js +7 -0
- package/lib/module/hooks/computer_vision/useClassification.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageEmbeddings.js +8 -0
- package/lib/module/hooks/computer_vision/useImageEmbeddings.js.map +1 -1
- package/lib/module/hooks/computer_vision/useImageSegmentation.js +7 -0
- package/lib/module/hooks/computer_vision/useImageSegmentation.js.map +1 -1
- package/lib/module/hooks/computer_vision/useOCR.js +7 -0
- package/lib/module/hooks/computer_vision/useOCR.js.map +1 -1
- package/lib/module/hooks/computer_vision/useObjectDetection.js +7 -0
- package/lib/module/hooks/computer_vision/useObjectDetection.js.map +1 -1
- package/lib/module/hooks/computer_vision/useStyleTransfer.js +7 -0
- package/lib/module/hooks/computer_vision/useStyleTransfer.js.map +1 -1
- package/lib/module/hooks/computer_vision/useTextToImage.js +7 -0
- package/lib/module/hooks/computer_vision/useTextToImage.js.map +1 -1
- package/lib/module/hooks/computer_vision/useVerticalOCR.js +7 -0
- package/lib/module/hooks/computer_vision/useVerticalOCR.js.map +1 -1
- package/lib/module/hooks/general/useExecutorchModule.js +8 -0
- package/lib/module/hooks/general/useExecutorchModule.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useLLM.js +11 -3
- package/lib/module/hooks/natural_language_processing/useLLM.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useSpeechToText.js +8 -0
- package/lib/module/hooks/natural_language_processing/useSpeechToText.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js +7 -0
- package/lib/module/hooks/natural_language_processing/useTextEmbeddings.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTextToSpeech.js +8 -0
- package/lib/module/hooks/natural_language_processing/useTextToSpeech.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useTokenizer.js +7 -0
- package/lib/module/hooks/natural_language_processing/useTokenizer.js.map +1 -1
- package/lib/module/hooks/natural_language_processing/useVAD.js +7 -0
- package/lib/module/hooks/natural_language_processing/useVAD.js.map +1 -1
- package/lib/module/hooks/useModule.js +12 -0
- package/lib/module/hooks/useModule.js.map +1 -1
- package/lib/module/index.js +10 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/BaseModule.js +22 -0
- package/lib/module/modules/BaseModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ClassificationModule.js +20 -0
- package/lib/module/modules/computer_vision/ClassificationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js +19 -0
- package/lib/module/modules/computer_vision/ImageEmbeddingsModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js +22 -0
- package/lib/module/modules/computer_vision/ImageSegmentationModule.js.map +1 -1
- package/lib/module/modules/computer_vision/OCRModule.js +26 -0
- package/lib/module/modules/computer_vision/OCRModule.js.map +1 -1
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js +22 -0
- package/lib/module/modules/computer_vision/ObjectDetectionModule.js.map +1 -1
- package/lib/module/modules/computer_vision/StyleTransferModule.js +20 -0
- package/lib/module/modules/computer_vision/StyleTransferModule.js.map +1 -1
- package/lib/module/modules/computer_vision/TextToImageModule.js +33 -0
- package/lib/module/modules/computer_vision/TextToImageModule.js.map +1 -1
- package/lib/module/modules/computer_vision/VerticalOCRModule.js +27 -0
- package/lib/module/modules/computer_vision/VerticalOCRModule.js.map +1 -1
- package/lib/module/modules/general/ExecutorchModule.js +21 -0
- package/lib/module/modules/general/ExecutorchModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/LLMModule.js +104 -0
- package/lib/module/modules/natural_language_processing/LLMModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js +67 -21
- package/lib/module/modules/natural_language_processing/SpeechToTextModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js +21 -0
- package/lib/module/modules/natural_language_processing/TextEmbeddingsModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/TextToSpeechModule.js +40 -0
- package/lib/module/modules/natural_language_processing/TextToSpeechModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/TokenizerModule.js +54 -2
- package/lib/module/modules/natural_language_processing/TokenizerModule.js.map +1 -1
- package/lib/module/modules/natural_language_processing/VADModule.js +20 -0
- package/lib/module/modules/natural_language_processing/VADModule.js.map +1 -1
- package/lib/module/types/classification.js +4 -0
- package/lib/module/types/classification.js.map +1 -0
- package/lib/module/types/common.js +96 -0
- package/lib/module/types/common.js.map +1 -1
- package/lib/module/types/executorchModule.js +4 -0
- package/lib/module/types/executorchModule.js.map +1 -0
- package/lib/module/types/imageEmbeddings.js +4 -0
- package/lib/module/types/imageEmbeddings.js.map +1 -0
- package/lib/module/types/imageSegmentation.js +22 -1
- package/lib/module/types/imageSegmentation.js.map +1 -1
- package/lib/module/types/llm.js +80 -2
- package/lib/module/types/llm.js.map +1 -1
- package/lib/module/types/objectDetection.js +42 -2
- package/lib/module/types/objectDetection.js.map +1 -1
- package/lib/module/types/styleTransfer.js +4 -0
- package/lib/module/types/styleTransfer.js.map +1 -0
- package/lib/module/types/textEmbeddings.js +4 -0
- package/lib/module/types/textEmbeddings.js.map +1 -0
- package/lib/module/types/tokenizer.js +4 -0
- package/lib/module/types/tokenizer.js.map +1 -0
- package/lib/module/types/tti.js +4 -0
- package/lib/module/types/tti.js.map +1 -0
- package/lib/module/types/vad.js +2 -0
- package/lib/module/utils/ResourceFetcher.js +63 -0
- package/lib/module/utils/ResourceFetcher.js.map +1 -1
- package/lib/module/utils/llm.js +24 -1
- package/lib/module/utils/llm.js.map +1 -1
- package/lib/typescript/constants/llmDefaults.d.ts +27 -0
- package/lib/typescript/constants/llmDefaults.d.ts.map +1 -1
- package/lib/typescript/constants/modelUrls.d.ts +165 -0
- package/lib/typescript/constants/modelUrls.d.ts.map +1 -1
- package/lib/typescript/constants/ocr/models.d.ts +189 -315
- package/lib/typescript/constants/ocr/models.d.ts.map +1 -1
- package/lib/typescript/constants/ocr/symbols.d.ts +3 -0
- package/lib/typescript/constants/ocr/symbols.d.ts.map +1 -1
- package/lib/typescript/constants/tts/models.d.ts +4 -0
- package/lib/typescript/constants/tts/models.d.ts.map +1 -1
- package/lib/typescript/constants/tts/voices.d.ts +24 -0
- package/lib/typescript/constants/tts/voices.d.ts.map +1 -1
- package/lib/typescript/constants/versions.d.ts +2 -2
- package/lib/typescript/controllers/LLMController.d.ts +2 -0
- package/lib/typescript/controllers/LLMController.d.ts.map +1 -1
- package/lib/typescript/errors/ErrorCodes.d.ts +54 -0
- package/lib/typescript/errors/ErrorCodes.d.ts.map +1 -1
- package/lib/typescript/errors/errorUtils.d.ts +9 -0
- package/lib/typescript/errors/errorUtils.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useClassification.d.ts +9 -15
- package/lib/typescript/hooks/computer_vision/useClassification.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts +9 -15
- package/lib/typescript/hooks/computer_vision/useImageEmbeddings.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts +9 -38
- package/lib/typescript/hooks/computer_vision/useImageSegmentation.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts +9 -19
- package/lib/typescript/hooks/computer_vision/useOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts +9 -15
- package/lib/typescript/hooks/computer_vision/useObjectDetection.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts +9 -15
- package/lib/typescript/hooks/computer_vision/useStyleTransfer.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts +9 -22
- package/lib/typescript/hooks/computer_vision/useTextToImage.d.ts.map +1 -1
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts +9 -20
- package/lib/typescript/hooks/computer_vision/useVerticalOCR.d.ts.map +1 -1
- package/lib/typescript/hooks/general/useExecutorchModule.d.ts +9 -13
- package/lib/typescript/hooks/general/useExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts +9 -10
- package/lib/typescript/hooks/natural_language_processing/useLLM.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts +9 -19
- package/lib/typescript/hooks/natural_language_processing/useSpeechToText.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts +9 -16
- package/lib/typescript/hooks/natural_language_processing/useTextEmbeddings.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useTextToSpeech.d.ts +9 -15
- package/lib/typescript/hooks/natural_language_processing/useTextToSpeech.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts +9 -18
- package/lib/typescript/hooks/natural_language_processing/useTokenizer.d.ts.map +1 -1
- package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts +9 -15
- package/lib/typescript/hooks/natural_language_processing/useVAD.d.ts.map +1 -1
- package/lib/typescript/hooks/useModule.d.ts +12 -0
- package/lib/typescript/hooks/useModule.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +10 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/modules/BaseModule.d.ts +20 -0
- package/lib/typescript/modules/BaseModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts +21 -1
- package/lib/typescript/modules/computer_vision/ClassificationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts +17 -0
- package/lib/typescript/modules/computer_vision/ImageEmbeddingsModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts +21 -3
- package/lib/typescript/modules/computer_vision/ImageSegmentationModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/OCRModule.d.ts +25 -2
- package/lib/typescript/modules/computer_vision/OCRModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts +20 -0
- package/lib/typescript/modules/computer_vision/ObjectDetectionModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts +18 -0
- package/lib/typescript/modules/computer_vision/StyleTransferModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts +29 -0
- package/lib/typescript/modules/computer_vision/TextToImageModule.d.ts.map +1 -1
- package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts +26 -2
- package/lib/typescript/modules/computer_vision/VerticalOCRModule.d.ts.map +1 -1
- package/lib/typescript/modules/general/ExecutorchModule.d.ts +19 -0
- package/lib/typescript/modules/general/ExecutorchModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts +97 -7
- package/lib/typescript/modules/natural_language_processing/LLMModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts +62 -4
- package/lib/typescript/modules/natural_language_processing/SpeechToTextModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts +19 -0
- package/lib/typescript/modules/natural_language_processing/TextEmbeddingsModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/TextToSpeechModule.d.ts +37 -2
- package/lib/typescript/modules/natural_language_processing/TextToSpeechModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts +47 -2
- package/lib/typescript/modules/natural_language_processing/TokenizerModule.d.ts.map +1 -1
- package/lib/typescript/modules/natural_language_processing/VADModule.d.ts +18 -0
- package/lib/typescript/modules/natural_language_processing/VADModule.d.ts.map +1 -1
- package/lib/typescript/types/classification.d.ts +50 -0
- package/lib/typescript/types/classification.d.ts.map +1 -0
- package/lib/typescript/types/common.d.ts +92 -0
- package/lib/typescript/types/common.d.ts.map +1 -1
- package/lib/typescript/types/executorchModule.d.ts +45 -0
- package/lib/typescript/types/executorchModule.d.ts.map +1 -0
- package/lib/typescript/types/imageEmbeddings.d.ts +48 -0
- package/lib/typescript/types/imageEmbeddings.d.ts.map +1 -0
- package/lib/typescript/types/imageSegmentation.d.ts +55 -0
- package/lib/typescript/types/imageSegmentation.d.ts.map +1 -1
- package/lib/typescript/types/llm.d.ts +193 -5
- package/lib/typescript/types/llm.d.ts.map +1 -1
- package/lib/typescript/types/objectDetection.d.ts +71 -2
- package/lib/typescript/types/objectDetection.d.ts.map +1 -1
- package/lib/typescript/types/ocr.d.ts +97 -2
- package/lib/typescript/types/ocr.d.ts.map +1 -1
- package/lib/typescript/types/stt.d.ts +114 -0
- package/lib/typescript/types/stt.d.ts.map +1 -1
- package/lib/typescript/types/styleTransfer.d.ts +48 -0
- package/lib/typescript/types/styleTransfer.d.ts.map +1 -0
- package/lib/typescript/types/textEmbeddings.d.ts +53 -0
- package/lib/typescript/types/textEmbeddings.d.ts.map +1 -0
- package/lib/typescript/types/tokenizer.d.ts +75 -0
- package/lib/typescript/types/tokenizer.d.ts.map +1 -0
- package/lib/typescript/types/tti.d.ts +74 -0
- package/lib/typescript/types/tti.d.ts.map +1 -0
- package/lib/typescript/types/tts.d.ts +77 -0
- package/lib/typescript/types/tts.d.ts.map +1 -1
- package/lib/typescript/types/vad.d.ts +53 -0
- package/lib/typescript/types/vad.d.ts.map +1 -1
- package/lib/typescript/utils/ResourceFetcher.d.ts +55 -0
- package/lib/typescript/utils/ResourceFetcher.d.ts.map +1 -1
- package/lib/typescript/utils/llm.d.ts +22 -0
- package/lib/typescript/utils/llm.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants/llmDefaults.ts +27 -0
- package/src/constants/modelUrls.ts +166 -0
- package/src/constants/ocr/models.ts +192 -266
- package/src/constants/ocr/symbols.ts +3 -0
- package/src/constants/tts/models.ts +6 -2
- package/src/constants/tts/voices.ts +27 -3
- package/src/constants/versions.ts +2 -2
- package/src/controllers/LLMController.ts +15 -0
- package/src/errors/ErrorCodes.ts +54 -0
- package/src/errors/errorUtils.ts +37 -17
- package/src/hooks/computer_vision/useClassification.ts +15 -7
- package/src/hooks/computer_vision/useImageEmbeddings.ts +15 -7
- package/src/hooks/computer_vision/useImageSegmentation.ts +15 -7
- package/src/hooks/computer_vision/useOCR.ts +9 -21
- package/src/hooks/computer_vision/useObjectDetection.ts +15 -7
- package/src/hooks/computer_vision/useStyleTransfer.ts +15 -7
- package/src/hooks/computer_vision/useTextToImage.ts +9 -26
- package/src/hooks/computer_vision/useVerticalOCR.ts +9 -19
- package/src/hooks/general/useExecutorchModule.ts +12 -7
- package/src/hooks/natural_language_processing/useLLM.ts +24 -28
- package/src/hooks/natural_language_processing/useSpeechToText.ts +13 -5
- package/src/hooks/natural_language_processing/useTextEmbeddings.ts +15 -10
- package/src/hooks/natural_language_processing/useTextToSpeech.ts +10 -6
- package/src/hooks/natural_language_processing/useTokenizer.ts +10 -6
- package/src/hooks/natural_language_processing/useVAD.ts +9 -7
- package/src/hooks/useModule.ts +15 -0
- package/src/index.ts +10 -5
- package/src/modules/BaseModule.ts +20 -0
- package/src/modules/computer_vision/ClassificationModule.ts +19 -1
- package/src/modules/computer_vision/ImageEmbeddingsModule.ts +17 -0
- package/src/modules/computer_vision/ImageSegmentationModule.ts +21 -1
- package/src/modules/computer_vision/OCRModule.ts +25 -2
- package/src/modules/computer_vision/ObjectDetectionModule.ts +20 -0
- package/src/modules/computer_vision/StyleTransferModule.ts +18 -0
- package/src/modules/computer_vision/TextToImageModule.ts +29 -0
- package/src/modules/computer_vision/VerticalOCRModule.ts +26 -2
- package/src/modules/general/ExecutorchModule.ts +19 -0
- package/src/modules/natural_language_processing/LLMModule.ts +104 -18
- package/src/modules/natural_language_processing/SpeechToTextModule.ts +63 -39
- package/src/modules/natural_language_processing/TextEmbeddingsModule.ts +19 -0
- package/src/modules/natural_language_processing/TextToSpeechModule.ts +43 -2
- package/src/modules/natural_language_processing/TokenizerModule.ts +51 -3
- package/src/modules/natural_language_processing/VADModule.ts +18 -0
- package/src/types/classification.ts +51 -0
- package/src/types/common.ts +93 -0
- package/src/types/executorchModule.ts +50 -0
- package/src/types/imageEmbeddings.ts +51 -0
- package/src/types/imageSegmentation.ts +64 -1
- package/src/types/llm.ts +208 -11
- package/src/types/objectDetection.ts +79 -1
- package/src/types/ocr.ts +107 -2
- package/src/types/stt.ts +136 -1
- package/src/types/styleTransfer.ts +51 -0
- package/src/types/textEmbeddings.ts +58 -0
- package/src/types/tokenizer.ts +86 -0
- package/src/types/tti.ts +87 -0
- package/src/types/tts.ts +85 -2
- package/src/types/vad.ts +58 -0
- package/src/utils/ResourceFetcher.ts +55 -0
- package/src/utils/llm.ts +22 -1
package/src/types/vad.ts
CHANGED
|
@@ -1,4 +1,62 @@
|
|
|
1
|
+
import { ResourceSource } from '../types/common';
|
|
2
|
+
import { RnExecutorchError } from '../errors/errorUtils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props for the useVAD hook.
|
|
6
|
+
*
|
|
7
|
+
* @category Types
|
|
8
|
+
* @property {Object} model - An object containing the model source.
|
|
9
|
+
* @property {ResourceSource} model.modelSource - The source of the VAD model binary.
|
|
10
|
+
* @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook.
|
|
11
|
+
*/
|
|
12
|
+
export interface VADProps {
|
|
13
|
+
model: { modelSource: ResourceSource };
|
|
14
|
+
preventLoad?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents a detected audio segment with start and end timestamps.
|
|
19
|
+
*
|
|
20
|
+
* @category Types
|
|
21
|
+
* @property {number} start - Start time of the segment in seconds.
|
|
22
|
+
* @property {number} end - End time of the segment in seconds.
|
|
23
|
+
*/
|
|
1
24
|
export interface Segment {
|
|
2
25
|
start: number;
|
|
3
26
|
end: number;
|
|
4
27
|
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* React hook state and methods for managing a Voice Activity Detection (VAD) model instance.
|
|
31
|
+
*
|
|
32
|
+
* @category Types
|
|
33
|
+
*/
|
|
34
|
+
export interface VADType {
|
|
35
|
+
/**
|
|
36
|
+
* Contains the error message if the VAD model failed to load or during processing.
|
|
37
|
+
*/
|
|
38
|
+
error: null | RnExecutorchError;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Indicates whether the VAD model has successfully loaded and is ready for inference.
|
|
42
|
+
*/
|
|
43
|
+
isReady: boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Indicates whether the model is currently processing an inference.
|
|
47
|
+
*/
|
|
48
|
+
isGenerating: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Represents the download progress as a value between 0 and 1.
|
|
52
|
+
*/
|
|
53
|
+
downloadProgress: number;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Runs the Voice Activity Detection model on the provided audio waveform.
|
|
57
|
+
* @param waveform - The input audio waveform array.
|
|
58
|
+
* @returns A promise resolving to an array of detected audio segments (e.g., timestamps for speech).
|
|
59
|
+
* @throws {RnExecutorchError} If the model is not loaded or is currently processing another request.
|
|
60
|
+
*/
|
|
61
|
+
forward(waveform: Float32Array): Promise<Segment[]>;
|
|
62
|
+
}
|
|
@@ -54,9 +54,23 @@ import {
|
|
|
54
54
|
import { RnExecutorchErrorCode } from '../errors/ErrorCodes';
|
|
55
55
|
import { RnExecutorchError } from '../errors/errorUtils';
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* This module provides functions to download and work with downloaded files stored in the application's document directory inside the `react-native-executorch/` directory.
|
|
59
|
+
* These utilities can help you manage your storage and clean up the downloaded files when they are no longer needed.
|
|
60
|
+
*
|
|
61
|
+
* @category Utilities - General
|
|
62
|
+
*/
|
|
57
63
|
export class ResourceFetcher {
|
|
58
64
|
static downloads = new Map<ResourceSource, DownloadResource>(); //map of currently downloading (or paused) files, if the download was started by .fetch() method.
|
|
59
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Fetches resources (remote URLs, local files or embedded assets), downloads or stores them locally for use by React Native ExecuTorch.
|
|
68
|
+
*
|
|
69
|
+
* @param callback - Optional callback to track progress of all downloads, reported between 0 and 1.
|
|
70
|
+
* @param sources - Multiple resources that can be strings, asset references, or objects.
|
|
71
|
+
* @returns If the fetch was successful, it returns a promise which resolves to an array of local file paths for the downloaded/stored resources (without file:// prefix).
|
|
72
|
+
* If the fetch was interrupted by `pauseFetching` or `cancelFetching`, it returns a promise which resolves to `null`.
|
|
73
|
+
*/
|
|
60
74
|
static async fetch(
|
|
61
75
|
callback: (downloadProgress: number) => void = () => {},
|
|
62
76
|
...sources: ResourceSource[]
|
|
@@ -238,16 +252,35 @@ export class ResourceFetcher {
|
|
|
238
252
|
this.downloads.delete(source);
|
|
239
253
|
}
|
|
240
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Pauses an ongoing download of files.
|
|
257
|
+
*
|
|
258
|
+
* @param sources - The resource identifiers used when calling `fetch`.
|
|
259
|
+
* @returns A promise that resolves once the download is paused.
|
|
260
|
+
*/
|
|
241
261
|
static async pauseFetching(...sources: ResourceSource[]) {
|
|
242
262
|
const source = this.findActive(sources);
|
|
243
263
|
await this.pause(source);
|
|
244
264
|
}
|
|
245
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Resumes a paused download of files.
|
|
268
|
+
*
|
|
269
|
+
* @param sources - The resource identifiers used when calling fetch.
|
|
270
|
+
* @returns If the fetch was successful, it returns a promise which resolves to an array of local file paths for the downloaded resources (without file:// prefix).
|
|
271
|
+
* If the fetch was again interrupted by `pauseFetching` or `cancelFetching`, it returns a promise which resolves to `null`.
|
|
272
|
+
*/
|
|
246
273
|
static async resumeFetching(...sources: ResourceSource[]) {
|
|
247
274
|
const source = this.findActive(sources);
|
|
248
275
|
await this.resume(source);
|
|
249
276
|
}
|
|
250
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Cancels an ongoing/paused download of files.
|
|
280
|
+
*
|
|
281
|
+
* @param sources - The resource identifiers used when calling `fetch()`.
|
|
282
|
+
* @returns A promise that resolves once the download is canceled.
|
|
283
|
+
*/
|
|
251
284
|
static async cancelFetching(...sources: ResourceSource[]) {
|
|
252
285
|
const source = this.findActive(sources);
|
|
253
286
|
await this.cancel(source);
|
|
@@ -265,16 +298,32 @@ export class ResourceFetcher {
|
|
|
265
298
|
);
|
|
266
299
|
}
|
|
267
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Lists all the downloaded files used by React Native ExecuTorch.
|
|
303
|
+
*
|
|
304
|
+
* @returns A promise, which resolves to an array of URIs for all the downloaded files.
|
|
305
|
+
*/
|
|
268
306
|
static async listDownloadedFiles() {
|
|
269
307
|
const files = await readDirectoryAsync(RNEDirectory);
|
|
270
308
|
return files.map((file) => `${RNEDirectory}${file}`);
|
|
271
309
|
}
|
|
272
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Lists all the downloaded models used by React Native ExecuTorch.
|
|
313
|
+
*
|
|
314
|
+
* @returns A promise, which resolves to an array of URIs for all the downloaded models.
|
|
315
|
+
*/
|
|
273
316
|
static async listDownloadedModels() {
|
|
274
317
|
const files = await this.listDownloadedFiles();
|
|
275
318
|
return files.filter((file) => file.endsWith('.pte'));
|
|
276
319
|
}
|
|
277
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Deletes downloaded resources from the local filesystem.
|
|
323
|
+
*
|
|
324
|
+
* @param sources - The resource identifiers used when calling `fetch`.
|
|
325
|
+
* @returns A promise that resolves once all specified resources have been removed.
|
|
326
|
+
*/
|
|
278
327
|
static async deleteResources(...sources: ResourceSource[]) {
|
|
279
328
|
for (const source of sources) {
|
|
280
329
|
const filename = ResourceFetcherUtils.getFilenameFromUri(
|
|
@@ -287,6 +336,12 @@ export class ResourceFetcher {
|
|
|
287
336
|
}
|
|
288
337
|
}
|
|
289
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Fetches the info about files size. Works only for remote files.
|
|
341
|
+
*
|
|
342
|
+
* @param sources - The resource identifiers (URLs).
|
|
343
|
+
* @returns A promise that resolves to combined size of files in bytes.
|
|
344
|
+
*/
|
|
290
345
|
static async getFilesTotalSize(...sources: ResourceSource[]) {
|
|
291
346
|
return (await ResourceFetcherUtils.getFilesSizes(sources)).totalLength;
|
|
292
347
|
}
|
package/src/utils/llm.ts
CHANGED
|
@@ -6,6 +6,13 @@ import { DEFAULT_STRUCTURED_OUTPUT_PROMPT } from '../constants/llmDefaults';
|
|
|
6
6
|
import * as zCore from 'zod/v4/core';
|
|
7
7
|
import { Logger } from '../common/Logger';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Parses tool calls from a given message string.
|
|
11
|
+
*
|
|
12
|
+
* @category Utilities - LLM
|
|
13
|
+
* @param message - The message string containing tool calls in JSON format.
|
|
14
|
+
* @returns An array of `ToolCall` objects extracted from the message.
|
|
15
|
+
*/
|
|
9
16
|
export const parseToolCall: (message: string) => ToolCall[] = (
|
|
10
17
|
message: string
|
|
11
18
|
) => {
|
|
@@ -47,6 +54,13 @@ const filterObjectKeys = (obj: object, keysToRemove: string[]) => {
|
|
|
47
54
|
return Object.fromEntries(filteredEntries);
|
|
48
55
|
};
|
|
49
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Generates a structured output prompt based on the provided schema.
|
|
59
|
+
*
|
|
60
|
+
* @category Utilities - LLM
|
|
61
|
+
* @param responseSchema - The schema (Zod or JSON Schema) defining the desired output format.
|
|
62
|
+
* @returns A prompt string instructing the model to format its output according to the given schema.
|
|
63
|
+
*/
|
|
50
64
|
export const getStructuredOutputPrompt = <T extends zCore.$ZodType>(
|
|
51
65
|
responseSchema: T | Schema
|
|
52
66
|
) => {
|
|
@@ -77,7 +91,14 @@ const extractBetweenBrackets = (text: string): string => {
|
|
|
77
91
|
);
|
|
78
92
|
};
|
|
79
93
|
|
|
80
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Fixes and validates structured output from LLMs against a provided schema.
|
|
96
|
+
*
|
|
97
|
+
* @category Utilities - LLM
|
|
98
|
+
* @param output - The raw output string from the LLM.
|
|
99
|
+
* @param responseSchema - The schema (Zod or JSON Schema) to validate the output against.
|
|
100
|
+
* @returns The validated and parsed output.
|
|
101
|
+
*/
|
|
81
102
|
export const fixAndValidateStructuredOutput = <T extends zCore.$ZodType>(
|
|
82
103
|
output: string,
|
|
83
104
|
responseSchema: T | Schema
|