UNPKG

@kaibanjs/tools

Version:

A set of tools to work with LLMs and KaibanJS

102 lines (101 loc) 2.83 kB
/** * Firecrawl * * This tool integrates with Firecrawl (https://www.firecrawl.dev/), a web scraping * and crawling service designed to turn websites into LLM-ready data. * * Firecrawl allows you to extract clean, well-formatted markdown or structured data * from websites, making it ideal for AI applications, particularly those using * Large Language Models (LLMs). * * Key features of Firecrawl: * - Scrapes and crawls websites, even those with dynamic content * - Converts web content into clean, LLM-ready markdown * - Handles challenges like rate limits, JavaScript rendering, and anti-bot mechanisms * - Offers flexible pricing plans, including a free tier for small-scale use * * For more information about Firecrawl, visit: https://www.firecrawl.dev/ */ import { StructuredTool } from '@langchain/core/tools'; import { z } from 'zod'; /** * Configuration options for initializing the Firecrawl tool * @example * { * apiKey: "your-api-key", * format: "markdown" * } */ interface FirecrawlToolFields { apiKey: string; format?: string; } /** * Parameters for making a scraping request * @example * { * url: "https://example.com/article", * format: "markdown", * mode: "scrape" * } */ interface FirecrawlToolParams { url: string; format?: string; mode?: string; } /** The scraped content returned as a string */ type FirecrawlToolResponse = string; /** Error message returned when the scraping fails */ type FirecrawlToolError = string; /** * Firecrawl tool for scraping web content and converting it to LLM-ready formats * * @example * ```typescript * const firecrawl = new Firecrawl({ * apiKey: 'your-api-key', * format: 'markdown' * }); * * const content = await firecrawl.call({ * url: 'https://example.com/article' * }); * ``` */ export declare class Firecrawl extends StructuredTool { private apiKey; private format; private mode; private httpClient; name: string; description: string; schema: z.ZodObject<{ url: z.ZodString; }, "strip", z.ZodTypeAny, { url: string; }, { url: string; }>; /** * Creates a new instance of the Firecrawl tool * * @param fields - Configuration options for the scraping tool */ constructor(fields: FirecrawlToolFields); /** * Scrapes content from a URL using the Firecrawl API * * @param input - The parameters containing the URL to scrape * @returns A promise that resolves to either the scraped content or an error message * * @example * ```typescript * const content = await firecrawl._call({ * url: 'https://example.com/article' * }); * ``` */ _call(input: FirecrawlToolParams): Promise<FirecrawlToolResponse | FirecrawlToolError>; } export {};