Skip to content

Commit dc59d01

Browse files
committed
📦 NEW: Service option to crawl primtive
1 parent ad18654 commit dc59d01

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

examples/nodejs/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ LANGBASE_API_KEY=""
66
# https://dashboard.exa.ai/api-keys
77
EXA_API_KEY=""
88
CRAWL_KEY=""
9+
FIRECRAWL_KEY=""

examples/nodejs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"pipe.structured.outputs": "npx tsx ./pipes/pipe.structured.outputs.ts",
3434
"tools.web-search": "npx tsx ./tools/web-search.ts",
3535
"tools.crawl": "npx tsx ./tools/crawl.ts",
36+
"tools.crawl.firecrawl": "npx tsx ./tools/crawl.firecrawl.ts",
3637
"embed": "npx tsx ./embed/index.ts",
3738
"chunker": "npx tsx ./chunker/index.ts",
3839
"parser": "npx tsx ./parser/index.ts",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Experimental upcoming beta AI primitve.
2+
// Please refer to the documentation for more information: https://langbase.com/docs for more information.
3+
import 'dotenv/config';
4+
import {Langbase} from 'langbase';
5+
6+
const langbase = new Langbase({
7+
apiKey: process.env.LANGBASE_API_KEY!,
8+
});
9+
10+
/**
11+
* Crawls specified URLs using firecrawl.dev service.
12+
*
13+
* Get your API key from the following link and set it in .env file.
14+
*
15+
* @link https://docs.firecrawl.dev/introduction
16+
*/
17+
async function main() {
18+
const results = await langbase.tools.crawl({
19+
url: ['https://langbase.com', 'https://langbase.com/about'],
20+
maxPages: 1,
21+
apiKey: process.env.FIRECRAWL_KEY!,
22+
service: 'firecrawl',
23+
});
24+
25+
console.log(results);
26+
}
27+
28+
main();

examples/nodejs/tools/crawl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async function main() {
1818
const results = await langbase.tools.crawl({
1919
url: ['https://langbase.com', 'https://langbase.com/about'],
2020
maxPages: 1,
21-
apiKey: process.env.CRAWL_KEY,
21+
apiKey: process.env.CRAWL_KEY!,
2222
});
2323

2424
console.log(results);

packages/langbase/src/langbase/langbase.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ export interface ToolCrawlOptions {
394394
url: string[];
395395
maxPages?: number;
396396
apiKey: string;
397+
service?: 'spider' | 'firecrawl';
397398
}
398399

399400
export interface ToolCrawlResponse {

0 commit comments

Comments
 (0)