Skip to content

Commit b53f3ee

Browse files
docs: fix type errors and missing import in llm docs (#514)
## Description Fix missing types in llm docs and errors in code ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [x] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions <!-- Provide step-by-step instructions on how to test your changes. Include setup details if necessary. --> ### Screenshots <!-- Add screenshots here, if applicable --> ### Related issues <!-- Link related issues here using #issue-number --> ### Checklist - [x] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. -->
1 parent 1ad9195 commit b53f3ee

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Add this to your component file:
6868
import {
6969
useLLM,
7070
LLAMA3_2_1B,
71+
Message
7172
} from 'react-native-executorch';
7273

7374
function MyComponent() {
@@ -81,7 +82,7 @@ function MyComponent() {
8182

8283
```tsx
8384
const handleGenerate = async () => {
84-
const chat = [
85+
const chat: Message[] = [
8586
{ role: 'system', content: 'You are a helpful assistant' },
8687
{ role: 'user', content: 'What is the meaning of life?' }
8788
];

docs/docs/02-hooks/01-natural-language-processing/useLLM.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ To perform chat completion you can use the `generate` function. There is no retu
165165
const llm = useLLM({ model: LLAMA3_2_1B });
166166

167167
const handleGenerate = () => {
168-
const chat = [
168+
const chat: Message[] = [
169169
{ role: 'system', content: 'You are a helpful assistant' },
170170
{ role: 'user', content: 'Hi!' },
171171
{ role: 'assistant', content: 'Hi!, how can I help you?' },
@@ -220,7 +220,7 @@ const TOOL_DEFINITIONS: LLMTool[] = [
220220
const llm = useLLM({ model: HAMMER2_1_1_5B });
221221

222222
const handleGenerate = () => {
223-
const chat = [
223+
const chat: Message[] = [
224224
{
225225
role: 'system',
226226
content: `You are a helpful assistant. Current time and date: ${new Date().toString()}`,
@@ -361,6 +361,8 @@ return (
361361
### Structured output example
362362

363363
```tsx
364+
import { Schema } from 'jsonschema';
365+
364366
const responseSchema: Schema = {
365367
properties: {
366368
username: {
@@ -407,7 +409,7 @@ useEffect(() => {
407409
// Some extra prompting to improve quality of response.
408410
const prompt = `Your goal is to parse user's messages and return them in JSON format. Don't respond to user. Simply return JSON with user's question parsed. \n${formattingInstructions}\n /no_think`;
409411

410-
configure({
412+
llm.configure({
411413
chatConfig: {
412414
systemPrompt: prompt,
413415
},

docs/versioned_docs/version-0.4.x/natural-language-processing/useLLM.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const llm = useLLM({
174174
});
175175

176176
const handleGenerate = () => {
177-
const chat = [
177+
const chat: Message[] = [
178178
{ role: 'system', content: 'You are a helpful assistant' },
179179
{ role: 'user', content: 'Hi!' },
180180
{ role: 'assistant', content: 'Hi!, how can I help you?'},
@@ -231,7 +231,7 @@ const llm = useLLM({
231231
});
232232

233233
const handleGenerate = () => {
234-
const chat = [
234+
const chat: Message[] = [
235235
{
236236
role: 'system',
237237
content: `You are a helpful assistant. Current time and date: ${new Date().toString()}`,

0 commit comments

Comments
 (0)