Skip to content

Commit ae10ae5

Browse files
Merge pull request #17 from software-mansion-labs/@nk/bump-rne
chore: upgrade rne to 0.8.0
2 parents 93547c4 + 9c2892e commit ae10ae5

11 files changed

Lines changed: 1387 additions & 1374 deletions

File tree

example/app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"web": {
2828
"favicon": "./assets/favicon.png"
29-
}
29+
},
30+
"plugins": ["expo-asset"]
3031
}
3132
}

example/package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,26 @@
99
"web": "expo start --web"
1010
},
1111
"dependencies": {
12-
"@expo/metro-runtime": "~5.0.4",
13-
"@op-engineering/op-sqlite": "^14.0.3",
12+
"@expo/metro-runtime": "~55.0.0",
13+
"@op-engineering/op-sqlite": "^15.2.7",
1414
"@react-native-rag/executorch": "workspace:packages/executorch",
1515
"@react-native-rag/op-sqlite": "workspace:packages/op-sqlite",
16-
"expo": "~53.0.9",
17-
"expo-status-bar": "~2.2.3",
18-
"react": "19.0.0",
19-
"react-dom": "19.0.0",
20-
"react-native": "0.79.2",
21-
"react-native-executorch": "^0.5.1",
16+
"expo": "~55.0.0",
17+
"expo-asset": "~55.0.10",
18+
"expo-file-system": "~55.0.11",
19+
"expo-status-bar": "~55.0.4",
20+
"react": "19.2.0",
21+
"react-dom": "19.2.0",
22+
"react-native": "0.83.2",
23+
"react-native-executorch": "^0.8.0",
24+
"react-native-executorch-expo-resource-fetcher": "^0.8.0",
2225
"react-native-rag": "workspace:*",
23-
"react-native-safe-area-context": "^5.4.1",
24-
"react-native-svg": "15.11.2",
25-
"react-native-web": "~0.20.0"
26+
"react-native-safe-area-context": "~5.6.2",
27+
"react-native-svg": "15.15.3",
28+
"react-native-web": "^0.21.0"
2629
},
2730
"op-sqlite": {
28-
"libsql": true,
29-
"sqliteVec": true
31+
"libsql": true
3032
},
3133
"devDependencies": {
3234
"@babel/core": "^7.20.0",

example/src/App.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ 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';
7-
import { useMemo, useState } from 'react';
8+
import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher';
89
import {
910
ExecuTorchEmbeddings,
1011
ExecuTorchLLM,
1112
} from '@react-native-rag/executorch';
13+
import { useMemo, useState } from 'react';
14+
15+
initExecutorch({ resourceFetcher: ExpoResourceFetcher });
1216
import {
1317
KeyboardAvoidingView,
1418
Text,

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-rag",
3-
"version": "0.2.0",
3+
"version": "0.8.0",
44
"description": "Private, local RAGs. Supercharge LLMs with your own knowledge base.",
55
"main": "./lib/module/index.js",
66
"types": "./lib/typescript/src/index.d.ts",
@@ -69,7 +69,7 @@
6969
"@eslint/eslintrc": "^3.3.0",
7070
"@eslint/js": "^9.22.0",
7171
"@evilmartians/lefthook": "^1.5.0",
72-
"@react-native/babel-preset": "0.78.2",
72+
"@react-native/babel-preset": "0.83.2",
7373
"@react-native/eslint-config": "^0.78.0",
7474
"@release-it/conventional-changelog": "^9.0.2",
7575
"@types/jest": "^29.5.5",
@@ -81,8 +81,8 @@
8181
"eslint-plugin-prettier": "^5.2.3",
8282
"jest": "^29.7.0",
8383
"prettier": "^3.0.3",
84-
"react": "19.0.0",
85-
"react-native": "0.79.2",
84+
"react": "19.2.0",
85+
"react-native": "0.83.2",
8686
"react-native-builder-bob": "^0.40.11",
8787
"release-it": "^17.10.0",
8888
"typedoc": "^0.28.13",

packages/executorch/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ This package provides implementations for the `Embeddings` and `LLM` interfaces
88
npm install @react-native-rag/executorch react-native-executorch
99
```
1010

11+
You also need to install a resource fetcher for your setup (e.g. `react-native-executorch-expo-resource-fetcher` for Expo projects) and call `initExecutorch` in your app before using any ExecuTorch modules:
12+
13+
```typescript
14+
import { initExecutorch } from 'react-native-executorch';
15+
import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher';
16+
17+
initExecutorch({ resourceFetcher: ExpoResourceFetcher });
18+
```
19+
1120
## Usage
1221

1322
### `ExecuTorchEmbeddings`

packages/executorch/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "@react-native-rag/executorch",
3-
"version": "0.2.0",
3+
"version": "0.8.0",
44
"main": "src/index.ts",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"
77
},
88
"license": "MIT",
99
"description": "React Native ExecuTorch wrapper for React Native RAG",
1010
"peerDependencies": {
11-
"react-native-executorch": "^0.5.1",
12-
"react-native-rag": "^0.2.0"
11+
"react-native-executorch": "^0.8.0",
12+
"react-native-rag": "^0.8.0"
1313
},
1414
"devDependencies": {
15-
"react-native-executorch": "^0.5.1",
15+
"react-native-executorch": "^0.8.0",
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
}

packages/op-sqlite/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ To enable the required features for vector search, you must add the following co
2424

2525
```json
2626
"op-sqlite": {
27-
"libsql": true,
28-
"sqliteVec": true
27+
"libsql": true
2928
}
3029
```
3130

32-
This configuration ensures that the necessary `libsql` and `sqliteVec` extensions are enabled for `op-sqlite`.
31+
This configuration ensures that the `libsql` extension is enabled for `op-sqlite`. Note that `libsql` already includes vector search capabilities, so `sqliteVec` is not needed.
3332

3433
## Usage
3534

packages/op-sqlite/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "@react-native-rag/op-sqlite",
3-
"version": "0.2.0",
3+
"version": "0.8.0",
44
"main": "src/index.ts",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"
77
},
88
"license": "MIT",
99
"description": "OP-SQLite wrapper for React Native RAG",
1010
"peerDependencies": {
11-
"@op-engineering/op-sqlite": "^14.0.4",
12-
"react-native-rag": "^0.2.0"
11+
"@op-engineering/op-sqlite": "^15.2.7",
12+
"react-native-rag": "^0.8.0"
1313
},
1414
"devDependencies": {
15-
"@op-engineering/op-sqlite": "^14.0.4",
15+
"@op-engineering/op-sqlite": "^15.2.7",
1616
"react-native-rag": "workspace:*"
1717
}
1818
}

0 commit comments

Comments
 (0)