@blinkdotnew/sdk 0.2.2 → 0.4.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 +47 -4
- package/dist/index.d.mts +55 -9
- package/dist/index.d.ts +55 -9
- package/dist/index.js +105 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,9 +46,11 @@ const { text } = await blink.ai.generateText({
|
|
|
46
46
|
})
|
|
47
47
|
|
|
48
48
|
// Data operations (extract text from documents)
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
)
|
|
49
|
+
const text = await blink.data.extractFromUrl("https://example.com/document.pdf")
|
|
50
|
+
|
|
51
|
+
// Website scraping and screenshots (crystal clear results!)
|
|
52
|
+
const { markdown, metadata, links } = await blink.data.scrape("https://competitor.com")
|
|
53
|
+
const screenshotUrl = await blink.data.screenshot("https://competitor.com")
|
|
52
54
|
|
|
53
55
|
// Storage operations (instant - returns public URL directly)
|
|
54
56
|
const { publicUrl } = await blink.storage.upload(
|
|
@@ -73,7 +75,7 @@ This SDK powers every Blink-generated app with:
|
|
|
73
75
|
|
|
74
76
|
- **🔐 Authentication**: JWT-based auth with automatic token management
|
|
75
77
|
- **🗄️ Database**: PostgREST-compatible CRUD operations with advanced filtering
|
|
76
|
-
- **🤖 AI**: Text generation, object generation, image creation, speech synthesis, and transcription
|
|
78
|
+
- **🤖 AI**: Text generation with web search, object generation, image creation, speech synthesis, and transcription
|
|
77
79
|
- **📄 Data**: Extract text content from documents, spreadsheets, and more
|
|
78
80
|
- **📁 Storage**: File upload, download, and management
|
|
79
81
|
- **🌐 Universal**: Works on client-side and server-side
|
|
@@ -182,6 +184,19 @@ const { text } = await blink.ai.generateText({
|
|
|
182
184
|
maxTokens: 150
|
|
183
185
|
})
|
|
184
186
|
|
|
187
|
+
// Web search (OpenAI only) - get real-time information
|
|
188
|
+
const { text, sources } = await blink.ai.generateText({
|
|
189
|
+
prompt: 'Who is the current US president?',
|
|
190
|
+
search: true // Returns current info + source URLs
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
// Multi-step reasoning - for complex analysis
|
|
194
|
+
const { text } = await blink.ai.generateText({
|
|
195
|
+
prompt: 'Research and analyze tech trends',
|
|
196
|
+
search: true,
|
|
197
|
+
maxSteps: 5 // Default: 25 when tools used
|
|
198
|
+
})
|
|
199
|
+
|
|
185
200
|
// Text generation with image content
|
|
186
201
|
const { text } = await blink.ai.generateText({
|
|
187
202
|
messages: [
|
|
@@ -245,6 +260,12 @@ await blink.ai.streamText(
|
|
|
245
260
|
{ prompt: 'Write a story...' },
|
|
246
261
|
(chunk) => console.log(chunk)
|
|
247
262
|
)
|
|
263
|
+
|
|
264
|
+
// Streaming with web search
|
|
265
|
+
await blink.ai.streamText(
|
|
266
|
+
{ prompt: 'Latest AI news', search: true },
|
|
267
|
+
(chunk) => console.log(chunk)
|
|
268
|
+
)
|
|
248
269
|
```
|
|
249
270
|
|
|
250
271
|
### Data Operations
|
|
@@ -277,6 +298,28 @@ const chunks = await blink.data.extractFromBlob(file, {
|
|
|
277
298
|
chunkSize: 3000
|
|
278
299
|
});
|
|
279
300
|
|
|
301
|
+
// Website scraping (NEW!) - Crystal clear destructuring
|
|
302
|
+
const { markdown, metadata, links, extract } = await blink.data.scrape('https://example.com');
|
|
303
|
+
console.log(markdown); // Clean markdown content
|
|
304
|
+
console.log(metadata.title); // Page title
|
|
305
|
+
console.log(links.length); // Number of links found
|
|
306
|
+
|
|
307
|
+
// Even cleaner - destructure only what you need
|
|
308
|
+
const { metadata, extract } = await blink.data.scrape('https://blog.example.com/article');
|
|
309
|
+
console.log(metadata.title); // Always available
|
|
310
|
+
console.log(extract.headings); // Always an array
|
|
311
|
+
|
|
312
|
+
// Website screenshots (NEW!)
|
|
313
|
+
const screenshotUrl = await blink.data.screenshot('https://example.com');
|
|
314
|
+
console.log(screenshotUrl); // Direct URL to screenshot image
|
|
315
|
+
|
|
316
|
+
// Full-page screenshot with custom dimensions
|
|
317
|
+
const fullPageUrl = await blink.data.screenshot('https://example.com', {
|
|
318
|
+
fullPage: true,
|
|
319
|
+
width: 1920,
|
|
320
|
+
height: 1080
|
|
321
|
+
});
|
|
322
|
+
|
|
280
323
|
// Error handling for data extraction
|
|
281
324
|
try {
|
|
282
325
|
const result = await blink.data.extractFromUrl('https://example.com/huge-file.pdf');
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, BlinkStorage, BlinkAI,
|
|
1
|
+
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, BlinkStorage, BlinkAI, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse } from '@blink/core';
|
|
2
2
|
export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkData, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -196,6 +196,42 @@ declare class BlinkDatabase {
|
|
|
196
196
|
}>;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
interface BlinkData {
|
|
200
|
+
extractFromUrl(url: string, options?: {
|
|
201
|
+
chunking?: boolean;
|
|
202
|
+
chunkSize?: number;
|
|
203
|
+
}): Promise<string | string[]>;
|
|
204
|
+
extractFromBlob(file: File, options?: {
|
|
205
|
+
chunking?: boolean;
|
|
206
|
+
chunkSize?: number;
|
|
207
|
+
}): Promise<string | string[]>;
|
|
208
|
+
scrape(url: string): Promise<ScrapeResult>;
|
|
209
|
+
screenshot(url: string, options?: {
|
|
210
|
+
fullPage?: boolean;
|
|
211
|
+
width?: number;
|
|
212
|
+
height?: number;
|
|
213
|
+
}): Promise<string>;
|
|
214
|
+
}
|
|
215
|
+
declare class BlinkDataImpl implements BlinkData {
|
|
216
|
+
private httpClient;
|
|
217
|
+
private projectId;
|
|
218
|
+
constructor(httpClient: HttpClient, projectId: string);
|
|
219
|
+
extractFromUrl(url: string, options?: {
|
|
220
|
+
chunking?: boolean;
|
|
221
|
+
chunkSize?: number;
|
|
222
|
+
}): Promise<string | string[]>;
|
|
223
|
+
extractFromBlob(file: File, options?: {
|
|
224
|
+
chunking?: boolean;
|
|
225
|
+
chunkSize?: number;
|
|
226
|
+
}): Promise<string | string[]>;
|
|
227
|
+
scrape(url: string): Promise<ScrapeResult>;
|
|
228
|
+
screenshot(url: string, options?: {
|
|
229
|
+
fullPage?: boolean;
|
|
230
|
+
width?: number;
|
|
231
|
+
height?: number;
|
|
232
|
+
}): Promise<string>;
|
|
233
|
+
}
|
|
234
|
+
|
|
199
235
|
/**
|
|
200
236
|
* Blink Client - Main SDK entry point
|
|
201
237
|
* Factory function and client class for the Blink SDK
|
|
@@ -284,7 +320,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
284
320
|
* @param options - An object containing either:
|
|
285
321
|
* - `prompt`: a simple string prompt
|
|
286
322
|
* - OR `messages`: an array of chat messages for conversation
|
|
287
|
-
* - Plus optional model, maxTokens, temperature, signal parameters
|
|
323
|
+
* - Plus optional model, search, maxSteps, experimental_continueSteps, maxTokens, temperature, signal parameters
|
|
288
324
|
*
|
|
289
325
|
* @example
|
|
290
326
|
* ```ts
|
|
@@ -335,6 +371,22 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
335
371
|
* maxTokens: 150,
|
|
336
372
|
* temperature: 0.7
|
|
337
373
|
* });
|
|
374
|
+
*
|
|
375
|
+
* // With web search (OpenAI models only)
|
|
376
|
+
* const { text, sources } = await blink.ai.generateText({
|
|
377
|
+
* prompt: "What are the latest developments in AI?",
|
|
378
|
+
* model: "gpt-4o-mini",
|
|
379
|
+
* search: true // Enables web search
|
|
380
|
+
* });
|
|
381
|
+
*
|
|
382
|
+
* // With advanced multi-step configuration
|
|
383
|
+
* const { text } = await blink.ai.generateText({
|
|
384
|
+
* prompt: "Research and analyze recent tech trends",
|
|
385
|
+
* model: "gpt-4o",
|
|
386
|
+
* search: true,
|
|
387
|
+
* maxSteps: 10, // Allow up to 10 reasoning steps
|
|
388
|
+
* experimental_continueSteps: true // Enable continued reasoning
|
|
389
|
+
* });
|
|
338
390
|
* ```
|
|
339
391
|
*
|
|
340
392
|
* @returns Promise<TextGenerationResponse> - Object containing:
|
|
@@ -346,7 +398,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
346
398
|
/**
|
|
347
399
|
* Streams text generation with real-time updates as the AI generates content.
|
|
348
400
|
*
|
|
349
|
-
* @param options - Same as generateText: either `prompt` or `messages` with optional parameters
|
|
401
|
+
* @param options - Same as generateText: either `prompt` or `messages` with optional parameters including search, maxSteps, experimental_continueSteps
|
|
350
402
|
* @param onChunk - Callback function that receives each text chunk as it's generated
|
|
351
403
|
*
|
|
352
404
|
* @example
|
|
@@ -597,10 +649,4 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
597
649
|
transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
|
|
598
650
|
}
|
|
599
651
|
|
|
600
|
-
declare class BlinkDataImpl implements BlinkData {
|
|
601
|
-
private httpClient;
|
|
602
|
-
constructor(httpClient: HttpClient);
|
|
603
|
-
extractFromUrl(url: string, filename?: string): Promise<DataExtraction>;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
652
|
export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, BlinkStorage, BlinkAI,
|
|
1
|
+
import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, BlinkStorage, BlinkAI, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse } from '@blink/core';
|
|
2
2
|
export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkData, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -196,6 +196,42 @@ declare class BlinkDatabase {
|
|
|
196
196
|
}>;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
interface BlinkData {
|
|
200
|
+
extractFromUrl(url: string, options?: {
|
|
201
|
+
chunking?: boolean;
|
|
202
|
+
chunkSize?: number;
|
|
203
|
+
}): Promise<string | string[]>;
|
|
204
|
+
extractFromBlob(file: File, options?: {
|
|
205
|
+
chunking?: boolean;
|
|
206
|
+
chunkSize?: number;
|
|
207
|
+
}): Promise<string | string[]>;
|
|
208
|
+
scrape(url: string): Promise<ScrapeResult>;
|
|
209
|
+
screenshot(url: string, options?: {
|
|
210
|
+
fullPage?: boolean;
|
|
211
|
+
width?: number;
|
|
212
|
+
height?: number;
|
|
213
|
+
}): Promise<string>;
|
|
214
|
+
}
|
|
215
|
+
declare class BlinkDataImpl implements BlinkData {
|
|
216
|
+
private httpClient;
|
|
217
|
+
private projectId;
|
|
218
|
+
constructor(httpClient: HttpClient, projectId: string);
|
|
219
|
+
extractFromUrl(url: string, options?: {
|
|
220
|
+
chunking?: boolean;
|
|
221
|
+
chunkSize?: number;
|
|
222
|
+
}): Promise<string | string[]>;
|
|
223
|
+
extractFromBlob(file: File, options?: {
|
|
224
|
+
chunking?: boolean;
|
|
225
|
+
chunkSize?: number;
|
|
226
|
+
}): Promise<string | string[]>;
|
|
227
|
+
scrape(url: string): Promise<ScrapeResult>;
|
|
228
|
+
screenshot(url: string, options?: {
|
|
229
|
+
fullPage?: boolean;
|
|
230
|
+
width?: number;
|
|
231
|
+
height?: number;
|
|
232
|
+
}): Promise<string>;
|
|
233
|
+
}
|
|
234
|
+
|
|
199
235
|
/**
|
|
200
236
|
* Blink Client - Main SDK entry point
|
|
201
237
|
* Factory function and client class for the Blink SDK
|
|
@@ -284,7 +320,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
284
320
|
* @param options - An object containing either:
|
|
285
321
|
* - `prompt`: a simple string prompt
|
|
286
322
|
* - OR `messages`: an array of chat messages for conversation
|
|
287
|
-
* - Plus optional model, maxTokens, temperature, signal parameters
|
|
323
|
+
* - Plus optional model, search, maxSteps, experimental_continueSteps, maxTokens, temperature, signal parameters
|
|
288
324
|
*
|
|
289
325
|
* @example
|
|
290
326
|
* ```ts
|
|
@@ -335,6 +371,22 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
335
371
|
* maxTokens: 150,
|
|
336
372
|
* temperature: 0.7
|
|
337
373
|
* });
|
|
374
|
+
*
|
|
375
|
+
* // With web search (OpenAI models only)
|
|
376
|
+
* const { text, sources } = await blink.ai.generateText({
|
|
377
|
+
* prompt: "What are the latest developments in AI?",
|
|
378
|
+
* model: "gpt-4o-mini",
|
|
379
|
+
* search: true // Enables web search
|
|
380
|
+
* });
|
|
381
|
+
*
|
|
382
|
+
* // With advanced multi-step configuration
|
|
383
|
+
* const { text } = await blink.ai.generateText({
|
|
384
|
+
* prompt: "Research and analyze recent tech trends",
|
|
385
|
+
* model: "gpt-4o",
|
|
386
|
+
* search: true,
|
|
387
|
+
* maxSteps: 10, // Allow up to 10 reasoning steps
|
|
388
|
+
* experimental_continueSteps: true // Enable continued reasoning
|
|
389
|
+
* });
|
|
338
390
|
* ```
|
|
339
391
|
*
|
|
340
392
|
* @returns Promise<TextGenerationResponse> - Object containing:
|
|
@@ -346,7 +398,7 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
346
398
|
/**
|
|
347
399
|
* Streams text generation with real-time updates as the AI generates content.
|
|
348
400
|
*
|
|
349
|
-
* @param options - Same as generateText: either `prompt` or `messages` with optional parameters
|
|
401
|
+
* @param options - Same as generateText: either `prompt` or `messages` with optional parameters including search, maxSteps, experimental_continueSteps
|
|
350
402
|
* @param onChunk - Callback function that receives each text chunk as it's generated
|
|
351
403
|
*
|
|
352
404
|
* @example
|
|
@@ -597,10 +649,4 @@ declare class BlinkAIImpl implements BlinkAI {
|
|
|
597
649
|
transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
|
|
598
650
|
}
|
|
599
651
|
|
|
600
|
-
declare class BlinkDataImpl implements BlinkData {
|
|
601
|
-
private httpClient;
|
|
602
|
-
constructor(httpClient: HttpClient);
|
|
603
|
-
extractFromUrl(url: string, filename?: string): Promise<DataExtraction>;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
652
|
export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
|
package/dist/index.js
CHANGED
|
@@ -40,12 +40,6 @@ var BlinkAIError = class extends BlinkError {
|
|
|
40
40
|
this.name = "BlinkAIError";
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
var BlinkDataError = class extends BlinkError {
|
|
44
|
-
constructor(message, status, details) {
|
|
45
|
-
super(message, "DATA_ERROR", status, details);
|
|
46
|
-
this.name = "BlinkDataError";
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
43
|
|
|
50
44
|
// ../core/src/query-builder.ts
|
|
51
45
|
function buildFilterQuery(condition) {
|
|
@@ -538,10 +532,36 @@ var HttpClient = class {
|
|
|
538
532
|
/**
|
|
539
533
|
* Data-specific requests
|
|
540
534
|
*/
|
|
541
|
-
async dataExtractFromUrl(
|
|
542
|
-
return this.request(`/api/data/${
|
|
535
|
+
async dataExtractFromUrl(projectId, request) {
|
|
536
|
+
return this.request(`/api/data/${projectId}/extract-from-url`, {
|
|
537
|
+
method: "POST",
|
|
538
|
+
body: JSON.stringify(request)
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
async dataExtractFromBlob(projectId, file, chunking, chunkSize) {
|
|
542
|
+
const formData = new FormData();
|
|
543
|
+
formData.append("file", file);
|
|
544
|
+
if (chunking !== void 0) {
|
|
545
|
+
formData.append("chunking", String(chunking));
|
|
546
|
+
}
|
|
547
|
+
if (chunkSize !== void 0) {
|
|
548
|
+
formData.append("chunkSize", String(chunkSize));
|
|
549
|
+
}
|
|
550
|
+
return this.request(`/api/data/${projectId}/extract-from-blob`, {
|
|
551
|
+
method: "POST",
|
|
552
|
+
body: formData
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
async dataScrape(projectId, request) {
|
|
556
|
+
return this.request(`/api/data/${projectId}/scrape`, {
|
|
557
|
+
method: "POST",
|
|
558
|
+
body: JSON.stringify(request)
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
async dataScreenshot(projectId, request) {
|
|
562
|
+
return this.request(`/api/data/${projectId}/screenshot`, {
|
|
543
563
|
method: "POST",
|
|
544
|
-
body:
|
|
564
|
+
body: JSON.stringify(request)
|
|
545
565
|
});
|
|
546
566
|
}
|
|
547
567
|
/**
|
|
@@ -1687,7 +1707,7 @@ var BlinkAIImpl = class {
|
|
|
1687
1707
|
* @param options - An object containing either:
|
|
1688
1708
|
* - `prompt`: a simple string prompt
|
|
1689
1709
|
* - OR `messages`: an array of chat messages for conversation
|
|
1690
|
-
* - Plus optional model, maxTokens, temperature, signal parameters
|
|
1710
|
+
* - Plus optional model, search, maxSteps, experimental_continueSteps, maxTokens, temperature, signal parameters
|
|
1691
1711
|
*
|
|
1692
1712
|
* @example
|
|
1693
1713
|
* ```ts
|
|
@@ -1738,6 +1758,22 @@ var BlinkAIImpl = class {
|
|
|
1738
1758
|
* maxTokens: 150,
|
|
1739
1759
|
* temperature: 0.7
|
|
1740
1760
|
* });
|
|
1761
|
+
*
|
|
1762
|
+
* // With web search (OpenAI models only)
|
|
1763
|
+
* const { text, sources } = await blink.ai.generateText({
|
|
1764
|
+
* prompt: "What are the latest developments in AI?",
|
|
1765
|
+
* model: "gpt-4o-mini",
|
|
1766
|
+
* search: true // Enables web search
|
|
1767
|
+
* });
|
|
1768
|
+
*
|
|
1769
|
+
* // With advanced multi-step configuration
|
|
1770
|
+
* const { text } = await blink.ai.generateText({
|
|
1771
|
+
* prompt: "Research and analyze recent tech trends",
|
|
1772
|
+
* model: "gpt-4o",
|
|
1773
|
+
* search: true,
|
|
1774
|
+
* maxSteps: 10, // Allow up to 10 reasoning steps
|
|
1775
|
+
* experimental_continueSteps: true // Enable continued reasoning
|
|
1776
|
+
* });
|
|
1741
1777
|
* ```
|
|
1742
1778
|
*
|
|
1743
1779
|
* @returns Promise<TextGenerationResponse> - Object containing:
|
|
@@ -1759,6 +1795,9 @@ var BlinkAIImpl = class {
|
|
|
1759
1795
|
const requestBody = {
|
|
1760
1796
|
model: options.model,
|
|
1761
1797
|
stream: false,
|
|
1798
|
+
search: options.search,
|
|
1799
|
+
maxSteps: options.maxSteps,
|
|
1800
|
+
experimental_continueSteps: options.experimental_continueSteps,
|
|
1762
1801
|
maxTokens: options.maxTokens,
|
|
1763
1802
|
temperature: options.temperature,
|
|
1764
1803
|
signal: options.signal
|
|
@@ -1794,7 +1833,7 @@ var BlinkAIImpl = class {
|
|
|
1794
1833
|
/**
|
|
1795
1834
|
* Streams text generation with real-time updates as the AI generates content.
|
|
1796
1835
|
*
|
|
1797
|
-
* @param options - Same as generateText: either `prompt` or `messages` with optional parameters
|
|
1836
|
+
* @param options - Same as generateText: either `prompt` or `messages` with optional parameters including search, maxSteps, experimental_continueSteps
|
|
1798
1837
|
* @param onChunk - Callback function that receives each text chunk as it's generated
|
|
1799
1838
|
*
|
|
1800
1839
|
* @example
|
|
@@ -1837,6 +1876,9 @@ var BlinkAIImpl = class {
|
|
|
1837
1876
|
{
|
|
1838
1877
|
model: options.model,
|
|
1839
1878
|
messages: options.messages,
|
|
1879
|
+
search: options.search,
|
|
1880
|
+
maxSteps: options.maxSteps,
|
|
1881
|
+
experimental_continueSteps: options.experimental_continueSteps,
|
|
1840
1882
|
maxTokens: options.maxTokens,
|
|
1841
1883
|
temperature: options.temperature,
|
|
1842
1884
|
signal: options.signal
|
|
@@ -2296,29 +2338,59 @@ var BlinkAIImpl = class {
|
|
|
2296
2338
|
|
|
2297
2339
|
// src/data.ts
|
|
2298
2340
|
var BlinkDataImpl = class {
|
|
2299
|
-
constructor(httpClient) {
|
|
2341
|
+
constructor(httpClient, projectId) {
|
|
2300
2342
|
this.httpClient = httpClient;
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2343
|
+
this.projectId = projectId;
|
|
2344
|
+
}
|
|
2345
|
+
async extractFromUrl(url, options = {}) {
|
|
2346
|
+
const { chunking = false, chunkSize } = options;
|
|
2347
|
+
const request = { url, chunking, chunkSize };
|
|
2348
|
+
const response = await this.httpClient.dataExtractFromUrl(this.projectId, request);
|
|
2349
|
+
return chunking ? response.data.chunks : response.data.text;
|
|
2350
|
+
}
|
|
2351
|
+
async extractFromBlob(file, options = {}) {
|
|
2352
|
+
const { chunking = false, chunkSize } = options;
|
|
2353
|
+
const response = await this.httpClient.dataExtractFromBlob(this.projectId, file, chunking, chunkSize);
|
|
2354
|
+
return chunking ? response.data.chunks : response.data.text;
|
|
2355
|
+
}
|
|
2356
|
+
async scrape(url) {
|
|
2357
|
+
const request = {
|
|
2358
|
+
url,
|
|
2359
|
+
formats: ["markdown", "html", "links", "extract", "metadata"]
|
|
2360
|
+
};
|
|
2361
|
+
const response = await this.httpClient.dataScrape(this.projectId, request);
|
|
2362
|
+
const data = response.data;
|
|
2363
|
+
return {
|
|
2364
|
+
markdown: data.markdown || "",
|
|
2365
|
+
html: data.html || "",
|
|
2366
|
+
metadata: {
|
|
2367
|
+
title: data.metadata?.title || "",
|
|
2368
|
+
description: data.metadata?.description || "",
|
|
2369
|
+
url: data.metadata?.url || url,
|
|
2370
|
+
domain: data.metadata?.domain || new URL(url).hostname,
|
|
2371
|
+
favicon: data.metadata?.favicon,
|
|
2372
|
+
image: data.metadata?.image,
|
|
2373
|
+
author: data.metadata?.author,
|
|
2374
|
+
publishedTime: data.metadata?.publishedTime,
|
|
2375
|
+
modifiedTime: data.metadata?.modifiedTime,
|
|
2376
|
+
type: data.metadata?.type,
|
|
2377
|
+
siteName: data.metadata?.siteName,
|
|
2378
|
+
locale: data.metadata?.locale,
|
|
2379
|
+
keywords: data.metadata?.keywords || []
|
|
2380
|
+
},
|
|
2381
|
+
links: data.links || [],
|
|
2382
|
+
extract: {
|
|
2383
|
+
title: data.extract?.title || data.metadata?.title || "",
|
|
2384
|
+
description: data.extract?.description || data.metadata?.description || "",
|
|
2385
|
+
headings: data.extract?.headings || [],
|
|
2386
|
+
text: data.extract?.text || data.markdown || ""
|
|
2315
2387
|
}
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
async screenshot(url, options = {}) {
|
|
2391
|
+
const request = { url, ...options };
|
|
2392
|
+
const response = await this.httpClient.dataScreenshot(this.projectId, request);
|
|
2393
|
+
return response.data.url;
|
|
2322
2394
|
}
|
|
2323
2395
|
};
|
|
2324
2396
|
|
|
@@ -2340,7 +2412,7 @@ var BlinkClientImpl = class {
|
|
|
2340
2412
|
this.db = new BlinkDatabase(this.httpClient);
|
|
2341
2413
|
this.storage = new BlinkStorageImpl(this.httpClient);
|
|
2342
2414
|
this.ai = new BlinkAIImpl(this.httpClient);
|
|
2343
|
-
this.data = new BlinkDataImpl(this.httpClient);
|
|
2415
|
+
this.data = new BlinkDataImpl(this.httpClient, config.projectId);
|
|
2344
2416
|
}
|
|
2345
2417
|
};
|
|
2346
2418
|
function createClient(config) {
|