Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type Message, MemoryVectorStore, useRAG } from 'react-native-rag';
import { type Message, useRAG } from 'react-native-rag';
import { OPSQLiteVectorStore } from '@react-native-rag/op-sqlite';
import {
QWEN3_0_6B_QUANTIZED,
ALL_MINILM_L6_V2,
Expand Down Expand Up @@ -32,7 +33,8 @@ export default function App() {
const [messages, setMessages] = useState<Message[]>([]);

const vectorStore = useMemo(() => {
return new MemoryVectorStore({
return new OPSQLiteVectorStore({
name: 'rag_example_db1',
embeddings: new ExecuTorchEmbeddings(ALL_MINILM_L6_V2),
});
}, []);
Expand All @@ -55,13 +57,11 @@ export default function App() {
try {
if (ids.length) {
for (const id of ids) {
await rag.deleteDocument({
ids: [id],
});
await rag.deleteDocument({ predicate: (value) => value.id === id });
}
setIds([]);
}
const newIds = await rag.splitAddDocument(document);
const newIds = await rag.splitAddDocument({ document });
setIds(newIds);
console.log('Document splitted and added with IDs:', newIds);
setModalVisible(false);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-rag",
"version": "0.2.0",
"version": "0.2.0-rc3",
"description": "Private, local RAGs. Supercharge LLMs with your own knowledge base.",
"main": "./lib/module/index.js",
"types": "./lib/typescript/src/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/executorch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-rag/executorch",
"version": "0.2.0",
"version": "0.2.0-rc3",
"main": "src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
10 changes: 5 additions & 5 deletions packages/executorch/src/wrappers/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ExecuTorchEmbeddingsParams {
modelSource: ResourceSource;
/** Source of the tokenizer model. */
tokenizerSource: ResourceSource;
/** Optional download progress callback (0-1). */
/** Download progress callback (0-1). */
onDownloadProgress?: (progress: number) => void;
}

Expand All @@ -29,7 +29,7 @@ export class ExecuTorchEmbeddings implements Embeddings {
* @param params - Parameters for the instance.
* @param params.modelSource - Source of the embedding model.
* @param params.tokenizerSource - Source of the tokenizer.
* @param params.onDownloadProgress - Optional download progress callback (0-1).
* @param params.onDownloadProgress - Download progress callback (0-1).
*/
constructor({
modelSource,
Expand Down Expand Up @@ -61,16 +61,16 @@ export class ExecuTorchEmbeddings implements Embeddings {
}

/**
* Unloads the underlying module. Note: unload is synchronous in ExecuTorch
* at the time of writing; this method resolves immediately after calling delete.
* Unloads the underlying module.
* Note: current ExecuTorch unload is synchronous.
* Awaiting this method will not guarantee completion.
* @returns Promise that resolves when unloading is initiated.
*/
async unload() {
console.warn(
'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.'
);
this.module.delete();
this.isLoaded = false;
}

/**
Expand Down
18 changes: 9 additions & 9 deletions packages/executorch/src/wrappers/llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ interface ExecuTorchLLMParams {
/** Source of the tokenizer config. */
tokenizerConfigSource: ResourceSource;

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

/** Optional chat configuration forwarded to ExecuTorch. */
/** Chat configuration forwarded to ExecuTorch. */
chatConfig?: Partial<ChatConfig>;
}

Expand All @@ -43,9 +43,9 @@ export class ExecuTorchLLM implements LLM {
* @param params.modelSource - Source of the LLM model.
* @param params.tokenizerSource - Source of the tokenizer.
* @param params.tokenizerConfigSource - Source of the tokenizer config.
* @param params.onDownloadProgress - Optional download progress callback (0-1).
* @param params.onDownloadProgress - Download progress callback (0-1).
* @param params.responseCallback - Callback invoked with final full response string.
* @param params.chatConfig - Optional chat configuration forwarded to ExecuTorch.
* @param params.chatConfig - Chat configuration forwarded to ExecuTorch.
*/
constructor({
modelSource,
Expand Down Expand Up @@ -88,10 +88,9 @@ export class ExecuTorchLLM implements LLM {
}

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

/**
* Unloads the underlying module. Note: unload is synchronous in ExecuTorch.
* Unloads the underlying module.
* Note: current ExecuTorch unload is synchronous.
* Awaiting this method will not guarantee completion.
* @returns Promise that resolves when unload is initiated.
*/
async unload() {
console.warn(
'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.'
);
this.module.delete();
this.isLoaded = false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/op-sqlite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-rag/op-sqlite",
"version": "0.2.0",
"version": "0.2.0-rc3",
"main": "src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
Loading