@@ -65,30 +65,19 @@ import React from 'react';
6565import { Text } from ' react-native' ;
6666
6767import { useRAG , MemoryVectorStore } from ' react-native-rag' ;
68- import {
69- ALL_MINILM_L6_V2 ,
70- ALL_MINILM_L6_V2_TOKENIZER ,
71- LLAMA3_2_1B_QLORA ,
72- LLAMA3_2_1B_TOKENIZER ,
73- LLAMA3_2_TOKENIZER_CONFIG ,
74- } from ' react-native-executorch' ;
68+ import { models } from ' react-native-executorch' ;
7569import {
7670 ExecuTorchEmbeddings ,
7771 ExecuTorchLLM ,
7872} from ' @react-native-rag/executorch' ;
7973
8074const vectorStore = new MemoryVectorStore ({
81- embeddings: new ExecuTorchEmbeddings ({
82- modelSource: ALL_MINILM_L6_V2 ,
83- tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER ,
84- }),
75+ embeddings: new ExecuTorchEmbeddings (
76+ models .text_embedding .all_minilm_l6_v2 ()
77+ ),
8578});
8679
87- const llm = new ExecuTorchLLM ({
88- modelSource: LLAMA3_2_1B_QLORA ,
89- tokenizerSource: LLAMA3_2_1B_TOKENIZER ,
90- tokenizerConfigSource: LLAMA3_2_TOKENIZER_CONFIG ,
91- });
80+ const llm = new ExecuTorchLLM (models .llm .lfm2_5_1_2b_instruct ());
9281
9382const App = () => {
9483 const rag = useRAG ({ vectorStore , llm });
@@ -109,29 +98,20 @@ import {
10998 ExecuTorchEmbeddings ,
11099 ExecuTorchLLM ,
111100} from ' @react-native-rag/executorch' ;
112- import {
113- ALL_MINILM_L6_V2 ,
114- ALL_MINILM_L6_V2_TOKENIZER ,
115- LLAMA3_2_1B_QLORA ,
116- LLAMA3_2_1B_TOKENIZER ,
117- LLAMA3_2_TOKENIZER_CONFIG ,
118- } from ' react-native-executorch' ;
101+ import { models } from ' react-native-executorch' ;
119102
120103const App = () => {
121104 const [rag, setRag] = useState <RAG | null >(null );
122105 const [response, setResponse] = useState <string | null >(null );
123106
124107 useEffect (() => {
125108 const initializeRAG = async () => {
126- const embeddings = new ExecuTorchEmbeddings ({
127- modelSource: ALL_MINILM_L6_V2 ,
128- tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER ,
129- });
109+ const embeddings = new ExecuTorchEmbeddings (
110+ models .text_embedding .all_minilm_l6_v2 ()
111+ );
130112
131113 const llm = new ExecuTorchLLM ({
132- modelSource: LLAMA3_2_1B_QLORA ,
133- tokenizerSource: LLAMA3_2_1B_TOKENIZER ,
134- tokenizerConfigSource: LLAMA3_2_TOKENIZER_CONFIG ,
114+ ... models .llm .lfm2_5_1_2b_instruct (),
135115 responseCallback: setResponse ,
136116 });
137117
@@ -163,13 +143,7 @@ import {
163143 ExecuTorchEmbeddings ,
164144 ExecuTorchLLM ,
165145} from ' @react-native-rag/executorch' ;
166- import {
167- ALL_MINILM_L6_V2 ,
168- ALL_MINILM_L6_V2_TOKENIZER ,
169- LLAMA3_2_1B_QLORA ,
170- LLAMA3_2_1B_TOKENIZER ,
171- LLAMA3_2_TOKENIZER_CONFIG ,
172- } from ' react-native-executorch' ;
146+ import { models } from ' react-native-executorch' ;
173147
174148const App = () => {
175149 const [embeddings, setEmbeddings] = useState <ExecuTorchEmbeddings | null >(null );
@@ -182,16 +156,13 @@ const App = () => {
182156 // Instantiate and load the Embeddings Model
183157 // NOTE: Calling load on VectorStore will automatically load the embeddings model
184158 // so loading the embeddings model separately is not necessary in this case.
185- const embeddings = await new ExecuTorchEmbeddings ({
186- modelSource: ALL_MINILM_L6_V2 ,
187- tokenizerSource: ALL_MINILM_L6_V2_TOKENIZER ,
188- }).load ();
159+ const embeddings = await new ExecuTorchEmbeddings (
160+ models .text_embedding .all_minilm_l6_v2 ()
161+ ).load ();
189162
190163 // Instantiate and load the Large Language Model
191164 const llm = await new ExecuTorchLLM ({
192- modelSource: LLAMA3_2_1B_QLORA ,
193- tokenizerSource: LLAMA3_2_1B_TOKENIZER ,
194- tokenizerConfigSource: LLAMA3_2_TOKENIZER_CONFIG ,
165+ ... models .llm .lfm2_5_1_2b_instruct (),
195166 responseCallback: setResponse ,
196167 }).load ();
197168
0 commit comments