Skip to content

Commit d2eed3c

Browse files
chore: update llms example app with strategy configuration
1 parent 56ff74c commit d2eed3c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

apps/llm/app/llm/index.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import {
1111
View,
1212
} from 'react-native';
1313
import SendIcon from '../../assets/icons/send_icon.svg';
14-
import { useLLM, LLAMA3_2_1B_SPINQUANT } from 'react-native-executorch';
14+
import {
15+
useLLM,
16+
LLAMA3_2_1B_SPINQUANT,
17+
SlidingWindowContextStrategy,
18+
} from 'react-native-executorch';
1519
import PauseIcon from '../../assets/icons/pause_icon.svg';
1620
import ColorPalette from '../../colors';
1721
import Messages from '../../components/Messages';
@@ -32,6 +36,15 @@ function LLMScreen() {
3236

3337
const llm = useLLM({ model: LLAMA3_2_1B_SPINQUANT });
3438

39+
useEffect(() => {
40+
llm.configure({
41+
chatConfig: {
42+
contextStrategy: new SlidingWindowContextStrategy(2048, 512),
43+
},
44+
});
45+
// eslint-disable-next-line react-hooks/exhaustive-deps
46+
}, []);
47+
3548
useEffect(() => {
3649
if (llm.error) {
3750
console.log('LLM error:', llm.error);

0 commit comments

Comments
 (0)