()
| 33 | ]; |
| 34 | |
| 35 | const ToolCallingScreen = () => { |
| 36 | const cactusLM = useCactusLM({ model: 'qwen3-0.6b' }); |
| 37 | const [input, setInput] = useState("What's the weather in San Francisco?"); |
| 38 | const [result, setResult] = useState<CactusLMCompleteResult | null>(null); |
| 39 | |
| 40 | useEffect(() => { |
| 41 | if (!cactusLM.isDownloaded) { |
| 42 | cactusLM.download(); |
| 43 | } |
| 44 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 45 | }, [cactusLM.isDownloaded]); |
| 46 | |
| 47 | const handleComplete = async () => { |
| 48 | const messages: CactusLMMessage[] = [ |
| 49 | { |
| 50 | role: 'system', |
| 51 | content: 'You are a helpful assistant that can call tools.', |
| 52 | }, |
| 53 | { role: 'user', content: input }, |
| 54 | ]; |
| 55 | |
| 56 | const completionResult = await cactusLM.complete({ |
| 57 | messages, |
| 58 | tools, |
| 59 | options: { forceTools: true }, |
| 60 | }); |
| 61 | setResult(completionResult); |
| 62 | }; |
| 63 | |
| 64 | const handleInit = () => { |
| 65 | cactusLM.init(); |
| 66 | }; |
| 67 | |
| 68 | const handleStop = () => { |
| 69 | cactusLM.stop(); |
| 70 | }; |
| 71 | |
| 72 | const handleReset = () => { |
| 73 | cactusLM.reset(); |
| 74 | }; |
| 75 | |
| 76 | const handleDestroy = () => { |
| 77 | cactusLM.destroy(); |
| 78 | }; |
| 79 | |
| 80 | if (cactusLM.isDownloading) { |
| 81 | return ( |
| 82 | <View style={styles.centerContainer}> |
| 83 | <ActivityIndicator size="large" /> |
| 84 | <Text style={styles.progressText}> |
| 85 | Downloading model: {Math.round(cactusLM.downloadProgress * 100)}% |
| 86 | </Text> |
| 87 | </View> |
| 88 | ); |
| 89 | } |
| 90 | |
| 91 | return ( |
| 92 | <ScrollView style={styles.container} contentContainerStyle={styles.content}> |
nothing calls this directly
no test coverage detected