@inferrlm/react-native-mlx 0.4.0 → 0.4.2-alpha.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/MLXReactNative.podspec +1 -1
- package/ios/Sources/HybridLLM.swift +44 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/llm.js +193 -0
- package/lib/module/llm.js.map +1 -0
- package/lib/module/modelManager.js +79 -0
- package/lib/module/modelManager.js.map +1 -0
- package/lib/module/models.js +360 -0
- package/lib/module/models.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/specs/LLM.nitro.js +4 -0
- package/lib/module/specs/LLM.nitro.js.map +1 -0
- package/lib/module/specs/ModelManager.nitro.js +4 -0
- package/lib/module/specs/ModelManager.nitro.js.map +1 -0
- package/lib/module/specs/STT.nitro.js +4 -0
- package/lib/module/specs/STT.nitro.js.map +1 -0
- package/lib/module/specs/TTS.nitro.js +4 -0
- package/lib/module/specs/TTS.nitro.js.map +1 -0
- package/lib/module/stt.js +49 -0
- package/lib/module/stt.js.map +1 -0
- package/lib/module/tool-utils.js +56 -0
- package/lib/module/tool-utils.js.map +1 -0
- package/lib/module/tts.js +40 -0
- package/lib/module/tts.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/llm.d.ts +129 -0
- package/lib/typescript/src/llm.d.ts.map +1 -0
- package/lib/typescript/src/modelManager.d.ts +53 -0
- package/lib/typescript/src/modelManager.d.ts.map +1 -0
- package/lib/typescript/src/models.d.ts +67 -0
- package/lib/typescript/src/models.d.ts.map +1 -0
- package/lib/typescript/src/specs/LLM.nitro.d.ts +160 -0
- package/lib/typescript/src/specs/LLM.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/ModelManager.nitro.d.ts +41 -0
- package/lib/typescript/src/specs/ModelManager.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/STT.nitro.d.ts +28 -0
- package/lib/typescript/src/specs/STT.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/TTS.nitro.d.ts +22 -0
- package/lib/typescript/src/specs/TTS.nitro.d.ts.map +1 -0
- package/lib/typescript/src/stt.d.ts +16 -0
- package/lib/typescript/src/stt.d.ts.map +1 -0
- package/lib/typescript/src/tool-utils.d.ts +13 -0
- package/lib/typescript/src/tool-utils.d.ts.map +1 -0
- package/lib/typescript/src/tts.d.ts +13 -0
- package/lib/typescript/src/tts.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/models.ts +24 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { GenerationStats, LLMLoadOptions, StreamEvent } from './specs/LLM.nitro';
|
|
2
|
+
export type EventCallback = (event: StreamEvent) => void;
|
|
3
|
+
export type Message = {
|
|
4
|
+
role: 'user' | 'assistant' | 'system';
|
|
5
|
+
content: string;
|
|
6
|
+
};
|
|
7
|
+
export type ToolCallInfo = {
|
|
8
|
+
name: string;
|
|
9
|
+
arguments: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export type ToolCallUpdate = {
|
|
12
|
+
toolCall: ToolCallInfo;
|
|
13
|
+
allToolCalls: ToolCallInfo[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* LLM text generation using MLX on Apple Silicon.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { LLM } from 'react-native-nitro-mlx'
|
|
21
|
+
*
|
|
22
|
+
* // Load a model
|
|
23
|
+
* await LLM.load('mlx-community/Qwen3-0.6B-4bit', progress => {
|
|
24
|
+
* console.log(`Loading: ${(progress * 100).toFixed(0)}%`)
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* // Stream a response
|
|
28
|
+
* await LLM.stream('Hello!', token => {
|
|
29
|
+
* process.stdout.write(token)
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* // Get generation stats
|
|
33
|
+
* const stats = LLM.getLastGenerationStats()
|
|
34
|
+
* console.log(`${stats.tokensPerSecond} tokens/sec`)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const LLM: {
|
|
38
|
+
/**
|
|
39
|
+
* Load a model into memory. Downloads the model from HuggingFace if not already cached.
|
|
40
|
+
* @param modelId - HuggingFace model ID (e.g., 'mlx-community/Qwen3-0.6B-4bit')
|
|
41
|
+
* @param options - Callback invoked with loading progress (0-1)
|
|
42
|
+
*/
|
|
43
|
+
load(modelId: string, options: LLMLoadOptions): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Generate a complete response for a prompt. Blocks until generation is complete.
|
|
46
|
+
* For streaming responses, use `stream()` instead.
|
|
47
|
+
* @param prompt - The input text to generate a response for
|
|
48
|
+
* @returns The complete generated text
|
|
49
|
+
*/
|
|
50
|
+
generate(prompt: string): Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Stream a response token by token with optional tool calling support.
|
|
53
|
+
* Tools must be provided when loading the model via `load()` options.
|
|
54
|
+
* Tools are automatically executed when the model calls them.
|
|
55
|
+
* @param prompt - The input text to generate a response for
|
|
56
|
+
* @param onToken - Callback invoked for each generated token
|
|
57
|
+
* @param onToolCall - Optional callback invoked when a tool is called.
|
|
58
|
+
* Receives the current tool call and an accumulated array of all tool calls so far.
|
|
59
|
+
* @returns The complete generated text
|
|
60
|
+
*/
|
|
61
|
+
stream(prompt: string, onToken: (token: string) => void, onToolCall?: (update: ToolCallUpdate) => void): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Stream with typed events for thinking blocks and tool calls.
|
|
64
|
+
* Provides granular lifecycle events for UI updates.
|
|
65
|
+
*
|
|
66
|
+
* @param prompt - The input text
|
|
67
|
+
* @param onEvent - Callback receiving typed StreamEvent objects
|
|
68
|
+
* @returns Promise resolving to final content string (thinking content stripped)
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* await LLM.streamWithEvents(prompt, (event) => {
|
|
73
|
+
* switch (event.type) {
|
|
74
|
+
* case 'token':
|
|
75
|
+
* appendToContent(event.token)
|
|
76
|
+
* break
|
|
77
|
+
* case 'thinking_start':
|
|
78
|
+
* showThinkingIndicator()
|
|
79
|
+
* break
|
|
80
|
+
* case 'thinking_chunk':
|
|
81
|
+
* appendToThinking(event.chunk)
|
|
82
|
+
* break
|
|
83
|
+
* case 'tool_call_start':
|
|
84
|
+
* showToolCallCard(event.name, event.arguments)
|
|
85
|
+
* break
|
|
86
|
+
* }
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
streamWithEvents(prompt: string, onEvent: EventCallback): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Stop the current generation. Safe to call even if not generating.
|
|
93
|
+
*/
|
|
94
|
+
stop(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Unload the current model and release memory.
|
|
97
|
+
* Call this when you're done with the model to free up memory.
|
|
98
|
+
*/
|
|
99
|
+
unload(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Get statistics from the last generation.
|
|
102
|
+
* @returns Statistics including token count, tokens/sec (excluding tool execution), TTFT, total time, and tool execution time
|
|
103
|
+
*/
|
|
104
|
+
getLastGenerationStats(): GenerationStats;
|
|
105
|
+
/**
|
|
106
|
+
* Get the message history if management is enabled.
|
|
107
|
+
* @returns Array of messages in the history
|
|
108
|
+
*/
|
|
109
|
+
getHistory(): Message[];
|
|
110
|
+
/**
|
|
111
|
+
* Clear the message history.
|
|
112
|
+
*/
|
|
113
|
+
clearHistory(): void;
|
|
114
|
+
/** Whether a model is currently loaded and ready for generation */
|
|
115
|
+
readonly isLoaded: boolean;
|
|
116
|
+
/** Whether text is currently being generated */
|
|
117
|
+
readonly isGenerating: boolean;
|
|
118
|
+
/** The ID of the currently loaded model, or empty string if none */
|
|
119
|
+
readonly modelId: string;
|
|
120
|
+
/** Enable debug logging to console */
|
|
121
|
+
debug: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* System prompt used when loading the model.
|
|
124
|
+
* Set this before calling `load()`. Changes require reloading the model.
|
|
125
|
+
* @default "You are a helpful assistant."
|
|
126
|
+
*/
|
|
127
|
+
systemPrompt: string;
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../../src/llm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAEd,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAE1B,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;AAIxD,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;IACrC,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,YAAY,CAAA;IACtB,YAAY,EAAE,YAAY,EAAE,CAAA;CAC7B,CAAA;AASD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,GAAG;IACd;;;;OAIG;kBACW,MAAM,WAAW,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D;;;;;OAKG;qBACc,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIzC;;;;;;;;;OASG;mBAEO,MAAM,WACL,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,eACnB,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,GAC5C,OAAO,CAAC,MAAM,CAAC;IAyBlB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;6BACsB,MAAM,WAAW,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAWzE;;OAEG;YACK,IAAI;IAIZ;;;OAGG;cACO,IAAI;IAId;;;OAGG;8BACuB,eAAe;IAIzC;;;OAGG;kBACW,OAAO,EAAE;IAIvB;;OAEG;oBACa,IAAI;IAIpB,mEAAmE;uBACnD,OAAO;IAIvB,gDAAgD;2BAC5B,OAAO;IAI3B,oEAAoE;sBACrD,MAAM;IAIrB,sCAAsC;WACzB,OAAO;IAQpB;;;;OAIG;kBACiB,MAAM;CAO3B,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manage MLX model downloads from HuggingFace.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { ModelManager } from 'react-native-nitro-mlx'
|
|
7
|
+
*
|
|
8
|
+
* // Download a model
|
|
9
|
+
* await ModelManager.download('mlx-community/Qwen3-0.6B-4bit', progress => {
|
|
10
|
+
* console.log(`Downloading: ${(progress * 100).toFixed(0)}%`)
|
|
11
|
+
* })
|
|
12
|
+
*
|
|
13
|
+
* // Check if downloaded
|
|
14
|
+
* const isReady = await ModelManager.isDownloaded('mlx-community/Qwen3-0.6B-4bit')
|
|
15
|
+
*
|
|
16
|
+
* // List all downloaded models
|
|
17
|
+
* const models = await ModelManager.getDownloadedModels()
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const ModelManager: {
|
|
21
|
+
/**
|
|
22
|
+
* Download a model from HuggingFace.
|
|
23
|
+
* @param modelId - HuggingFace model ID (e.g., 'mlx-community/Qwen3-0.6B-4bit')
|
|
24
|
+
* @param progressCallback - Callback invoked with download progress (0-1)
|
|
25
|
+
* @returns Path to the downloaded model directory
|
|
26
|
+
*/
|
|
27
|
+
download(modelId: string, progressCallback: (progress: number) => void): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a model is already downloaded.
|
|
30
|
+
* @param modelId - HuggingFace model ID
|
|
31
|
+
* @returns True if the model is fully downloaded
|
|
32
|
+
*/
|
|
33
|
+
isDownloaded(modelId: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Get a list of all downloaded model IDs.
|
|
36
|
+
* @returns Array of model IDs that are available locally
|
|
37
|
+
*/
|
|
38
|
+
getDownloadedModels(): Promise<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete a downloaded model to free up disk space.
|
|
41
|
+
* @param modelId - HuggingFace model ID
|
|
42
|
+
*/
|
|
43
|
+
deleteModel(modelId: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the local filesystem path for a downloaded model.
|
|
46
|
+
* @param modelId - HuggingFace model ID
|
|
47
|
+
* @returns Absolute path to the model directory
|
|
48
|
+
*/
|
|
49
|
+
getModelPath(modelId: string): Promise<string>;
|
|
50
|
+
/** Enable debug logging to console */
|
|
51
|
+
debug: boolean;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=modelManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelManager.d.ts","sourceRoot":"","sources":["../../../src/modelManager.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;OAKG;sBAEQ,MAAM,oBACG,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAC3C,OAAO,CAAC,MAAM,CAAC;IAIlB;;;;OAIG;0BACmB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/C;;;OAGG;2BACoB,OAAO,CAAC,MAAM,EAAE,CAAC;IAIxC;;;OAGG;yBACkB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C;;;;OAIG;0BACmB,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI9C,sCAAsC;WACzB,OAAO;CAOrB,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare enum ModelFamily {
|
|
2
|
+
Llama = "Llama",
|
|
3
|
+
Qwen = "Qwen",
|
|
4
|
+
Gemma = "Gemma",
|
|
5
|
+
Phi = "Phi",
|
|
6
|
+
SmolLM = "SmolLM",
|
|
7
|
+
OpenELM = "OpenELM",
|
|
8
|
+
PocketTTS = "PocketTTS",
|
|
9
|
+
GLMASR = "GLMASR"
|
|
10
|
+
}
|
|
11
|
+
export declare enum ModelProvider {
|
|
12
|
+
Meta = "Meta",
|
|
13
|
+
Alibaba = "Alibaba",
|
|
14
|
+
Google = "Google",
|
|
15
|
+
Microsoft = "Microsoft",
|
|
16
|
+
HuggingFace = "HuggingFace",
|
|
17
|
+
Apple = "Apple",
|
|
18
|
+
Kyutai = "Kyutai"
|
|
19
|
+
}
|
|
20
|
+
export type ModelQuantization = '4bit' | '8bit' | 'bf16';
|
|
21
|
+
export type ModelType = 'llm' | 'tts' | 'stt';
|
|
22
|
+
export interface ModelInfo {
|
|
23
|
+
id: MLXModel;
|
|
24
|
+
family: ModelFamily;
|
|
25
|
+
provider: ModelProvider;
|
|
26
|
+
parameters: string;
|
|
27
|
+
quantization: ModelQuantization;
|
|
28
|
+
displayName: string;
|
|
29
|
+
downloadSize: number;
|
|
30
|
+
type: ModelType;
|
|
31
|
+
}
|
|
32
|
+
export declare enum MLXModel {
|
|
33
|
+
Llama_3_2_1B_Instruct_4bit = "mlx-community/Llama-3.2-1B-Instruct-4bit",
|
|
34
|
+
Llama_3_2_1B_Instruct_8bit = "mlx-community/Llama-3.2-1B-Instruct-8bit",
|
|
35
|
+
Llama_3_2_3B_Instruct_4bit = "mlx-community/Llama-3.2-3B-Instruct-4bit",
|
|
36
|
+
Llama_3_2_3B_Instruct_8bit = "mlx-community/Llama-3.2-3B-Instruct-8bit",
|
|
37
|
+
Qwen2_5_0_5B_Instruct_4bit = "mlx-community/Qwen2.5-0.5B-Instruct-4bit",
|
|
38
|
+
Qwen2_5_0_5B_Instruct_8bit = "mlx-community/Qwen2.5-0.5B-Instruct-8bit",
|
|
39
|
+
Qwen2_5_1_5B_Instruct_4bit = "mlx-community/Qwen2.5-1.5B-Instruct-4bit",
|
|
40
|
+
Qwen2_5_1_5B_Instruct_8bit = "mlx-community/Qwen2.5-1.5B-Instruct-8bit",
|
|
41
|
+
Qwen2_5_3B_Instruct_4bit = "mlx-community/Qwen2.5-3B-Instruct-4bit",
|
|
42
|
+
Qwen2_5_3B_Instruct_8bit = "mlx-community/Qwen2.5-3B-Instruct-8bit",
|
|
43
|
+
Qwen3_1_7B_4bit = "mlx-community/Qwen3-1.7B-4bit",
|
|
44
|
+
Qwen3_1_7B_8bit = "mlx-community/Qwen3-1.7B-8bit",
|
|
45
|
+
Qwen3_5_0_8B_MLX_4bit = "mlx-community/Qwen3.5-0.8B-MLX-4bit",
|
|
46
|
+
Qwen3_5_0_8B_MLX_8bit = "mlx-community/Qwen3.5-0.8B-MLX-8bit",
|
|
47
|
+
Gemma_3_1B_IT_4bit = "mlx-community/gemma-3-1b-it-4bit",
|
|
48
|
+
Gemma_3_1B_IT_8bit = "mlx-community/gemma-3-1b-it-8bit",
|
|
49
|
+
Phi_3_5_Mini_Instruct_4bit = "mlx-community/Phi-3.5-mini-instruct-4bit",
|
|
50
|
+
Phi_3_5_Mini_Instruct_8bit = "mlx-community/Phi-3.5-mini-instruct-8bit",
|
|
51
|
+
Phi_4_Mini_Instruct_4bit = "mlx-community/Phi-4-mini-instruct-4bit",
|
|
52
|
+
Phi_4_Mini_Instruct_8bit = "mlx-community/Phi-4-mini-instruct-8bit",
|
|
53
|
+
SmolLM_1_7B_Instruct_4bit = "mlx-community/SmolLM-1.7B-Instruct-4bit",
|
|
54
|
+
SmolLM_1_7B_Instruct_8bit = "mlx-community/SmolLM-1.7B-Instruct-8bit",
|
|
55
|
+
SmolLM2_1_7B_Instruct_4bit = "mlx-community/SmolLM2-1.7B-Instruct-4bit",
|
|
56
|
+
SmolLM2_1_7B_Instruct_8bit = "mlx-community/SmolLM2-1.7B-Instruct-8bit",
|
|
57
|
+
OpenELM_1_1B_4bit = "mlx-community/OpenELM-1_1B-4bit",
|
|
58
|
+
OpenELM_1_1B_8bit = "mlx-community/OpenELM-1_1B-8bit",
|
|
59
|
+
OpenELM_3B_4bit = "mlx-community/OpenELM-3B-4bit",
|
|
60
|
+
OpenELM_3B_8bit = "mlx-community/OpenELM-3B-8bit",
|
|
61
|
+
PocketTTS = "mlx-community/pocket-tts",
|
|
62
|
+
PocketTTS_8bit = "mlx-community/pocket-tts-8bit",
|
|
63
|
+
PocketTTS_4bit = "mlx-community/pocket-tts-4bit",
|
|
64
|
+
GLM_ASR_Nano_4bit = "mlx-community/GLM-ASR-Nano-2512-4bit"
|
|
65
|
+
}
|
|
66
|
+
export declare const MLXModels: ModelInfo[];
|
|
67
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/models.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB;AAED,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAExD,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;AAE7C,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,QAAQ,CAAA;IACZ,MAAM,EAAE,WAAW,CAAA;IACnB,QAAQ,EAAE,aAAa,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,iBAAiB,CAAA;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,oBAAY,QAAQ;IAElB,0BAA0B,6CAA6C;IACvE,0BAA0B,6CAA6C;IACvE,0BAA0B,6CAA6C;IACvE,0BAA0B,6CAA6C;IAGvE,0BAA0B,6CAA6C;IACvE,0BAA0B,6CAA6C;IACvE,0BAA0B,6CAA6C;IACvE,0BAA0B,6CAA6C;IACvE,wBAAwB,2CAA2C;IACnE,wBAAwB,2CAA2C;IAGnE,eAAe,kCAAkC;IACjD,eAAe,kCAAkC;IAGjD,qBAAqB,wCAAwC;IAC7D,qBAAqB,wCAAwC;IAG7D,kBAAkB,qCAAqC;IACvD,kBAAkB,qCAAqC;IAGvD,0BAA0B,6CAA6C;IACvE,0BAA0B,6CAA6C;IAGvE,wBAAwB,2CAA2C;IACnE,wBAAwB,2CAA2C;IAGnE,yBAAyB,4CAA4C;IACrE,yBAAyB,4CAA4C;IAGrE,0BAA0B,6CAA6C;IACvE,0BAA0B,6CAA6C;IAGvE,iBAAiB,oCAAoC;IACrD,iBAAiB,oCAAoC;IACrD,eAAe,kCAAkC;IACjD,eAAe,kCAAkC;IAGjD,SAAS,6BAA6B;IACtC,cAAc,kCAAkC;IAChD,cAAc,kCAAkC;IAGhD,iBAAiB,yCAAyC;CAC3D;AAED,eAAO,MAAM,SAAS,EAAE,SAAS,EAiUhC,CAAA"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { AnyMap, HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
/**
|
|
3
|
+
* Statistics from the last text generation.
|
|
4
|
+
*/
|
|
5
|
+
export interface GenerationStats {
|
|
6
|
+
tokenCount: number;
|
|
7
|
+
tokensPerSecond: number;
|
|
8
|
+
timeToFirstToken: number;
|
|
9
|
+
totalTime: number;
|
|
10
|
+
toolExecutionTime: number;
|
|
11
|
+
}
|
|
12
|
+
export interface GenerationStartEvent {
|
|
13
|
+
type: 'generation_start';
|
|
14
|
+
timestamp: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TokenEvent {
|
|
17
|
+
type: 'token';
|
|
18
|
+
token: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ThinkingStartEvent {
|
|
21
|
+
type: 'thinking_start';
|
|
22
|
+
timestamp: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ThinkingChunkEvent {
|
|
25
|
+
type: 'thinking_chunk';
|
|
26
|
+
chunk: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ThinkingEndEvent {
|
|
29
|
+
type: 'thinking_end';
|
|
30
|
+
content: string;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
}
|
|
33
|
+
export interface ToolCallStartEvent {
|
|
34
|
+
type: 'tool_call_start';
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
arguments: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ToolCallExecutingEvent {
|
|
40
|
+
type: 'tool_call_executing';
|
|
41
|
+
id: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ToolCallCompletedEvent {
|
|
44
|
+
type: 'tool_call_completed';
|
|
45
|
+
id: string;
|
|
46
|
+
result: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ToolCallFailedEvent {
|
|
49
|
+
type: 'tool_call_failed';
|
|
50
|
+
id: string;
|
|
51
|
+
error: string;
|
|
52
|
+
}
|
|
53
|
+
export interface GenerationEndEvent {
|
|
54
|
+
type: 'generation_end';
|
|
55
|
+
content: string;
|
|
56
|
+
stats: GenerationStats;
|
|
57
|
+
}
|
|
58
|
+
export type StreamEvent = GenerationStartEvent | TokenEvent | ThinkingStartEvent | ThinkingChunkEvent | ThinkingEndEvent | ToolCallStartEvent | ToolCallExecutingEvent | ToolCallCompletedEvent | ToolCallFailedEvent | GenerationEndEvent;
|
|
59
|
+
export interface LLMMessage {
|
|
60
|
+
role: string;
|
|
61
|
+
content: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parameter definition for a tool.
|
|
65
|
+
*/
|
|
66
|
+
export interface ToolParameter {
|
|
67
|
+
name: string;
|
|
68
|
+
type: string;
|
|
69
|
+
description: string;
|
|
70
|
+
required: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Tool definition that can be called by the model.
|
|
74
|
+
*/
|
|
75
|
+
export interface ToolDefinition {
|
|
76
|
+
name: string;
|
|
77
|
+
description: string;
|
|
78
|
+
parameters: ToolParameter[];
|
|
79
|
+
handler: (args: AnyMap) => Promise<AnyMap>;
|
|
80
|
+
}
|
|
81
|
+
/** Options for loading a model.
|
|
82
|
+
*/
|
|
83
|
+
export interface LLMLoadOptions {
|
|
84
|
+
/** Callback invoked with loading progress (0-1) */
|
|
85
|
+
onProgress?: (progress: number) => void;
|
|
86
|
+
/** Additional context to provide to the model */
|
|
87
|
+
additionalContext?: LLMMessage[];
|
|
88
|
+
/** Whether to automatically manage message history */
|
|
89
|
+
manageHistory?: boolean;
|
|
90
|
+
/** Tools available for the model to call */
|
|
91
|
+
tools?: ToolDefinition[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Low-level LLM interface for text generation using MLX.
|
|
95
|
+
* @internal Use the `LLM` export from `react-native-nitro-mlx` instead.
|
|
96
|
+
*/
|
|
97
|
+
export interface LLM extends HybridObject<{
|
|
98
|
+
ios: 'swift';
|
|
99
|
+
}> {
|
|
100
|
+
/**
|
|
101
|
+
* Load a model into memory. Downloads from HuggingFace if not already cached.
|
|
102
|
+
* @param modelId - HuggingFace model ID (e.g., 'mlx-community/Qwen3-0.6B-4bit')
|
|
103
|
+
* @param options - Callback invoked with loading progress (0-1)
|
|
104
|
+
*/
|
|
105
|
+
load(modelId: string, options?: LLMLoadOptions): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Generate a complete response for a prompt.
|
|
108
|
+
* @param prompt - The input text to generate a response for
|
|
109
|
+
* @returns The generated text
|
|
110
|
+
*/
|
|
111
|
+
generate(prompt: string): Promise<string>;
|
|
112
|
+
/**
|
|
113
|
+
* Stream a response token by token with optional tool calling support.
|
|
114
|
+
* Tools are automatically executed when the model calls them.
|
|
115
|
+
* @param prompt - The input text to generate a response for
|
|
116
|
+
* @param onToken - Callback invoked for each generated token
|
|
117
|
+
* @param onToolCall - Optional callback invoked when a tool is called (for UI feedback)
|
|
118
|
+
* @returns The complete generated text
|
|
119
|
+
*/
|
|
120
|
+
stream(prompt: string, onToken: (token: string) => void, onToolCall?: (toolName: string, args: string) => void): Promise<string>;
|
|
121
|
+
streamWithEvents(prompt: string, onEvent: (eventJson: string) => void): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* Stop the current generation.
|
|
124
|
+
*/
|
|
125
|
+
stop(): void;
|
|
126
|
+
/**
|
|
127
|
+
* Unload the current model and release memory.
|
|
128
|
+
*/
|
|
129
|
+
unload(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Get statistics from the last generation.
|
|
132
|
+
* @returns Statistics including token count, speed, and timing
|
|
133
|
+
*/
|
|
134
|
+
getLastGenerationStats(): GenerationStats;
|
|
135
|
+
/**
|
|
136
|
+
* Get the message history if management is enabled.
|
|
137
|
+
* @returns Array of messages in the history
|
|
138
|
+
*/
|
|
139
|
+
getHistory(): LLMMessage[];
|
|
140
|
+
/**
|
|
141
|
+
* Clear the message history.
|
|
142
|
+
*/
|
|
143
|
+
clearHistory(): void;
|
|
144
|
+
/** Whether a model is currently loaded */
|
|
145
|
+
readonly isLoaded: boolean;
|
|
146
|
+
/** Whether text is currently being generated */
|
|
147
|
+
readonly isGenerating: boolean;
|
|
148
|
+
/** The ID of the currently loaded model */
|
|
149
|
+
readonly modelId: string;
|
|
150
|
+
/** Enable debug logging */
|
|
151
|
+
debug: boolean;
|
|
152
|
+
/** System prompt used when loading the model */
|
|
153
|
+
systemPrompt: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Supported parameter types for tool definitions.
|
|
157
|
+
* Used for type safety in createTool().
|
|
158
|
+
*/
|
|
159
|
+
export type ToolParameterType = 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
160
|
+
//# sourceMappingURL=LLM.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLM.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/LLM.nitro.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
/**
|
|
3
|
+
* Low-level interface for managing MLX model downloads.
|
|
4
|
+
* @internal Use the `ModelManager` export from `react-native-nitro-mlx` instead.
|
|
5
|
+
*/
|
|
6
|
+
export interface ModelManager extends HybridObject<{
|
|
7
|
+
ios: 'swift';
|
|
8
|
+
}> {
|
|
9
|
+
/**
|
|
10
|
+
* Download a model from HuggingFace.
|
|
11
|
+
* @param modelId - HuggingFace model ID (e.g., 'mlx-community/Qwen3-0.6B-4bit')
|
|
12
|
+
* @param progressCallback - Callback invoked with download progress (0-1)
|
|
13
|
+
* @returns Path to the downloaded model directory
|
|
14
|
+
*/
|
|
15
|
+
download(modelId: string, progressCallback: (progress: number) => void): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a model is already downloaded.
|
|
18
|
+
* @param modelId - HuggingFace model ID
|
|
19
|
+
* @returns True if the model is downloaded
|
|
20
|
+
*/
|
|
21
|
+
isDownloaded(modelId: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Get a list of all downloaded model IDs.
|
|
24
|
+
* @returns Array of downloaded model IDs
|
|
25
|
+
*/
|
|
26
|
+
getDownloadedModels(): Promise<string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Delete a downloaded model.
|
|
29
|
+
* @param modelId - HuggingFace model ID
|
|
30
|
+
*/
|
|
31
|
+
deleteModel(modelId: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the local filesystem path for a downloaded model.
|
|
34
|
+
* @param modelId - HuggingFace model ID
|
|
35
|
+
* @returns Path to the model directory
|
|
36
|
+
*/
|
|
37
|
+
getModelPath(modelId: string): Promise<string>;
|
|
38
|
+
/** Enable debug logging */
|
|
39
|
+
debug: boolean;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=ModelManager.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelManager.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/ModelManager.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC;IAClE;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAExF;;;;OAIG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE/C;;;OAGG;IACH,mBAAmB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAExC;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3C;;;;OAIG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAE9C,2BAA2B;IAC3B,KAAK,EAAE,OAAO,CAAA;CACf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
export interface STTLoadOptions {
|
|
3
|
+
onProgress?: (progress: number) => void;
|
|
4
|
+
}
|
|
5
|
+
export interface STTTranscriptionInfo {
|
|
6
|
+
promptTokens: number;
|
|
7
|
+
generationTokens: number;
|
|
8
|
+
tokensPerSecond: number;
|
|
9
|
+
prefillTime: number;
|
|
10
|
+
generateTime: number;
|
|
11
|
+
}
|
|
12
|
+
export interface STT extends HybridObject<{
|
|
13
|
+
ios: 'swift';
|
|
14
|
+
}> {
|
|
15
|
+
readonly isLoaded: boolean;
|
|
16
|
+
readonly isTranscribing: boolean;
|
|
17
|
+
readonly isListening: boolean;
|
|
18
|
+
readonly modelId: string;
|
|
19
|
+
load(modelId: string, options?: STTLoadOptions): Promise<void>;
|
|
20
|
+
transcribe(audio: ArrayBuffer): Promise<string>;
|
|
21
|
+
transcribeStream(audio: ArrayBuffer, onToken: (token: string) => void): Promise<string>;
|
|
22
|
+
startListening(): Promise<void>;
|
|
23
|
+
transcribeBuffer(): Promise<string>;
|
|
24
|
+
stopListening(): Promise<string>;
|
|
25
|
+
stop(): void;
|
|
26
|
+
unload(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=STT.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"STT.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/STT.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,GAAI,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC;IACzD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE9D,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/C,gBAAgB,CACd,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAA;IAElB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IACnC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAEhC,IAAI,IAAI,IAAI,CAAA;IACZ,MAAM,IAAI,IAAI,CAAA;CACf"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
export interface TTSLoadOptions {
|
|
3
|
+
onProgress?: (progress: number) => void;
|
|
4
|
+
}
|
|
5
|
+
export interface TTSGenerateOptions {
|
|
6
|
+
voice?: string;
|
|
7
|
+
speed?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TTS extends HybridObject<{
|
|
10
|
+
ios: 'swift';
|
|
11
|
+
}> {
|
|
12
|
+
readonly isLoaded: boolean;
|
|
13
|
+
readonly isGenerating: boolean;
|
|
14
|
+
readonly modelId: string;
|
|
15
|
+
readonly sampleRate: number;
|
|
16
|
+
load(modelId: string, options?: TTSLoadOptions): Promise<void>;
|
|
17
|
+
generate(text: string, options?: TTSGenerateOptions): Promise<ArrayBuffer>;
|
|
18
|
+
stream(text: string, onAudioChunk: (audio: ArrayBuffer) => void, options?: TTSGenerateOptions): Promise<void>;
|
|
19
|
+
stop(): void;
|
|
20
|
+
unload(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=TTS.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TTS.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/TTS.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CACxC;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,GAAI,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC;IACzD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAE3B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9D,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC,CAAA;IACvB,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EAC1C,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAA;IAChB,IAAI,IAAI,IAAI,CAAA;IACZ,MAAM,IAAI,IAAI,CAAA;CACf"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { STTLoadOptions } from './specs/STT.nitro';
|
|
2
|
+
export declare const STT: {
|
|
3
|
+
load(modelId: string, options?: STTLoadOptions): Promise<void>;
|
|
4
|
+
transcribe(audio: ArrayBuffer): Promise<string>;
|
|
5
|
+
transcribeStream(audio: ArrayBuffer, onToken: (token: string) => void): Promise<string>;
|
|
6
|
+
startListening(): Promise<void>;
|
|
7
|
+
transcribeBuffer(): Promise<string>;
|
|
8
|
+
stopListening(): Promise<string>;
|
|
9
|
+
stop(): void;
|
|
10
|
+
unload(): void;
|
|
11
|
+
readonly isLoaded: boolean;
|
|
12
|
+
readonly isTranscribing: boolean;
|
|
13
|
+
readonly isListening: boolean;
|
|
14
|
+
readonly modelId: string;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=stt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stt.d.ts","sourceRoot":"","sources":["../../../src/stt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,mBAAmB,CAAA;AAW1B,eAAO,MAAM,GAAG;kBACA,MAAM,YAAY,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;sBAI5C,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;4BAKtC,WAAW,WACT,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC/B,OAAO,CAAC,MAAM,CAAC;sBAIA,OAAO,CAAC,IAAI,CAAC;wBAIX,OAAO,CAAC,MAAM,CAAC;qBAIlB,OAAO,CAAC,MAAM,CAAC;YAIxB,IAAI;cAIF,IAAI;uBAIE,OAAO;6BAID,OAAO;0BAIV,OAAO;sBAIX,MAAM;CAGtB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from './specs/LLM.nitro';
|
|
3
|
+
type ZodObjectSchema = z.ZodObject<z.core.$ZodShape>;
|
|
4
|
+
type InferArgs<T extends ZodObjectSchema> = z.infer<T>;
|
|
5
|
+
export interface TypeSafeToolDefinition<T extends ZodObjectSchema> {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
arguments: T;
|
|
9
|
+
handler: (args: InferArgs<T>) => Promise<Record<string, unknown>>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createTool<T extends ZodObjectSchema>(definition: TypeSafeToolDefinition<T>): ToolDefinition;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=tool-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-utils.d.ts","sourceRoot":"","sources":["../../../src/tool-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAoC,MAAM,mBAAmB,CAAA;AAEzF,KAAK,eAAe,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACpD,KAAK,SAAS,CAAC,CAAC,SAAS,eAAe,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAEtD,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,eAAe;IAC/D,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,CAAC,CAAA;IACZ,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAClE;AA+CD,wBAAgB,UAAU,CAAC,CAAC,SAAS,eAAe,EAClD,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACpC,cAAc,CAYhB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TTSLoadOptions, TTSGenerateOptions } from './specs/TTS.nitro';
|
|
2
|
+
export declare const TTS: {
|
|
3
|
+
load(modelId: string, options?: TTSLoadOptions): Promise<void>;
|
|
4
|
+
generate(text: string, options?: TTSGenerateOptions): Promise<ArrayBuffer>;
|
|
5
|
+
stream(text: string, onAudioChunk: (audio: ArrayBuffer) => void, options?: TTSGenerateOptions): Promise<void>;
|
|
6
|
+
stop(): void;
|
|
7
|
+
unload(): void;
|
|
8
|
+
readonly isLoaded: boolean;
|
|
9
|
+
readonly isGenerating: boolean;
|
|
10
|
+
readonly modelId: string;
|
|
11
|
+
readonly sampleRate: number;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=tts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tts.d.ts","sourceRoot":"","sources":["../../../src/tts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,cAAc,EACd,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAW1B,eAAO,MAAM,GAAG;kBACA,MAAM,YAAY,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;mBAKtD,MAAM,YACF,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;iBAKf,MAAM,gBACE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,YAChC,kBAAkB,GAC3B,OAAO,CAAC,IAAI,CAAC;YAIR,IAAI;cAIF,IAAI;uBAIE,OAAO;2BAIH,OAAO;sBAIZ,MAAM;yBAIH,MAAM;CAGzB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inferrlm/react-native-mlx",
|
|
3
3
|
"description": "MLX Swift integration for React Native - InferrLM fork with enhanced features",
|
|
4
|
-
"version": "0.4.0",
|
|
4
|
+
"version": "0.4.2-alpha.0",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
7
7
|
"types": "./lib/typescript/src/index.d.ts",
|
package/src/models.ts
CHANGED
|
@@ -53,6 +53,10 @@ export enum MLXModel {
|
|
|
53
53
|
Qwen3_1_7B_4bit = 'mlx-community/Qwen3-1.7B-4bit',
|
|
54
54
|
Qwen3_1_7B_8bit = 'mlx-community/Qwen3-1.7B-8bit',
|
|
55
55
|
|
|
56
|
+
// Qwen 3.5 - 0.8B variant
|
|
57
|
+
Qwen3_5_0_8B_MLX_4bit = 'mlx-community/Qwen3.5-0.8B-MLX-4bit',
|
|
58
|
+
Qwen3_5_0_8B_MLX_8bit = 'mlx-community/Qwen3.5-0.8B-MLX-8bit',
|
|
59
|
+
|
|
56
60
|
// Gemma 3 (Google) - 1B variant
|
|
57
61
|
Gemma_3_1B_IT_4bit = 'mlx-community/gemma-3-1b-it-4bit',
|
|
58
62
|
Gemma_3_1B_IT_8bit = 'mlx-community/gemma-3-1b-it-8bit',
|
|
@@ -209,6 +213,26 @@ export const MLXModels: ModelInfo[] = [
|
|
|
209
213
|
downloadSize: 1839729195,
|
|
210
214
|
type: 'llm',
|
|
211
215
|
},
|
|
216
|
+
{
|
|
217
|
+
id: MLXModel.Qwen3_5_0_8B_MLX_4bit,
|
|
218
|
+
family: ModelFamily.Qwen,
|
|
219
|
+
provider: ModelProvider.Alibaba,
|
|
220
|
+
parameters: '0.8B',
|
|
221
|
+
quantization: '4bit',
|
|
222
|
+
displayName: 'Qwen 3.5 0.8B (4-bit)',
|
|
223
|
+
downloadSize: 550000000,
|
|
224
|
+
type: 'llm',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: MLXModel.Qwen3_5_0_8B_MLX_8bit,
|
|
228
|
+
family: ModelFamily.Qwen,
|
|
229
|
+
provider: ModelProvider.Alibaba,
|
|
230
|
+
parameters: '0.8B',
|
|
231
|
+
quantization: '8bit',
|
|
232
|
+
displayName: 'Qwen 3.5 0.8B (8-bit)',
|
|
233
|
+
downloadSize: 950000000,
|
|
234
|
+
type: 'llm',
|
|
235
|
+
},
|
|
212
236
|
{
|
|
213
237
|
id: MLXModel.Gemma_3_1B_IT_4bit,
|
|
214
238
|
family: ModelFamily.Gemma,
|