You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -40,7 +32,7 @@ Private, local RAGs. Supercharge LLMs with your own knowledge base.
40
32
41
33
React Native RAG is powering [Private Mind](https://github.com/software-mansion-labs/private-mind), a privacy-first mobile AI app available on [App Store](https://apps.apple.com/gb/app/private-mind/id6746713439) and [Google Play](https://play.google.com/store/apps/details?id=com.swmansion.privatemind).
42
34
43
-
<imgwidth="2720"height="1085"alt="Private Mind promo"src="https://github.com/user-attachments/assets/2a5ebb32-0146-4b8e-875f-b25bb5cc50e4" />
35
+
<imgwidth="2720"alt="Private Mind promo"src="https://github.com/user-attachments/assets/2a5ebb32-0146-4b8e-875f-b25bb5cc50e4" />
44
36
45
37
## :package: Installation
46
38
@@ -69,7 +61,7 @@ We offer three ways to integrate RAG, depending on your needs.
69
61
The easiest way to get started. Good for simple use cases where you want to quickly set up RAG.
*`callback` (`function`, optional): A function that receives tokens as they are generated.
285
-
*`async splitAddDocument(document: string, metadataGenerator?: (chunks: string[]) => Record<string, any>[], textSplitter?: TextSplitter): Promise<string[]>`: Splits a document into chunks and adds them to the vector store.
286
-
*`async addDocument(document: string, metadata?: Record<string, any>): Promise<string>`: Adds a single document to the vector store.
287
-
*`async updateDocument(id: string, document?: string, metadata?: Record<string, any>): Promise<void>`: Updates a document in the vector store.
288
-
*`async deleteDocument(id: string): Promise<void>`: Deletes a document from the vector store.
289
-
*`async interrupt(): Promise<void>`: Interrupts the ongoing LLM generation.
290
-
291
-
#### `MemoryVectorStore`
292
-
293
-
An in-memory implementation of the `VectorStore` interface. Useful for development and testing without persistent storage or when you don't need to save documents across app restarts.
*`params`: Requires an `embeddings` instance to generate vectors for documents.
298
-
299
-
*`async load(): Promise<this>`: Loads the Embeddings model.
300
-
301
-
*`async unload(): Promise<void>`: Unloads the Embeddings model.
302
-
303
-
### Interfaces (for Custom Components)
304
-
305
-
These interfaces define the contracts for creating your own custom components.
306
-
307
-
#### `Embeddings`
308
-
309
-
*`load: () => Promise<this>`: Loads the embedding model.
310
-
*`unload: () => Promise<void>`: Unloads the model.
311
-
*`embed: (text: string) => Promise<number[]>`: Generates an embedding for a given text.
312
-
313
-
#### `LLM`
314
-
315
-
*`load: () => Promise<this>`: Loads the language model.
316
-
*`interrupt: () => Promise<void>`: Stops the current text generation.
317
-
*`unload: () => Promise<void>`: Unloads the model.
318
-
*`generate: (messages: Message[], callback: (token: string) => void) => Promise<string>`: Generates a response from a list of messages, streaming tokens to the callback.
319
-
320
-
#### `VectorStore`
321
-
322
-
*`load: () => Promise<this>`: Initializes the vector store.
323
-
*`unload: () => Promise<void>`: Unloads the vector store and releases resources.
324
-
*`add(document: string, metadata?: Record<string, any>): Promise<string>`: Adds a document.
*`delete(id: string): Promise<void>`: Deletes a document.
327
-
*`similaritySearch(query: string, k?: number, predicate?: (value: SearchResult) => boolean): Promise<SearchResult[]>`: Searches for `k` similar documents. Which can be filtered with an optional `predicate` function.
328
-
329
-
#### `TextSplitter`
330
-
331
-
*`splitText: (text: string) => Promise<string[]>`: Splits text into an array of chunks.
332
-
333
-
### Text Splitters
334
-
335
-
The library provides wrappers around common `langchain` text splitters. All splitters are initialized with `{ chunkSize: number, chunkOverlap: number }`.
336
-
337
-
*`RecursiveCharacterTextSplitter`: Splits text recursively by different characters. (Default in `RAG` class).
338
-
*`CharacterTextSplitter`: Splits text by a fixed character count.
339
-
*`TokenTextSplitter`: Splits text by token count.
340
-
*`MarkdownTextSplitter`: Splits text while preserving Markdown structure.
341
-
*`LatexTextSplitter`: Splits text while preserving LaTeX structure.
342
-
343
-
### Utilities
344
-
345
-
*`uuidv4(): string`: Generates a compliant Version 4 UUID. Not cryptographically secure.
346
-
*`cosine(a: number[], b: number[]): number`: Calculates the cosine similarity between two vectors.
347
-
*`dotProduct(a: number[], b: number[]): number`: Calculates the dot product of two vectors.
348
-
*`magnitude(a: number[]): number`: Calculates the Euclidean magnitude of a vector.
349
-
350
-
### Types
351
-
352
-
```typescript
353
-
interfaceMessage {
354
-
role:'user'|'assistant'|'system';
355
-
content:string;
356
-
}
357
-
358
-
typeResourceSource=string|number|object;
359
-
360
-
interfaceSearchResult {
361
-
id:string;
362
-
content:string;
363
-
metadata?:Record<string, any>;
364
-
similarity:number;
365
-
}
208
+
return <Text>{response}</Text>;
209
+
};
366
210
```
367
211
368
212
## :jigsaw: Using Custom Components
369
213
370
214
Bring your own components by creating classes that implement the `LLM`, `Embeddings`, `VectorStore` and `TextSplitter` interfaces. This allows you to use any model or service that fits your needs.
0 commit comments