You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: fix CHAPTER-1 to show correct systemPrompt and route patterns
- Updated system prompt section to show updating regularPrompt constant
- Updated route handler to show correct systemPrompt({ selectedChatModel, requestHints })
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
The full route handler uses `createUIMessageStream` with `JsonToSseTransformStream` for streaming - the key thing is adding `getWeather` to the `tools` object and `"getWeather"` to `experimental_activeTools`.
176
+
181
177
### Key Configuration
182
178
183
179
-**`stopWhen: stepCountIs(5)`**: Limits tool call chains to 5 steps
184
180
-**`experimental_activeTools`**: Conditionally enables/disables tools (disabled for reasoning model)
185
181
-**`tools`**: Object containing all available tools
182
+
-**`requestHints`**: Contains user's location (useful for "What's the weather?" without a city)
The AI will use tools based on their `description` field, so you don't *need* to update the system prompt. However, you can optionally add tool documentation to help the AI understand when to use tools.
258
257
259
-
Help the AI know when to use tools:
258
+
The system prompt is built from multiple parts. The simplest way to add tool info is to update the `regularPrompt` constant:
260
259
261
260
```typescript
262
261
// lib/ai/prompts.ts
263
-
exportconst systemPrompt = () =>`
264
-
You are a helpful AI assistant.
262
+
263
+
// Update this constant to include tool documentation
264
+
exportconst regularPrompt =`You are a friendly study buddy assistant! Keep your responses concise and helpful.
265
265
266
266
## Tools Available
267
267
- **getWeather**: Use this when users ask about weather conditions.
268
-
Ask for a city name if not provided.
269
-
270
-
Today's date is ${newDate().toLocaleDateString()}.
268
+
You can provide a city name like "Paris" or "Tokyo".
271
269
`;
270
+
271
+
// The systemPrompt function combines regularPrompt with location hints
272
+
// No need to change this function - it already works!
**Note**: The `requestHints` add the user's location context (city, country, lat/lon), which is useful for the weather tool - the AI can use the user's location as a default if they just say "What's the weather?"
286
+
274
287
## Try It Out: Weather Tool
275
288
276
289
Now that you've wired up the weather tool, test it with these prompts. Click the **"What is the weather in San Francisco?"** button in the chat, or try these variations:
0 commit comments