主题
要解析远程文件,LiteParse 在 CLI 和库两种用法上都支持读取字节与流。CLI 可以用任何你喜欢的工具下载,再把字节通过管道交给 lit parse(把 - 作为文件参数);库则可以直接取到字节并传给解析器。
CLI 用法
终端窗口
# Parse a remote PDF
curl -sL https://example.com/report.pdf | lit parse -
# With options
curl -sL https://example.com/report.pdf | lit parse --no-ocr --format json -
# Save to a file
curl -sL https://example.com/report.pdf | lit parse -o report.txt -- 参数告诉 LiteParse 从 stdin 读取而不是文件路径。任何往 stdout 写的工具都能用 —— curl、wget、aws s3 cp - - 等。
库用法
TypeScript 库直接接受 Buffer/Uint8Array,所以你可以按自己喜欢的方式完成下载。
例如在 Node.js 环境里使用 fetch:
import { LiteParse } from "@llamaindex/liteparse";
const response = await fetch("https://example.com/report.pdf");
const buffer = Buffer.from(await response.arrayBuffer());
const parser = new LiteParse({ ocrEnabled: false });
const result = await parser.parse(buffer);
console.log(result.text);