@youdotcom-oss/ai-sdk-plugin 0.1.0
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.
- package/README.md +372 -0
- package/dist/main.d.ts +146 -0
- package/dist/main.js +4748 -0
- package/package.json +80 -0
- package/templates/generate-text.ts +78 -0
- package/templates/streaming-text.ts +123 -0
package/README.md
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
# Vercel AI SDK Plugin for You.com
|
|
2
|
+
|
|
3
|
+
Give your AI applications **real-time access to the web** with native AI SDK tools. Search current content, get AI-generated answers with web context, and extract live web pages—all through simple function calls. Built for the [Vercel AI SDK](https://sdk.vercel.ai/), this plugin brings **You.com's search, AI agents, and content extraction directly into your AI applications** with zero server setup.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
Build AI applications that can:
|
|
8
|
+
- **Search the web in real-time** - Access current information with advanced filtering (dates, sites, file types)
|
|
9
|
+
- **Generate answers with web context** - Fast AI responses enhanced with live web data
|
|
10
|
+
- **Extract any webpage** - Pull full content in markdown or HTML format
|
|
11
|
+
- **Zero configuration** - Works with any AI SDK model provider (Anthropic, OpenAI, Google, and more)
|
|
12
|
+
- **Type-safe** - Full TypeScript support with Zod schema validation
|
|
13
|
+
- **Production-ready** - Built on You.com's enterprise search API
|
|
14
|
+
|
|
15
|
+
## Getting started
|
|
16
|
+
|
|
17
|
+
Get up and running in 4 quick steps:
|
|
18
|
+
|
|
19
|
+
### 1. Get your API key
|
|
20
|
+
|
|
21
|
+
Visit [you.com/platform/api-keys](https://you.com/platform/api-keys) to get your You.com API key. Keep this key secure - you'll need it for configuration.
|
|
22
|
+
|
|
23
|
+
### 2. Install the package (NPM, Bun, or Yarn)
|
|
24
|
+
|
|
25
|
+
Choose your package manager:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# NPM
|
|
29
|
+
npm install @youdotcom-oss/ai-sdk-plugin ai
|
|
30
|
+
|
|
31
|
+
# Bun
|
|
32
|
+
bun add @youdotcom-oss/ai-sdk-plugin ai
|
|
33
|
+
|
|
34
|
+
# Yarn
|
|
35
|
+
yarn add @youdotcom-oss/ai-sdk-plugin ai
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3. Add tools to your application
|
|
39
|
+
|
|
40
|
+
Import the tools and add them to your AI SDK configuration:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
44
|
+
import { generateText } from 'ai';
|
|
45
|
+
import { youSearch, youExpress, youContents } from '@youdotcom-oss/ai-sdk-plugin';
|
|
46
|
+
|
|
47
|
+
// Create your AI model provider
|
|
48
|
+
const anthropic = createAnthropic({
|
|
49
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const result = await generateText({
|
|
53
|
+
model: anthropic('claude-sonnet-4-5-20250929'),
|
|
54
|
+
tools: {
|
|
55
|
+
search: youSearch(),
|
|
56
|
+
agent: youExpress(),
|
|
57
|
+
extract: youContents(),
|
|
58
|
+
},
|
|
59
|
+
maxSteps: 5,
|
|
60
|
+
prompt: 'Search for the latest developments in quantum computing',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log(result.text);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Set your API keys as environment variables:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
export YDC_API_KEY=your-api-key-here
|
|
70
|
+
export ANTHROPIC_API_KEY=your-anthropic-api-key-here
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 4. Test your setup
|
|
74
|
+
|
|
75
|
+
Ask your AI something that needs real-time information:
|
|
76
|
+
|
|
77
|
+
- "What are the latest developments in quantum computing?"
|
|
78
|
+
- "Find recent articles about sustainable energy and summarize the key trends"
|
|
79
|
+
- "Extract and analyze the content from https://anthropic.com"
|
|
80
|
+
|
|
81
|
+
Your AI will automatically choose the right tool and return up-to-date, accurate answers.
|
|
82
|
+
|
|
83
|
+
## What you can build
|
|
84
|
+
|
|
85
|
+
Your AI can now handle requests like these:
|
|
86
|
+
|
|
87
|
+
### Research & information
|
|
88
|
+
|
|
89
|
+
**Current events:**
|
|
90
|
+
- "What's trending in AI research this week?"
|
|
91
|
+
- "Find the latest news about climate policy from the past month"
|
|
92
|
+
|
|
93
|
+
**Comparative research:**
|
|
94
|
+
- "Compare the features of the top 3 CRM platforms"
|
|
95
|
+
- "What are developers saying about the new React version?"
|
|
96
|
+
|
|
97
|
+
**Technical documentation:**
|
|
98
|
+
- "Search for TypeScript best practices on the official docs"
|
|
99
|
+
- "Find examples of using WebAssembly in production"
|
|
100
|
+
|
|
101
|
+
### Content analysis & extraction
|
|
102
|
+
|
|
103
|
+
**Documentation analysis:**
|
|
104
|
+
- "Extract and summarize the main points from https://docs.example.com"
|
|
105
|
+
- "Get the pricing information from https://competitor.com/pricing"
|
|
106
|
+
|
|
107
|
+
**Multi-page research:**
|
|
108
|
+
- "Extract content from these 3 blog posts and compare their approaches"
|
|
109
|
+
- "Pull the documentation from these URLs and create a summary"
|
|
110
|
+
|
|
111
|
+
### Real-time workflows
|
|
112
|
+
|
|
113
|
+
**Market intelligence:**
|
|
114
|
+
- "What's the current status of the stock market?"
|
|
115
|
+
- "Find recent funding announcements in the AI space"
|
|
116
|
+
|
|
117
|
+
**Competitive analysis:**
|
|
118
|
+
- "Search for recent product launches by our competitors"
|
|
119
|
+
- "Extract feature comparisons from competitor websites"
|
|
120
|
+
|
|
121
|
+
## Configuration
|
|
122
|
+
|
|
123
|
+
The plugin works out of the box with environment variables:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
export YDC_API_KEY=your-api-key-here
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
<details>
|
|
130
|
+
<summary>Advanced configuration options</summary>
|
|
131
|
+
|
|
132
|
+
### Passing API key directly
|
|
133
|
+
|
|
134
|
+
You can configure tools individually instead of using environment variables:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { youSearch } from '@youdotcom-oss/ai-sdk-plugin';
|
|
138
|
+
|
|
139
|
+
const search = youSearch({
|
|
140
|
+
apiKey: 'your-api-key-here', // Override YDC_API_KEY environment variable
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Configuration type
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
export type YouToolsConfig = {
|
|
148
|
+
apiKey?: string; // You.com API key (defaults to YDC_API_KEY env var)
|
|
149
|
+
};
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Using different model providers
|
|
153
|
+
|
|
154
|
+
This plugin works with any AI SDK compatible model provider:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// Anthropic Claude
|
|
158
|
+
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
159
|
+
|
|
160
|
+
const anthropic = createAnthropic({
|
|
161
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const result = await generateText({
|
|
165
|
+
model: anthropic('claude-sonnet-4-5-20250929'),
|
|
166
|
+
tools: { search: youSearch() },
|
|
167
|
+
prompt: 'Search for AI news',
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// OpenAI
|
|
171
|
+
import { createOpenAI } from '@ai-sdk/openai';
|
|
172
|
+
|
|
173
|
+
const openai = createOpenAI({
|
|
174
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const result = await generateText({
|
|
178
|
+
model: openai('gpt-4'),
|
|
179
|
+
tools: { search: youSearch() },
|
|
180
|
+
prompt: 'Search for AI news',
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Google Gemini
|
|
184
|
+
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
185
|
+
|
|
186
|
+
const google = createGoogleGenerativeAI({
|
|
187
|
+
apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const result = await generateText({
|
|
191
|
+
model: google('gemini-2.0-flash-exp'),
|
|
192
|
+
tools: { search: youSearch() },
|
|
193
|
+
prompt: 'Search for AI news',
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
</details>
|
|
198
|
+
|
|
199
|
+
## Available tools
|
|
200
|
+
|
|
201
|
+
This plugin provides three tools that your AI can use automatically:
|
|
202
|
+
|
|
203
|
+
### youSearch()
|
|
204
|
+
|
|
205
|
+
Comprehensive web and news search with advanced filtering capabilities. Perfect for finding current information, research articles, documentation, and news stories.
|
|
206
|
+
|
|
207
|
+
**When your AI will use this:**
|
|
208
|
+
- Searching for current information or news
|
|
209
|
+
- Finding specific content with filters (dates, sites, file types)
|
|
210
|
+
- Research queries requiring multiple results
|
|
211
|
+
|
|
212
|
+
### youExpress()
|
|
213
|
+
|
|
214
|
+
Fast AI-powered agent that provides synthesized answers with optional real-time web search. Ideal for straightforward questions that benefit from AI interpretation.
|
|
215
|
+
|
|
216
|
+
**When your AI will use this:**
|
|
217
|
+
- Direct questions needing quick answers
|
|
218
|
+
- Queries benefiting from AI synthesis
|
|
219
|
+
- Requests for explanations or summaries with web context
|
|
220
|
+
|
|
221
|
+
### youContents()
|
|
222
|
+
|
|
223
|
+
Extract full page content from URLs in markdown or HTML format. Useful for documentation analysis, content processing, and batch URL extraction.
|
|
224
|
+
|
|
225
|
+
**When your AI will use this:**
|
|
226
|
+
- Extracting content from specific URLs
|
|
227
|
+
- Processing multiple pages in batch
|
|
228
|
+
- Analyzing webpage content for further processing
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
**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.
|
|
233
|
+
|
|
234
|
+
## Examples
|
|
235
|
+
|
|
236
|
+
The `examples/` directory contains complete working examples demonstrating all features:
|
|
237
|
+
|
|
238
|
+
- **basic-search.ts** - Web search with filters and parameters
|
|
239
|
+
- **streaming-text.ts** - Real-time streaming responses
|
|
240
|
+
- **agent-response.ts** - AI reasoning with web context
|
|
241
|
+
- **content-extraction.ts** - Extract and analyze webpages
|
|
242
|
+
- **error-handling.ts** - Production-ready error handling
|
|
243
|
+
|
|
244
|
+
**Quick start:**
|
|
245
|
+
|
|
246
|
+
1. Set up your environment variables (see [examples/README.md](./examples/README.md) for 3 setup options)
|
|
247
|
+
2. Run an example:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Using the example script (easiest)
|
|
251
|
+
bun run example # Runs basic-search (default)
|
|
252
|
+
bun run example agent # Runs agent-response
|
|
253
|
+
bun run example help # Shows all available examples
|
|
254
|
+
|
|
255
|
+
# Or run directly
|
|
256
|
+
cd packages/ai-sdk-plugin
|
|
257
|
+
bun examples/basic-search.ts
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
All examples include:
|
|
261
|
+
- Environment variable validation with helpful error messages
|
|
262
|
+
- Explicit provider pattern matching integration tests
|
|
263
|
+
- Error handling best practices
|
|
264
|
+
|
|
265
|
+
**For complete setup instructions, environment variable options, and troubleshooting**, see [examples/README.md](./examples/README.md)
|
|
266
|
+
|
|
267
|
+
## Troubleshooting
|
|
268
|
+
|
|
269
|
+
### Problem: "YDC_API_KEY is required" error
|
|
270
|
+
|
|
271
|
+
**Solution**: Set your API key as an environment variable:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
export YDC_API_KEY=your-api-key-here
|
|
275
|
+
# Then restart your application
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Or pass it directly when creating tools:
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
const search = youSearch({ apiKey: 'your-api-key-here' });
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Problem: AI isn't using the tools
|
|
285
|
+
|
|
286
|
+
**Solution**: Make sure you're setting `maxSteps` to allow multiple tool calls:
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
290
|
+
|
|
291
|
+
const anthropic = createAnthropic({
|
|
292
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
const result = await generateText({
|
|
296
|
+
model: anthropic('claude-sonnet-4-5-20250929'),
|
|
297
|
+
tools: { search: youSearch() },
|
|
298
|
+
maxSteps: 5, // Required: allows AI to use tools
|
|
299
|
+
prompt: 'Search for recent AI news',
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Problem: Getting 401 authentication errors
|
|
304
|
+
|
|
305
|
+
**Solution**: Verify your API key is correct and properly set:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Check if environment variable is set
|
|
309
|
+
echo $YDC_API_KEY
|
|
310
|
+
|
|
311
|
+
# If empty, set it
|
|
312
|
+
export YDC_API_KEY=your-api-key-here
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Get a new API key at [you.com/platform/api-keys](https://you.com/platform/api-keys) if needed.
|
|
316
|
+
|
|
317
|
+
### Problem: Getting rate limit errors (429)
|
|
318
|
+
|
|
319
|
+
**Solution**: You've hit the API rate limit. Wait a few minutes before retrying, or check your API usage at [you.com/platform/api-keys](https://you.com/platform/api-keys).
|
|
320
|
+
|
|
321
|
+
### Problem: Tool execution failing silently
|
|
322
|
+
|
|
323
|
+
**Solution**: Check the AI SDK's tool results for error details:
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
327
|
+
|
|
328
|
+
const anthropic = createAnthropic({
|
|
329
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
const result = await generateText({
|
|
333
|
+
model: anthropic('claude-sonnet-4-5-20250929'),
|
|
334
|
+
tools: { search: youSearch() },
|
|
335
|
+
prompt: 'Search for AI news',
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// Inspect tool results for errors
|
|
339
|
+
console.log(result.toolResults);
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Need more help?
|
|
343
|
+
|
|
344
|
+
- **GitHub Issues**: [Report bugs](https://github.com/youdotcom-oss/dx-toolkit/issues)
|
|
345
|
+
- **Email Support**: support@you.com
|
|
346
|
+
|
|
347
|
+
## For contributors
|
|
348
|
+
|
|
349
|
+
Interested in contributing? We'd love your help!
|
|
350
|
+
|
|
351
|
+
**Development setup**: See [AGENTS.md](./AGENTS.md) for complete development guide, architecture overview, code patterns, and testing guidelines.
|
|
352
|
+
|
|
353
|
+
**Quick contribution steps:**
|
|
354
|
+
1. Fork the repository
|
|
355
|
+
2. Create a feature branch following [CONTRIBUTING.md](../../CONTRIBUTING.md) conventions
|
|
356
|
+
3. Follow code style guidelines (Biome enforced)
|
|
357
|
+
4. Write tests for your changes
|
|
358
|
+
5. Run quality checks: `bun run check && bun test`
|
|
359
|
+
6. Submit a pull request with a clear description
|
|
360
|
+
|
|
361
|
+
We appreciate contributions of all kinds:
|
|
362
|
+
- Bug fixes and improvements
|
|
363
|
+
- New features and enhancements
|
|
364
|
+
- Documentation improvements
|
|
365
|
+
- Test coverage improvements
|
|
366
|
+
- Performance optimizations
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
**License**: MIT - see [LICENSE](../../LICENSE) for details
|
|
371
|
+
|
|
372
|
+
**Author**: You.com (https://you.com)
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for You.com AI SDK tools
|
|
3
|
+
*/
|
|
4
|
+
export type YouToolsConfig = {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* You.com web search tool for Vercel AI SDK
|
|
9
|
+
*
|
|
10
|
+
* @param config - Configuration options
|
|
11
|
+
* @returns A tool that can be used with AI SDK's generateText, streamText, etc.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { generateText, stepCountIs } from 'ai';
|
|
16
|
+
* import { youSearch } from '@youdotcom-oss/ai-sdk-plugin';
|
|
17
|
+
*
|
|
18
|
+
* const { text } = await generateText({
|
|
19
|
+
* model: 'anthropic/claude-sonnet-4.5',
|
|
20
|
+
* prompt: 'What happened in San Francisco last week?',
|
|
21
|
+
* tools: {
|
|
22
|
+
* search: youSearch(),
|
|
23
|
+
* },
|
|
24
|
+
* stopWhen: stepCountIs(3),
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const youSearch: (config?: YouToolsConfig) => import("ai").Tool<{
|
|
29
|
+
query: string;
|
|
30
|
+
count?: number | undefined;
|
|
31
|
+
freshness?: string | undefined;
|
|
32
|
+
offset?: number | undefined;
|
|
33
|
+
country?: "AR" | "AU" | "AT" | "BE" | "BR" | "CA" | "CL" | "DK" | "FI" | "FR" | "DE" | "HK" | "IN" | "ID" | "IT" | "JP" | "KR" | "MY" | "MX" | "NL" | "NZ" | "NO" | "CN" | "PL" | "PT" | "PH" | "RU" | "SA" | "ZA" | "ES" | "SE" | "CH" | "TW" | "TR" | "GB" | "US" | undefined;
|
|
34
|
+
safesearch?: "off" | "moderate" | "strict" | undefined;
|
|
35
|
+
site?: string | undefined;
|
|
36
|
+
fileType?: string | undefined;
|
|
37
|
+
language?: string | undefined;
|
|
38
|
+
excludeTerms?: string | undefined;
|
|
39
|
+
exactTerms?: string | undefined;
|
|
40
|
+
livecrawl?: "web" | "news" | "all" | undefined;
|
|
41
|
+
livecrawl_formats?: "markdown" | "html" | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
results: {
|
|
44
|
+
web?: {
|
|
45
|
+
url: string;
|
|
46
|
+
title: string;
|
|
47
|
+
description: string;
|
|
48
|
+
snippets: string[];
|
|
49
|
+
page_age?: string | undefined;
|
|
50
|
+
authors?: string[] | undefined;
|
|
51
|
+
thumbnail_url?: string | undefined;
|
|
52
|
+
favicon_url?: string | undefined;
|
|
53
|
+
contents?: {
|
|
54
|
+
html?: string | undefined;
|
|
55
|
+
markdown?: string | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
}[] | undefined;
|
|
58
|
+
news?: {
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
page_age: string;
|
|
62
|
+
url: string;
|
|
63
|
+
thumbnail_url?: string | undefined;
|
|
64
|
+
contents?: {
|
|
65
|
+
html?: string | undefined;
|
|
66
|
+
markdown?: string | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
}[] | undefined;
|
|
69
|
+
};
|
|
70
|
+
metadata: {
|
|
71
|
+
search_uuid?: string | undefined;
|
|
72
|
+
query?: string | undefined;
|
|
73
|
+
latency?: number | undefined;
|
|
74
|
+
};
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* You.com AI agent tool for Vercel AI SDK
|
|
78
|
+
*
|
|
79
|
+
* Fast AI responses with optional web search integration.
|
|
80
|
+
*
|
|
81
|
+
* @param config - Configuration options
|
|
82
|
+
* @returns A tool that can be used with AI SDK's generateText, streamText, etc.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { generateText, stepCountIs } from 'ai';
|
|
87
|
+
* import { youExpress } from '@youdotcom-oss/ai-sdk-plugin';
|
|
88
|
+
*
|
|
89
|
+
* const { text } = await generateText({
|
|
90
|
+
* model: 'anthropic/claude-sonnet-4.5',
|
|
91
|
+
* prompt: 'What are the latest AI developments?',
|
|
92
|
+
* tools: {
|
|
93
|
+
* agent: youExpress(),
|
|
94
|
+
* },
|
|
95
|
+
* stopWhen: stepCountIs(3),
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare const youExpress: (config?: YouToolsConfig) => import("ai").Tool<{
|
|
100
|
+
input: string;
|
|
101
|
+
tools?: {
|
|
102
|
+
type: "web_search";
|
|
103
|
+
}[] | undefined;
|
|
104
|
+
}, {
|
|
105
|
+
answer: string;
|
|
106
|
+
results?: {
|
|
107
|
+
web: {
|
|
108
|
+
url: string;
|
|
109
|
+
title: string;
|
|
110
|
+
snippet: string;
|
|
111
|
+
}[];
|
|
112
|
+
} | undefined;
|
|
113
|
+
agent?: string | undefined;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* You.com content extraction tool for Vercel AI SDK
|
|
117
|
+
*
|
|
118
|
+
* Extract full page content from URLs in markdown or HTML format.
|
|
119
|
+
*
|
|
120
|
+
* @param config - Configuration options
|
|
121
|
+
* @returns A tool that can be used with AI SDK's generateText, streamText, etc.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { generateText, stepCountIs } from 'ai';
|
|
126
|
+
* import { youContents } from '@youdotcom-oss/ai-sdk-plugin';
|
|
127
|
+
*
|
|
128
|
+
* const { text } = await generateText({
|
|
129
|
+
* model: 'anthropic/claude-sonnet-4.5',
|
|
130
|
+
* prompt: 'Summarize the content from vercel.com/blog',
|
|
131
|
+
* tools: {
|
|
132
|
+
* extract: youContents(),
|
|
133
|
+
* },
|
|
134
|
+
* stopWhen: stepCountIs(3),
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare const youContents: (config?: YouToolsConfig) => import("ai").Tool<{
|
|
139
|
+
urls: string[];
|
|
140
|
+
format: "markdown" | "html";
|
|
141
|
+
}, {
|
|
142
|
+
url: string;
|
|
143
|
+
title?: string | undefined;
|
|
144
|
+
html?: string | undefined;
|
|
145
|
+
markdown?: string | undefined;
|
|
146
|
+
}[]>;
|