Skip to content

Commit 070c1cc

Browse files
chore: upgrade rne to 0.8.0
1 parent 93547c4 commit 070c1cc

6 files changed

Lines changed: 67 additions & 44 deletions

File tree

example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"react": "19.0.0",
1919
"react-dom": "19.0.0",
2020
"react-native": "0.79.2",
21-
"react-native-executorch": "^0.5.1",
21+
"react-native-executorch": "0.8.0-nightly-48610bf-20260324",
22+
"react-native-executorch-expo-resource-fetcher": "0.8.0-rc3-nightly-48610bf-20260324",
2223
"react-native-rag": "workspace:*",
2324
"react-native-safe-area-context": "^5.4.1",
2425
"react-native-svg": "15.11.2",

example/src/App.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ import { OPSQLiteVectorStore } from '@react-native-rag/op-sqlite';
33
import {
44
QWEN3_0_6B_QUANTIZED,
55
ALL_MINILM_L6_V2,
6+
initExecutorch,
67
} from 'react-native-executorch';
8+
import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher';
79
import { useMemo, useState } from 'react';
10+
11+
initExecutorch({ resourceFetcher: ExpoResourceFetcher });
812
import {
913
ExecuTorchEmbeddings,
1014
ExecuTorchLLM,

packages/executorch/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
"license": "MIT",
99
"description": "React Native ExecuTorch wrapper for React Native RAG",
1010
"peerDependencies": {
11-
"react-native-executorch": "^0.5.1",
11+
"react-native-executorch": "0.8.0-nightly-48610bf-20260324",
1212
"react-native-rag": "^0.2.0"
1313
},
1414
"devDependencies": {
15-
"react-native-executorch": "^0.5.1",
15+
"react-native-executorch": "0.8.0-nightly-48610bf-20260324",
1616
"react-native-rag": "workspace:*"
1717
}
1818
}

