@specstream/langchain 0.1.2 → 0.2.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 +2 -2
- package/dist/cjs/specstream-search.d.ts +6 -0
- package/dist/cjs/specstream-search.js +6 -1
- package/dist/cjs/utils.d.ts +5 -0
- package/dist/cjs/utils.js +6 -0
- package/dist/specstream-search.d.ts +6 -0
- package/dist/specstream-search.js +6 -1
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +6 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Source URL and read time on every value.
|
|
|
8
8
|
|
|
9
9
|
Three products:
|
|
10
10
|
|
|
11
|
-
1. Search API: `GET /v1/web-search`, $5 per 1,000 searches. The most accurate web search API in the world (scores and method: https://specstream.ai/benchmarks).
|
|
11
|
+
1. Search API: `GET /v1/web-search`, $5 per 1,000 searches of up to 10 results, or $1 on the fast tier. The most accurate web search API in the world (scores and method: https://specstream.ai/benchmarks).
|
|
12
12
|
2. Extract API: `POST /v1/extract`, up to 20 URLs a call (web pages, PDF, Word, Excel), $0.80 per 1,000 pages. A page with no text is not charged.
|
|
13
13
|
3. Deep Search: Ask in plain words. Get every match on the live web, in structured rows. Priced per row.
|
|
14
14
|
|
|
@@ -27,7 +27,7 @@ Both tools are LangChain `StructuredTool` classes, built like `@langchain/tavily
|
|
|
27
27
|
|
|
28
28
|
| Tool | Name | What it does | Cost |
|
|
29
29
|
| --- | --- | --- | --- |
|
|
30
|
-
| `SpecStreamSearch` | `specstream_search` | Calls `GET /v1/web-search` and returns the answer, matching rows and ranked sources, with page passages when `passages: true` | $5 per 1,000 searches |
|
|
30
|
+
| `SpecStreamSearch` | `specstream_search` | Calls `GET /v1/web-search` and returns the answer, matching rows and ranked sources, with page passages when `passages: true`. `speed: "fast"` returns the ranked results in about a second | $5 per 1,000 searches of up to 10 results; a fast search costs $1 per 1,000 |
|
|
31
31
|
| `SpecStreamExtract` | `specstream_extract` | Calls `POST /v1/extract` and returns the main text, title and published date of 1 to 20 web pages, PDF, Word or Excel files | $0.80 per 1,000 pages (a page with no text is free) |
|
|
32
32
|
|
|
33
33
|
Each tool takes `specstreamApiKey` (default: the `SPECSTREAM_API_KEY` environment variable), `apiBaseUrl`, `name` and `description`. A failed call returns `{ error }` to the model.
|
|
@@ -13,6 +13,11 @@ export type SpecStreamSearchAPIRetrieverFields = ToolParams & {
|
|
|
13
13
|
specstreamApiKey?: string;
|
|
14
14
|
/** Add the text of the top pages to every search. Takes up to about a second more. @default false */
|
|
15
15
|
passages?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* "fast" returns the first ranked results in about a second, at $1 per 1,000 searches.
|
|
18
|
+
* Left out, the API's default search runs ($5 per 1,000).
|
|
19
|
+
*/
|
|
20
|
+
speed?: "fast" | "default";
|
|
16
21
|
/** Replace the tool name. */
|
|
17
22
|
name?: string;
|
|
18
23
|
/** Replace the tool description. */
|
|
@@ -46,6 +51,7 @@ export declare class SpecStreamSearch extends StructuredTool<typeof inputSchema>
|
|
|
46
51
|
query: string;
|
|
47
52
|
}>;
|
|
48
53
|
passages?: boolean;
|
|
54
|
+
speed?: "fast" | "default";
|
|
49
55
|
private apiWrapper;
|
|
50
56
|
constructor(params?: SpecStreamSearchAPIRetrieverFields);
|
|
51
57
|
_call(input: InferInteropZodOutput<typeof inputSchema>, _runManager?: CallbackManagerForToolRun): Promise<SpecStreamSearchResponse | {
|
|
@@ -26,6 +26,7 @@ class SpecStreamSearch extends tools_1.StructuredTool {
|
|
|
26
26
|
name = "specstream_search";
|
|
27
27
|
schema = inputSchema;
|
|
28
28
|
passages;
|
|
29
|
+
speed;
|
|
29
30
|
apiWrapper;
|
|
30
31
|
constructor(params = {}) {
|
|
31
32
|
super(params);
|
|
@@ -36,6 +37,10 @@ class SpecStreamSearch extends tools_1.StructuredTool {
|
|
|
36
37
|
this.description = params.description;
|
|
37
38
|
}
|
|
38
39
|
this.passages = params.passages;
|
|
40
|
+
if (params.speed !== undefined && params.speed !== "fast" && params.speed !== "default") {
|
|
41
|
+
throw new Error('speed must be "default" or "fast".');
|
|
42
|
+
}
|
|
43
|
+
this.speed = params.speed;
|
|
39
44
|
this.apiWrapper =
|
|
40
45
|
params.apiWrapper ??
|
|
41
46
|
new utils_js_1.SpecStreamSearchAPIWrapper({
|
|
@@ -45,7 +50,7 @@ class SpecStreamSearch extends tools_1.StructuredTool {
|
|
|
45
50
|
}
|
|
46
51
|
async _call(input, _runManager) {
|
|
47
52
|
try {
|
|
48
|
-
return await this.apiWrapper.rawResults({ q: input.query, passages: this.passages });
|
|
53
|
+
return await this.apiWrapper.rawResults({ q: input.query, passages: this.passages, speed: this.speed });
|
|
49
54
|
}
|
|
50
55
|
catch (e) {
|
|
51
56
|
return { error: e instanceof Error ? e.message : String(e) };
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export type SpecStreamSearchParams = {
|
|
|
5
5
|
q: string;
|
|
6
6
|
/** Add the text of the top pages to the reply. */
|
|
7
7
|
passages?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* "fast" returns the engines' first ranked results in about a second, at $1 per 1,000 searches.
|
|
10
|
+
* Left out, the API's default search runs ($5 per 1,000).
|
|
11
|
+
*/
|
|
12
|
+
speed?: "fast" | "default";
|
|
8
13
|
};
|
|
9
14
|
export type SpecStreamSource = {
|
|
10
15
|
url: string;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -49,6 +49,12 @@ class SpecStreamSearchAPIWrapper extends BaseSpecStreamAPIWrapper {
|
|
|
49
49
|
if (params.passages) {
|
|
50
50
|
query.set("passages", "true");
|
|
51
51
|
}
|
|
52
|
+
if (params.speed !== undefined) {
|
|
53
|
+
if (params.speed !== "fast" && params.speed !== "default") {
|
|
54
|
+
throw new Error('speed must be "default" or "fast".');
|
|
55
|
+
}
|
|
56
|
+
query.set("speed", params.speed);
|
|
57
|
+
}
|
|
52
58
|
return this.call("GET", `/v1/web-search?${query.toString()}`);
|
|
53
59
|
}
|
|
54
60
|
}
|
|
@@ -13,6 +13,11 @@ export type SpecStreamSearchAPIRetrieverFields = ToolParams & {
|
|
|
13
13
|
specstreamApiKey?: string;
|
|
14
14
|
/** Add the text of the top pages to every search. Takes up to about a second more. @default false */
|
|
15
15
|
passages?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* "fast" returns the first ranked results in about a second, at $1 per 1,000 searches.
|
|
18
|
+
* Left out, the API's default search runs ($5 per 1,000).
|
|
19
|
+
*/
|
|
20
|
+
speed?: "fast" | "default";
|
|
16
21
|
/** Replace the tool name. */
|
|
17
22
|
name?: string;
|
|
18
23
|
/** Replace the tool description. */
|
|
@@ -46,6 +51,7 @@ export declare class SpecStreamSearch extends StructuredTool<typeof inputSchema>
|
|
|
46
51
|
query: string;
|
|
47
52
|
}>;
|
|
48
53
|
passages?: boolean;
|
|
54
|
+
speed?: "fast" | "default";
|
|
49
55
|
private apiWrapper;
|
|
50
56
|
constructor(params?: SpecStreamSearchAPIRetrieverFields);
|
|
51
57
|
_call(input: InferInteropZodOutput<typeof inputSchema>, _runManager?: CallbackManagerForToolRun): Promise<SpecStreamSearchResponse | {
|
|
@@ -23,6 +23,7 @@ export class SpecStreamSearch extends StructuredTool {
|
|
|
23
23
|
name = "specstream_search";
|
|
24
24
|
schema = inputSchema;
|
|
25
25
|
passages;
|
|
26
|
+
speed;
|
|
26
27
|
apiWrapper;
|
|
27
28
|
constructor(params = {}) {
|
|
28
29
|
super(params);
|
|
@@ -33,6 +34,10 @@ export class SpecStreamSearch extends StructuredTool {
|
|
|
33
34
|
this.description = params.description;
|
|
34
35
|
}
|
|
35
36
|
this.passages = params.passages;
|
|
37
|
+
if (params.speed !== undefined && params.speed !== "fast" && params.speed !== "default") {
|
|
38
|
+
throw new Error('speed must be "default" or "fast".');
|
|
39
|
+
}
|
|
40
|
+
this.speed = params.speed;
|
|
36
41
|
this.apiWrapper =
|
|
37
42
|
params.apiWrapper ??
|
|
38
43
|
new SpecStreamSearchAPIWrapper({
|
|
@@ -42,7 +47,7 @@ export class SpecStreamSearch extends StructuredTool {
|
|
|
42
47
|
}
|
|
43
48
|
async _call(input, _runManager) {
|
|
44
49
|
try {
|
|
45
|
-
return await this.apiWrapper.rawResults({ q: input.query, passages: this.passages });
|
|
50
|
+
return await this.apiWrapper.rawResults({ q: input.query, passages: this.passages, speed: this.speed });
|
|
46
51
|
}
|
|
47
52
|
catch (e) {
|
|
48
53
|
return { error: e instanceof Error ? e.message : String(e) };
|
package/dist/utils.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export type SpecStreamSearchParams = {
|
|
|
5
5
|
q: string;
|
|
6
6
|
/** Add the text of the top pages to the reply. */
|
|
7
7
|
passages?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* "fast" returns the engines' first ranked results in about a second, at $1 per 1,000 searches.
|
|
10
|
+
* Left out, the API's default search runs ($5 per 1,000).
|
|
11
|
+
*/
|
|
12
|
+
speed?: "fast" | "default";
|
|
8
13
|
};
|
|
9
14
|
export type SpecStreamSource = {
|
|
10
15
|
url: string;
|
package/dist/utils.js
CHANGED
|
@@ -46,6 +46,12 @@ export class SpecStreamSearchAPIWrapper extends BaseSpecStreamAPIWrapper {
|
|
|
46
46
|
if (params.passages) {
|
|
47
47
|
query.set("passages", "true");
|
|
48
48
|
}
|
|
49
|
+
if (params.speed !== undefined) {
|
|
50
|
+
if (params.speed !== "fast" && params.speed !== "default") {
|
|
51
|
+
throw new Error('speed must be "default" or "fast".');
|
|
52
|
+
}
|
|
53
|
+
query.set("speed", params.speed);
|
|
54
|
+
}
|
|
49
55
|
return this.call("GET", `/v1/web-search?${query.toString()}`);
|
|
50
56
|
}
|
|
51
57
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@specstream/langchain",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The live web data engine for LangChain.js: Search API ($5 per 1,000 searches), Extract API ($0.80 per 1,000 pages) and Deep Search.",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The live web data engine for LangChain.js: Search API ($5 per 1,000 searches of up to 10 results, or $1 on the fast tier), Extract API ($0.80 per 1,000 pages) and Deep Search.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20"
|