@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/dist/index.mjs
CHANGED
|
@@ -38,12 +38,6 @@ var BlinkAIError = class extends BlinkError {
|
|
|
38
38
|
this.name = "BlinkAIError";
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
var BlinkDataError = class extends BlinkError {
|
|
42
|
-
constructor(message, status, details) {
|
|
43
|
-
super(message, "DATA_ERROR", status, details);
|
|
44
|
-
this.name = "BlinkDataError";
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
41
|
|
|
48
42
|
// ../core/src/query-builder.ts
|
|
49
43
|
function buildFilterQuery(condition) {
|
|
@@ -536,10 +530,36 @@ var HttpClient = class {
|
|
|
536
530
|
/**
|
|
537
531
|
* Data-specific requests
|
|
538
532
|
*/
|
|
539
|
-
async dataExtractFromUrl(
|
|
540
|
-
return this.request(`/api/data/${
|
|
533
|
+
async dataExtractFromUrl(projectId, request) {
|
|
534
|
+
return this.request(`/api/data/${projectId}/extract-from-url`, {
|
|
535
|
+
method: "POST",
|
|
536
|
+
body: JSON.stringify(request)
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
async dataExtractFromBlob(projectId, file, chunking, chunkSize) {
|
|
540
|
+
const formData = new FormData();
|
|
541
|
+
formData.append("file", file);
|
|
542
|
+
if (chunking !== void 0) {
|
|
543
|
+
formData.append("chunking", String(chunking));
|
|
544
|
+
}
|
|
545
|
+
if (chunkSize !== void 0) {
|
|
546
|
+
formData.append("chunkSize", String(chunkSize));
|
|
547
|
+
}
|
|
548
|
+
return this.request(`/api/data/${projectId}/extract-from-blob`, {
|
|
549
|
+
method: "POST",
|
|
550
|
+
body: formData
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
async dataScrape(projectId, request) {
|
|
554
|
+
return this.request(`/api/data/${projectId}/scrape`, {
|
|
555
|
+
method: "POST",
|
|
556
|
+
body: JSON.stringify(request)
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
async dataScreenshot(projectId, request) {
|
|
560
|
+
return this.request(`/api/data/${projectId}/screenshot`, {
|
|
541
561
|
method: "POST",
|
|
542
|
-
body:
|
|
562
|
+
body: JSON.stringify(request)
|
|
543
563
|
});
|
|
544
564
|
}
|
|
545
565
|
/**
|
|
@@ -1685,7 +1705,7 @@ var BlinkAIImpl = class {
|
|
|
1685
1705
|
* @param options - An object containing either:
|
|
1686
1706
|
* - `prompt`: a simple string prompt
|
|
1687
1707
|
* - OR `messages`: an array of chat messages for conversation
|
|
1688
|
-
* - Plus optional model, maxTokens, temperature, signal parameters
|
|
1708
|
+
* - Plus optional model, search, maxSteps, experimental_continueSteps, maxTokens, temperature, signal parameters
|
|
1689
1709
|
*
|
|
1690
1710
|
* @example
|
|
1691
1711
|
* ```ts
|
|
@@ -1736,6 +1756,22 @@ var BlinkAIImpl = class {
|
|
|
1736
1756
|
* maxTokens: 150,
|
|
1737
1757
|
* temperature: 0.7
|
|
1738
1758
|
* });
|
|
1759
|
+
*
|
|
1760
|
+
* // With web search (OpenAI models only)
|
|
1761
|
+
* const { text, sources } = await blink.ai.generateText({
|
|
1762
|
+
* prompt: "What are the latest developments in AI?",
|
|
1763
|
+
* model: "gpt-4o-mini",
|
|
1764
|
+
* search: true // Enables web search
|
|
1765
|
+
* });
|
|
1766
|
+
*
|
|
1767
|
+
* // With advanced multi-step configuration
|
|
1768
|
+
* const { text } = await blink.ai.generateText({
|
|
1769
|
+
* prompt: "Research and analyze recent tech trends",
|
|
1770
|
+
* model: "gpt-4o",
|
|
1771
|
+
* search: true,
|
|
1772
|
+
* maxSteps: 10, // Allow up to 10 reasoning steps
|
|
1773
|
+
* experimental_continueSteps: true // Enable continued reasoning
|
|
1774
|
+
* });
|
|
1739
1775
|
* ```
|
|
1740
1776
|
*
|
|
1741
1777
|
* @returns Promise<TextGenerationResponse> - Object containing:
|
|
@@ -1757,6 +1793,9 @@ var BlinkAIImpl = class {
|
|
|
1757
1793
|
const requestBody = {
|
|
1758
1794
|
model: options.model,
|
|
1759
1795
|
stream: false,
|
|
1796
|
+
search: options.search,
|
|
1797
|
+
maxSteps: options.maxSteps,
|
|
1798
|
+
experimental_continueSteps: options.experimental_continueSteps,
|
|
1760
1799
|
maxTokens: options.maxTokens,
|
|
1761
1800
|
temperature: options.temperature,
|
|
1762
1801
|
signal: options.signal
|
|
@@ -1792,7 +1831,7 @@ var BlinkAIImpl = class {
|
|
|
1792
1831
|
/**
|
|
1793
1832
|
* Streams text generation with real-time updates as the AI generates content.
|
|
1794
1833
|
*
|
|
1795
|
-
* @param options - Same as generateText: either `prompt` or `messages` with optional parameters
|
|
1834
|
+
* @param options - Same as generateText: either `prompt` or `messages` with optional parameters including search, maxSteps, experimental_continueSteps
|
|
1796
1835
|
* @param onChunk - Callback function that receives each text chunk as it's generated
|
|
1797
1836
|
*
|
|
1798
1837
|
* @example
|
|
@@ -1835,6 +1874,9 @@ var BlinkAIImpl = class {
|
|
|
1835
1874
|
{
|
|
1836
1875
|
model: options.model,
|
|
1837
1876
|
messages: options.messages,
|
|
1877
|
+
search: options.search,
|
|
1878
|
+
maxSteps: options.maxSteps,
|
|
1879
|
+
experimental_continueSteps: options.experimental_continueSteps,
|
|
1838
1880
|
maxTokens: options.maxTokens,
|
|
1839
1881
|
temperature: options.temperature,
|
|
1840
1882
|
signal: options.signal
|
|
@@ -2294,29 +2336,59 @@ var BlinkAIImpl = class {
|
|
|
2294
2336
|
|
|
2295
2337
|
// src/data.ts
|
|
2296
2338
|
var BlinkDataImpl = class {
|
|
2297
|
-
constructor(httpClient) {
|
|
2339
|
+
constructor(httpClient, projectId) {
|
|
2298
2340
|
this.httpClient = httpClient;
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2341
|
+
this.projectId = projectId;
|
|
2342
|
+
}
|
|
2343
|
+
async extractFromUrl(url, options = {}) {
|
|
2344
|
+
const { chunking = false, chunkSize } = options;
|
|
2345
|
+
const request = { url, chunking, chunkSize };
|
|
2346
|
+
const response = await this.httpClient.dataExtractFromUrl(this.projectId, request);
|
|
2347
|
+
return chunking ? response.data.chunks : response.data.text;
|
|
2348
|
+
}
|
|
2349
|
+
async extractFromBlob(file, options = {}) {
|
|
2350
|
+
const { chunking = false, chunkSize } = options;
|
|
2351
|
+
const response = await this.httpClient.dataExtractFromBlob(this.projectId, file, chunking, chunkSize);
|
|
2352
|
+
return chunking ? response.data.chunks : response.data.text;
|
|
2353
|
+
}
|
|
2354
|
+
async scrape(url) {
|
|
2355
|
+
const request = {
|
|
2356
|
+
url,
|
|
2357
|
+
formats: ["markdown", "html", "links", "extract", "metadata"]
|
|
2358
|
+
};
|
|
2359
|
+
const response = await this.httpClient.dataScrape(this.projectId, request);
|
|
2360
|
+
const data = response.data;
|
|
2361
|
+
return {
|
|
2362
|
+
markdown: data.markdown || "",
|
|
2363
|
+
html: data.html || "",
|
|
2364
|
+
metadata: {
|
|
2365
|
+
title: data.metadata?.title || "",
|
|
2366
|
+
description: data.metadata?.description || "",
|
|
2367
|
+
url: data.metadata?.url || url,
|
|
2368
|
+
domain: data.metadata?.domain || new URL(url).hostname,
|
|
2369
|
+
favicon: data.metadata?.favicon,
|
|
2370
|
+
image: data.metadata?.image,
|
|
2371
|
+
author: data.metadata?.author,
|
|
2372
|
+
publishedTime: data.metadata?.publishedTime,
|
|
2373
|
+
modifiedTime: data.metadata?.modifiedTime,
|
|
2374
|
+
type: data.metadata?.type,
|
|
2375
|
+
siteName: data.metadata?.siteName,
|
|
2376
|
+
locale: data.metadata?.locale,
|
|
2377
|
+
keywords: data.metadata?.keywords || []
|
|
2378
|
+
},
|
|
2379
|
+
links: data.links || [],
|
|
2380
|
+
extract: {
|
|
2381
|
+
title: data.extract?.title || data.metadata?.title || "",
|
|
2382
|
+
description: data.extract?.description || data.metadata?.description || "",
|
|
2383
|
+
headings: data.extract?.headings || [],
|
|
2384
|
+
text: data.extract?.text || data.markdown || ""
|
|
2313
2385
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2388
|
+
async screenshot(url, options = {}) {
|
|
2389
|
+
const request = { url, ...options };
|
|
2390
|
+
const response = await this.httpClient.dataScreenshot(this.projectId, request);
|
|
2391
|
+
return response.data.url;
|
|
2320
2392
|
}
|
|
2321
2393
|
};
|
|
2322
2394
|
|
|
@@ -2338,7 +2410,7 @@ var BlinkClientImpl = class {
|
|
|
2338
2410
|
this.db = new BlinkDatabase(this.httpClient);
|
|
2339
2411
|
this.storage = new BlinkStorageImpl(this.httpClient);
|
|
2340
2412
|
this.ai = new BlinkAIImpl(this.httpClient);
|
|
2341
|
-
this.data = new BlinkDataImpl(this.httpClient);
|
|
2413
|
+
this.data = new BlinkDataImpl(this.httpClient, config.projectId);
|
|
2342
2414
|
}
|
|
2343
2415
|
};
|
|
2344
2416
|
function createClient(config) {
|