@youdotcom-oss/ai-sdk-plugin 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +54 -5
  2. package/dist/main.js +9386 -91
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -12,6 +12,21 @@ Build AI applications that can:
12
12
  - **Type-safe** - Full TypeScript support with Zod schema validation
13
13
  - **Production-ready** - Built on You.com's enterprise search API
14
14
 
15
+ ## AI Agent Skills
16
+
17
+ **For AI SDK Integration**: Use the [ydc-ai-sdk-integration](https://github.com/youdotcom-oss/agent-skills/tree/main/skills/ydc-ai-sdk-integration) skill to quickly integrate You.com tools with your Vercel AI SDK applications.
18
+
19
+ ```bash
20
+ # Install the AI SDK integration skill
21
+ npx skills add youdotcom-oss/agent-skills --skill ydc-ai-sdk-integration
22
+ ```
23
+
24
+ Once installed, ask your AI agent: **"Integrate Vercel AI SDK with You.com tools"**
25
+
26
+ **Supported AI agents**: Claude Code, Cursor, Windsurf, Cody, Continue, and more.
27
+
28
+ See [Skill Documentation](https://github.com/youdotcom-oss/agent-skills/tree/main/skills/ydc-ai-sdk-integration) for complete integration guide.
29
+
15
30
  ## Getting started
16
31
 
17
32
  Get up and running in 4 quick steps:
@@ -41,7 +56,7 @@ Import the tools and add them to your AI SDK configuration:
41
56
 
42
57
  ```typescript
43
58
  import { createAnthropic } from '@ai-sdk/anthropic';
44
- import { generateText } from 'ai';
59
+ import { generateText, stepCountIs } from 'ai';
45
60
  import { youSearch, youContents } from '@youdotcom-oss/ai-sdk-plugin';
46
61
 
47
62
  // Create your AI model provider
@@ -55,7 +70,7 @@ const result = await generateText({
55
70
  search: youSearch(),
56
71
  extract: youContents(),
57
72
  },
58
- maxSteps: 5,
73
+ stopWhen: stepCountIs(5), // Required for tool result processing
59
74
  prompt: 'Search for the latest developments in quantum computing',
60
75
  });
61
76
 
@@ -153,6 +168,8 @@ export type YouToolsConfig = {
153
168
  This plugin works with any AI SDK compatible model provider:
154
169
 
155
170
  ```typescript
171
+ import { generateText, stepCountIs } from 'ai';
172
+
156
173
  // Anthropic Claude
157
174
  import { createAnthropic } from '@ai-sdk/anthropic';
158
175
 
@@ -163,6 +180,7 @@ const anthropic = createAnthropic({
163
180
  const result = await generateText({
164
181
  model: anthropic('claude-sonnet-4-5-20250929'),
165
182
  tools: { search: youSearch() },
183
+ stopWhen: stepCountIs(3),
166
184
  prompt: 'Search for AI news',
167
185
  });
168
186
 
@@ -176,6 +194,7 @@ const openai = createOpenAI({
176
194
  const result = await generateText({
177
195
  model: openai('gpt-4'),
178
196
  tools: { search: youSearch() },
197
+ stopWhen: stepCountIs(3),
179
198
  prompt: 'Search for AI news',
180
199
  });
181
200
 
@@ -189,6 +208,7 @@ const google = createGoogleGenerativeAI({
189
208
  const result = await generateText({
190
209
  model: google('gemini-2.0-flash-exp'),
191
210
  tools: { search: youSearch() },
211
+ stopWhen: stepCountIs(3),
192
212
  prompt: 'Search for AI news',
193
213
  });
194
214
  ```
@@ -219,7 +239,7 @@ Extract full page content from URLs in markdown or HTML format. Useful for docum
219
239
 
220
240
  ---
221
241
 
222
- **Note**: Your AI automatically selects the right tool based on the user's request. Simply set `maxSteps` to allow multiple tool calls, and your AI handles the orchestration.
242
+ **Note**: Your AI automatically selects the right tool based on the user's request. Use `stopWhen: stepCountIs(n)` to enable multi-step tool execution, and your AI handles the orchestration.
223
243
 
224
244
  ## Examples
225
245
 
@@ -273,10 +293,11 @@ const search = youSearch({ apiKey: 'your-api-key-here' });
273
293
 
274
294
  ### Problem: AI isn't using the tools
275
295
 
276
- **Solution**: Make sure you're setting `maxSteps` to allow multiple tool calls:
296
+ **Solution**: Make sure you're using `stopWhen` to enable multi-step tool execution:
277
297
 
278
298
  ```typescript
279
299
  import { createAnthropic } from '@ai-sdk/anthropic';
300
+ import { generateText, stepCountIs } from 'ai';
280
301
 
281
302
  const anthropic = createAnthropic({
282
303
  apiKey: process.env.ANTHROPIC_API_KEY,
@@ -285,11 +306,39 @@ const anthropic = createAnthropic({
285
306
  const result = await generateText({
286
307
  model: anthropic('claude-sonnet-4-5-20250929'),
287
308
  tools: { search: youSearch() },
288
- maxSteps: 5, // Required: allows AI to use tools
309
+ stopWhen: stepCountIs(3), // Required: enables tool result processing
289
310
  prompt: 'Search for recent AI news',
290
311
  });
291
312
  ```
292
313
 
314
+ ### Problem: Tools execute but response is empty
315
+
316
+ **Symptoms**: You see tool calls in `result.steps` but `result.text` is empty or minimal.
317
+
318
+ **Solution**: Replace `maxSteps` with `stopWhen: stepCountIs(n)`:
319
+
320
+ ```typescript
321
+ import { generateText, stepCountIs } from 'ai';
322
+
323
+ // ❌ WRONG - tools execute but results aren't integrated
324
+ const result = await generateText({
325
+ model: anthropic('claude-sonnet-4-5-20250929'),
326
+ tools: { search: youSearch() },
327
+ maxSteps: 5, // Don't use this!
328
+ prompt: 'Search for AI news',
329
+ });
330
+
331
+ // ✅ CORRECT - tool results properly integrated
332
+ const result = await generateText({
333
+ model: anthropic('claude-sonnet-4-5-20250929'),
334
+ tools: { search: youSearch() },
335
+ stopWhen: stepCountIs(3), // Use this instead
336
+ prompt: 'Search for AI news',
337
+ });
338
+ ```
339
+
340
+ **Why this happens**: `maxSteps` doesn't properly integrate tool results into the response generation. The `stopWhen` pattern ensures the AI processes tool outputs before stopping.
341
+
293
342
  ### Problem: Getting 401 authentication errors
294
343
 
295
344
  **Solution**: Verify your API key is correct and properly set: