Skip to content

Commit 74c816b

Browse files
authored
V0.2.0 rc3 (#13)
* chore: update package versions to 0.2.0-rc1 * fix: reset isLoaded flag after unloading module in ExecuTorch classes * refactor: api modified: example/src/App.tsx * fix: handle undefined metadata and preserve existing values in MemoryVectorStore update
1 parent 3bc0523 commit 74c816b

15 files changed

Lines changed: 501 additions & 883 deletions

File tree

example/src/App.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { type Message, MemoryVectorStore, useRAG } from 'react-native-rag';
1+
import { type Message, useRAG } from 'react-native-rag';
2+
import { OPSQLiteVectorStore } from '@react-native-rag/op-sqlite';
23
import {
34
QWEN3_0_6B_QUANTIZED,
45
ALL_MINILM_L6_V2,
@@ -32,7 +33,8 @@ export default function App() {
3233
const [messages, setMessages] = useState<Message[]>([]);
3334

3435
const vectorStore = useMemo(() => {
35-
return new MemoryVectorStore({
36+
return new OPSQLiteVectorStore({
37+
name: 'rag_example_db1',
3638
embeddings: new ExecuTorchEmbeddings(ALL_MINILM_L6_V2),
3739
});
3840
}, []);
@@ -55,13 +57,11 @@ export default function App() {
5557
try {
5658
if (ids.length) {
5759
for (const id of ids) {
58-
await rag.deleteDocument({
59-
ids: [id],
60-
});
60+
await rag.deleteDocument({ predicate: (value) => value.id === id });
6161
}
6262
setIds([]);
6363
}
64-
const newIds = await rag.splitAddDocument(document);
64+
const newIds = await rag.splitAddDocument({ document });
6565
setIds(newIds);
6666
console.log('Document splitted and added with IDs:', newIds);
6767
setModalVisible(false);

package.json

Lines changed: 1 addition & 1 deletion
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.2.0-rc3",
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",

packages/executorch/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-native-rag/executorch",
3-
"version": "0.2.0",
3+
"version": "0.2.0-rc3",
44
"main": "src/index.ts",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"

packages/executorch/src/wrappers/embeddings.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface ExecuTorchEmbeddingsParams {
99
modelSource: ResourceSource;
1010
/** Source of the tokenizer model. */
1111
tokenizerSource: ResourceSource;
12-
/** Optional download progress callback (0-1). */
12+
/** Download progress callback (0-1). */
1313
onDownloadProgress?: (progress: number) => void;
1414
}
1515

@@ -29,7 +29,7 @@ export class ExecuTorchEmbeddings implements Embeddings {
2929
* @param params - Parameters for the instance.
3030
* @param params.modelSource - Source of the embedding model.
3131
* @param params.tokenizerSource - Source of the tokenizer.
32-
* @param params.onDownloadProgress - Optional download progress callback (0-1).
32+
* @param params.onDownloadProgress - Download progress callback (0-1).
3333
*/
3434
constructor({
3535
modelSource,
@@ -61,16 +61,16 @@ export class ExecuTorchEmbeddings implements Embeddings {
6161
}
6262

6363
/**
64-
* Unloads the underlying module. Note: unload is synchronous in ExecuTorch
65-
* at the time of writing; this method resolves immediately after calling delete.
64+
* Unloads the underlying module.
65+
* Note: current ExecuTorch unload is synchronous.
6666
* Awaiting this method will not guarantee completion.
67-
* @returns Promise that resolves when unloading is initiated.
6867
*/
6968
async unload() {
7069
console.warn(
7170
'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.'
7271
);
7372
this.module.delete();
73+
this.isLoaded = false;
7474
}
7575

7676
/**

packages/executorch/src/wrappers/llms.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ interface ExecuTorchLLMParams {
1212
/** Source of the tokenizer config. */
1313
tokenizerConfigSource: ResourceSource;
1414

15-
/** Optional download progress callback (0-1). */
15+
/** Download progress callback (0-1). */
1616
onDownloadProgress?: (progress: number) => void;
1717
/** Callback invoked with final full response string. */
1818
responseCallback?: (response: string) => void;
1919
/** Reserved: callback for message history changes (not wired currently). */
2020
messageHistoryCallback?: (messageHistory: Message[]) => void;
2121

22-
/** Optional chat configuration forwarded to ExecuTorch. */
22+
/** Chat configuration forwarded to ExecuTorch. */
2323
chatConfig?: Partial<ChatConfig>;
2424
}
2525

@@ -43,9 +43,9 @@ export class ExecuTorchLLM implements LLM {
4343
* @param params.modelSource - Source of the LLM model.
4444
* @param params.tokenizerSource - Source of the tokenizer.
4545
* @param params.tokenizerConfigSource - Source of the tokenizer config.
46-
* @param params.onDownloadProgress - Optional download progress callback (0-1).
46+
* @param params.onDownloadProgress - Download progress callback (0-1).
4747
* @param params.responseCallback - Callback invoked with final full response string.
48-
* @param params.chatConfig - Optional chat configuration forwarded to ExecuTorch.
48+
* @param params.chatConfig - Chat configuration forwarded to ExecuTorch.
4949
*/
5050
constructor({
5151
modelSource,
@@ -88,10 +88,9 @@ export class ExecuTorchLLM implements LLM {
8888
}
8989

9090
/**
91-
* Interrupts current generation. Note: interrupt is synchronous in ExecuTorch
92-
* at the time of writing; this method resolves immediately after calling interrupt.
91+
* Interrupts current generation.
92+
* Note: current ExecuTorch interrupt is synchronous.
9393
* Awaiting this method will not guarantee completion.
94-
* @returns Promise that resolves when interrupt is initiated.
9594
*/
9695
async interrupt() {
9796
console.warn(
@@ -101,15 +100,16 @@ export class ExecuTorchLLM implements LLM {
101100
}
102101

103102
/**
104-
* Unloads the underlying module. Note: unload is synchronous in ExecuTorch.
103+
* Unloads the underlying module.
104+
* Note: current ExecuTorch unload is synchronous.
105105
* Awaiting this method will not guarantee completion.
106-
* @returns Promise that resolves when unload is initiated.
107106
*/
108107
async unload() {
109108
console.warn(
110109
'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.'
111110
);
112111
this.module.delete();
112+
this.isLoaded = false;
113113
}
114114

115115
/**

packages/op-sqlite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-native-rag/op-sqlite",
3-
"version": "0.2.0",
3+
"version": "0.2.0-rc3",
44
"main": "src/index.ts",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"

0 commit comments

Comments
 (0)