Skip to content

Commit fec4dc1

Browse files
committed
refactor: get rid of not used LlmContext
1 parent 9fad500 commit fec4dc1

File tree

5 files changed

+2
-60
lines changed

5 files changed

+2
-60
lines changed

apps/llm/app/_layout.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import { Drawer } from 'expo-router/drawer';
22
import ColorPalette from '../colors';
33
import React from 'react';
4-
import { LlmProvider, useLlmContext } from '../contexts/LlmContext';
54

65
function DrawerWithScreens() {
7-
const { isGenerating } = useLlmContext();
86
return (
97
<Drawer
108
screenOptions={{
119
drawerActiveTintColor: ColorPalette.primary,
1210
drawerInactiveTintColor: '#888',
1311
headerTintColor: ColorPalette.primary,
1412
headerTitleStyle: { color: ColorPalette.primary },
15-
swipeEnabled: !isGenerating,
1613
}}
1714
>
1815
<Drawer.Screen
@@ -52,9 +49,5 @@ function DrawerWithScreens() {
5249
}
5350

5451
export default function _layout() {
55-
return (
56-
<LlmProvider>
57-
<DrawerWithScreens />
58-
</LlmProvider>
59-
);
52+
return <DrawerWithScreens />;
6053
}

apps/llm/app/llm/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ import {
2121
import PauseIcon from '../../assets/icons/pause_icon.svg';
2222
import ColorPalette from '../../colors';
2323
import Messages from '../../components/Messages';
24-
import { useLlmContext } from '../../contexts/LlmContext';
2524

2625
export default function LLMScreen() {
27-
const { setIsGenerating } = useLlmContext();
2826
const [isTextInputFocused, setIsTextInputFocused] = useState(false);
2927
const [userInput, setUserInput] = useState('');
3028
const textInputRef = useRef<TextInput>(null);
@@ -35,10 +33,6 @@ export default function LLMScreen() {
3533
tokenizerConfigSource: LLAMA3_2_TOKENIZER_CONFIG,
3634
});
3735

38-
useEffect(() => {
39-
setIsGenerating(llm.isGenerating);
40-
}, [llm.isGenerating, setIsGenerating]);
41-
4236
useEffect(() => {
4337
if (llm.error) {
4438
console.log('LLM error:', llm.error);

apps/llm/app/llm_tool_calling/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ import Messages from '../../components/Messages';
2626
import * as Brightness from 'expo-brightness';
2727
import * as Calendar from 'expo-calendar';
2828
import { executeTool, TOOL_DEFINITIONS_PHONE } from '../../utils/tools';
29-
import { useLlmContext } from '../../contexts/LlmContext';
3029

3130
export default function LLMToolCallingScreen() {
32-
const { setIsGenerating } = useLlmContext();
3331
const [isTextInputFocused, setIsTextInputFocused] = useState(false);
3432
const [userInput, setUserInput] = useState('');
3533
const textInputRef = useRef<TextInput>(null);
@@ -40,10 +38,6 @@ export default function LLMToolCallingScreen() {
4038
tokenizerConfigSource: HAMMER2_1_TOKENIZER_CONFIG,
4139
});
4240

43-
useEffect(() => {
44-
setIsGenerating(llm.isGenerating);
45-
}, [llm.isGenerating, setIsGenerating]);
46-
4741
const { configure } = llm;
4842
useEffect(() => {
4943
configure({

apps/llm/app/voice_chat/index.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRef, useState, useEffect } from 'react';
1+
import { useRef, useState } from 'react';
22
import {
33
Keyboard,
44
KeyboardAvoidingView,
@@ -27,7 +27,6 @@ import Messages from '../../components/Messages';
2727
import LiveAudioStream from 'react-native-live-audio-stream';
2828
import DeviceInfo from 'react-native-device-info';
2929
import { Buffer } from 'buffer';
30-
import { useLlmContext } from '../../contexts/LlmContext';
3130
const audioStreamOptions = {
3231
sampleRate: 16000,
3332
channels: 1,
@@ -57,7 +56,6 @@ const float32ArrayFromPCMBinaryBuffer = (b64EncodedBuffer: string) => {
5756
};
5857

5958
export default function VoiceChatScreen() {
60-
const { setIsGenerating } = useLlmContext();
6159
const [isRecording, setIsRecording] = useState(false);
6260
const messageRecorded = useRef<boolean>(false);
6361

@@ -72,10 +70,6 @@ export default function VoiceChatScreen() {
7270
overlapSeconds: 1.2,
7371
});
7472

75-
useEffect(() => {
76-
setIsGenerating(llm.isGenerating || speechToText.isGenerating);
77-
}, [llm.isGenerating, speechToText.isGenerating, setIsGenerating]);
78-
7973
const onChunk = (data: string) => {
8074
const float32Chunk = float32ArrayFromPCMBinaryBuffer(data);
8175
speechToText.streamingTranscribe(

apps/llm/contexts/LlmContext.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)