packages/executorch/src/wrappers/embeddings.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface ExecuTorchEmbeddingsParams {
1717
* ExecuTorch-based implementation of {@link Embeddings} for React Native.
1818
*/
1919
export class ExecuTorchEmbeddings implements Embeddings {
20-
private module: TextEmbeddingsModule;
20+
private module: TextEmbeddingsModule | null = null;
2121
private modelSource: ResourceSource;
2222
private tokenizerSource: ResourceSource;
2323
private onDownloadProgress: (progress: number) => void;
@@ -36,7 +36,6 @@ export class ExecuTorchEmbeddings implements Embeddings {
3636
tokenizerSource,
3737
onDownloadProgress = () => {},
3838
}: ExecuTorchEmbeddingsParams) {
39-
this.module = new TextEmbeddingsModule();
4039
this.modelSource = modelSource;
4140
this.tokenizerSource = tokenizerSource;
4241
this.onDownloadProgress = onDownloadProgress;
@@ -48,11 +47,9 @@ export class ExecuTorchEmbeddings implements Embeddings {
4847
*/
4948
async load() {
5049
if (!this.isLoaded) {
51-
await this.module.load(
52-
{
53-
modelSource: this.modelSource,
54-
tokenizerSource: this.tokenizerSource,
55-
},
50+
this.module = await TextEmbeddingsModule.fromCustomModel(
51+
this.modelSource,
52+
this.tokenizerSource,
5653
this.onDownloadProgress
5754
);
5855
this.isLoaded = true;
@@ -69,7 +66,8 @@ export class ExecuTorchEmbeddings implements Embeddings {
6966
console.warn(
7067
'This function will call a synchronous unload on the instance of TextEmbeddingsModule from React Native ExecuTorch. Awaiting this method will not guarantee completion. This may change in future versions to support async unload.'
7168
);
72-
this.module.delete();
69+
this.module?.delete();
70+
this.module = null;
7371
this.isLoaded = false;
7472
}
7573

@@ -79,6 +77,9 @@ export class ExecuTorchEmbeddings implements Embeddings {
7977
* @returns Promise that resolves to the embedding vector.
8078
*/
8179
async embed(text: string): Promise<number[]> {
80+
if (!this.module) {
81+
throw new Error('TextEmbeddingsModule not loaded. Call load() first.');
82+
}
8283
return Array.from(await this.module.forward(text));
8384
}
8485
}

packages/executorch/src/wrappers/llms.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface ExecuTorchLLMParams {
2727
* ExecuTorch-based implementation of {@link LLM} for React Native.
2828
*/
2929
export class ExecuTorchLLM implements LLM {
30-
private module: LLMModule;
30+
private module: LLMModule | null = null;
3131

3232
private modelSource: ResourceSource;
3333
private tokenizerSource: ResourceSource;
@@ -52,12 +52,8 @@ export class ExecuTorchLLM implements LLM {
5252
tokenizerSource,
5353
tokenizerConfigSource,
5454
onDownloadProgress = () => {},
55-
responseCallback = () => {},
5655
chatConfig,
5756
}: ExecuTorchLLMParams) {
58-
this.module = new LLMModule({
59-
responseCallback: responseCallback,
60-
});
6157
this.modelSource = modelSource;
6258
this.tokenizerSource = tokenizerSource;
6359
this.tokenizerConfigSource = tokenizerConfigSource;
@@ -71,15 +67,13 @@ export class ExecuTorchLLM implements LLM {
7167
*/
7268
async load() {
7369
if (!this.isLoaded) {
74-
await this.module.load(
75-
{
76-
modelSource: this.modelSource,
77-
tokenizerSource: this.tokenizerSource,
78-
tokenizerConfigSource: this.tokenizerConfigSource,
79-
},
70+
this.module = await LLMModule.fromCustomModel(
71+
this.modelSource,
72+
this.tokenizerSource,
73+
this.tokenizerConfigSource,
8074
this.onDownloadProgress
8175
);
82-
this.module.configure({
76+
this.module!.configure({
8377
chatConfig: this.chatConfig,
8478
});
8579
this.isLoaded = true;
@@ -96,7 +90,7 @@ export class ExecuTorchLLM implements LLM {
9690
console.warn(
9791
'This function will call a synchronous interrupt on the instance of LLMModule from React Native ExecuTorch. Awaiting this method will not guarantee completion. This may change in future versions to support async interrupt.'
9892
);
99-
this.module.interrupt();
93+
this.module?.interrupt();
10094
}
10195

10296
/**
@@ -108,7 +102,8 @@ export class ExecuTorchLLM implements LLM {
108102
console.warn(
109103
'This function will call a synchronous unload on the instance of LLMModule from React Native ExecuTorch. Awaiting this method will not guarantee completion. This may change in future versions to support async unload.'
110104
);
111-
this.module.delete();
105+
this.module?.delete();
106+
this.module = null;
112107
this.isLoaded = false;
113108
}
114109

@@ -119,6 +114,9 @@ export class ExecuTorchLLM implements LLM {
119114
* @returns Promise that resolves to the full generated string.
120115
*/
121116
async generate(messages: Message[], callback: (token: string) => void) {
117+
if (!this.module) {
118+
throw new Error('LLMModule not loaded. Call load() first.');
119+
}
122120
this.module.setTokenCallback({ tokenCallback: callback });
123121
return this.module.generate(messages);
124122
}

yarn.lock

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2966,10 +2966,10 @@ __metadata:
29662966
version: 0.0.0-use.local
29672967
resolution: "@react-native-rag/executorch@workspace:packages/executorch"
29682968
dependencies:
2969-
react-native-executorch: ^0.5.1
2969+
react-native-executorch: 0.8.0-nightly-48610bf-20260324
29702970
react-native-rag: "workspace:*"
29712971
peerDependencies:
2972-
react-native-executorch: ^0.5.1
2972+
react-native-executorch: 0.8.0-nightly-48610bf-20260324
29732973
react-native-rag: ^0.2.0
29742974
languageName: unknown
29752975
linkType: soft
@@ -6916,7 +6916,7 @@ __metadata:
69166916
languageName: node
69176917
linkType: hard
69186918

6919-
"expo@npm:^53.0.7, expo@npm:~53.0.9":
6919+
"expo@npm:~53.0.9":
69206920
version: 53.0.12
69216921
resolution: "expo@npm:53.0.12"
69226922
dependencies:
@@ -11401,6 +11401,13 @@ __metadata:
1140111401
languageName: node
1140211402
linkType: hard
1140311403

11404+
"pngjs@npm:^7.0.0":
11405+
version: 7.0.0
11406+
resolution: "pngjs@npm:7.0.0"
11407+
checksum: b19a018930d27de26229c1b3ff250b3a25d09caa22cbb0b0459987d91eb0a560a18ab5d67da45a38ed7514140f26d1db58de83c31159ec101f2bb270a3c707f1
11408+
languageName: node
11409+
linkType: hard
11410+
1140411411
"possible-typed-array-names@npm:^1.0.0":
1140511412
version: 1.1.0
1140611413
resolution: "possible-typed-array-names@npm:1.1.0"
@@ -11746,21 +11753,32 @@ __metadata:
1174611753
languageName: node
1174711754
linkType: hard
1174811755

11749-
"react-native-executorch@npm:^0.5.1":
11750-
version: 0.5.1
11751-
resolution: "react-native-executorch@npm:0.5.1"
11756+
"react-native-executorch-expo-resource-fetcher@npm:0.8.0-rc3-nightly-48610bf-20260324":
11757+
version: 0.8.0-rc3-nightly-48610bf-20260324
11758+
resolution: "react-native-executorch-expo-resource-fetcher@npm:0.8.0-rc3-nightly-48610bf-20260324"
11759+
peerDependencies:
11760+
expo: ">=54.0.0"
11761+
expo-asset: ">=12.0.0"
11762+
expo-file-system: ">=19.0.0"
11763+
react-native: "*"
11764+
react-native-executorch: "*"
11765+
checksum: d2c960872f581ccb5ab51e764e48574959e653b2de168f80de2ffc325d6d44fc58606c53329388cdac07800af4e86a5f5075b0962f3c44bc1b883c03bb10629b
11766+
languageName: node
11767+
linkType: hard
11768+
11769+
"react-native-executorch@npm:0.8.0-nightly-48610bf-20260324":
11770+
version: 0.8.0-nightly-48610bf-20260324
11771+
resolution: "react-native-executorch@npm:0.8.0-nightly-48610bf-20260324"
1175211772
dependencies:
1175311773
"@huggingface/jinja": ^0.5.0
11754-
expo: ^53.0.7
11755-
expo-asset: ~11.1.5
11756-
expo-file-system: ~18.1.10
1175711774
jsonrepair: ^3.12.0
1175811775
jsonschema: ^1.5.0
11759-
zod: ^3.25.0
11776+
pngjs: ^7.0.0
11777+
zod: ^4.3.6
1176011778
peerDependencies:
1176111779
react: "*"
1176211780
react-native: "*"
11763-
checksum: 63bac8781d71b5488512a35cd96c7ff4cb63e4018bd49ce9e47a5a00f6b735269e0d09e5fe6b6207c9931cb0b667082bf769b22e859b0c069afb3b10e58f29a4
11781+
checksum: e7e08c00aca0c30fad6a68323be4e334d333f86907df03dd1fd510d0f8cf8f932b498e59259cb17fc9f1cc5f3eb5d25b82de8afe8abe59170b76629798db6d32
1176411782
languageName: node
1176511783
linkType: hard
1176611784

@@ -11799,7 +11817,8 @@ __metadata:
1179911817
react-dom: 19.0.0
1180011818
react-native: 0.79.2
1180111819
react-native-builder-bob: ^0.40.11
11802-
react-native-executorch: ^0.5.1
11820+
react-native-executorch: 0.8.0-nightly-48610bf-20260324
11821+
react-native-executorch-expo-resource-fetcher: 0.8.0-rc3-nightly-48610bf-20260324
1180311822
react-native-monorepo-config: ^0.1.9
1180411823
react-native-rag: "workspace:*"
1180511824
react-native-safe-area-context: ^5.4.1
@@ -14396,16 +14415,16 @@ __metadata:
1439614415
languageName: node
1439714416
linkType: hard
1439814417

14399-
"zod@npm:^3.25.0":
14400-
version: 3.25.76
14401-
resolution: "zod@npm:3.25.76"
14402-
checksum: c9a403a62b329188a5f6bd24d5d935d2bba345f7ab8151d1baa1505b5da9f227fb139354b043711490c798e91f3df75991395e40142e6510a4b16409f302b849
14403-
languageName: node
14404-
linkType: hard
14405-
1440614418
"zod@npm:^3.25.32":
1440714419
version: 3.25.67
1440814420
resolution: "zod@npm:3.25.67"
1440914421
checksum: 56ab904d33b1cd00041ce64ae05b0628fcbfeb7e707fa31cd498a97b540135e4dfe685200c9c62aea307695ee132870b4bc34f035228ea728aa75cc96a4954cb
1441014422
languageName: node
1441114423
linkType: hard
14424+
14425+
"zod@npm:^4.3.6":
14426+
version: 4.3.6
14427+
resolution: "zod@npm:4.3.6"
14428+
checksum: 19cec761b46bae4b6e7e861ea740f3f248e50a6671825afc8a5758e27b35d6f20ccde9942422fd5cf6f8b697f18bd05ef8bb33f5f2db112ab25cc628de2fae47
14429+
languageName: node
14430+
linkType: hard

0 commit comments

Comments
 (0)