Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

@vakra-dev/langchain-reader

LangChain.js integration for Reader. Load web pages as LangChain Documents and use Reader as an agent tool.

Installation

npm install @vakra-dev/langchain-reader @langchain/core

Document Loader

Use ReaderLoader to scrape web pages and load them as LangChain Document objects for RAG pipelines.

import { ReaderLoader } from "@vakra-dev/langchain-reader";

// Single URL
const loader = new ReaderLoader({
  apiKey: "rdr_...",
  urls: ["https://example.com"],
});
const docs = await loader.load();
console.log(docs[0].pageContent);  // Markdown content
console.log(docs[0].metadata);     // { url, title, source, ... }

// Multiple URLs (batch)
const loader = new ReaderLoader({
  apiKey: "rdr_...",
  urls: [
    "https://example.com/page1",
    "https://example.com/page2",
    "https://example.com/page3",
  ],
});
const docs = await loader.load();

Options

Parameter Type Default Description
apiKey string required Reader API key
urls string[] required URLs to scrape
baseUrl string undefined Custom API URL for self-hosted Reader
formats string[] ["markdown"] Output formats
proxyMode string undefined "standard" or "premium"
onlyMainContent boolean true Extract main content only

Agent Tool

Use ReaderScrapeTool to give LangChain agents the ability to read web pages.

import { ReaderScrapeTool } from "@vakra-dev/langchain-reader";

const tool = new ReaderScrapeTool({ apiKey: "rdr_..." });

// Use directly
const result = await tool.invoke({ url: "https://example.com" });

// Or add to an agent
import { AgentExecutor } from "langchain/agents";
const agent = AgentExecutor.fromAgentAndTools({
  agent,
  tools: [tool],
});

License

MIT