@devilsdev/rag-pipeline-utils

中文文档
3.9.1发布于 2026/11/11MITTypeScriptESM + CJS构建来源已验证近 30 天下载 5296

RAG for Node.js that tells you when your LLM is making things up

原始使用文档
文档目录6 节
  1. New in 3.9
  2. Catch the made-up bits
  3. A pipeline in a dozen lines
  4. Why people reach for it
  5. Take only what you need
  6. Go further

rag-pipeline-utils: RAG for Node.js that tells you when your LLM is making things up

npm version CI TypeScript types Node.js version License: MIT

rag-pipeline-utils

RAG for Node.js that tells you when your LLM is making things up.

Your chatbot just told someone they get thirty vacation days. The handbook says twenty. This library catches that: it checks every sentence of an answer against the sources it was given, numbers, "not"s and conditions included, with no extra model calls. It also builds the pipeline for you, if you want one.

npm install @devilsdev/rag-pipeline-utils

Node.js 22+. CommonJS, ESM and TypeScript types out of the box.

New in 3.9

  • Dropped conditions are caught. An answer that leaves out a condition its source sets, like "with manager approval", now fails the check.
  • Much faster on long answers. A 1,000-sentence answer is checked in under half a second.
  • Cleaner text from PDFs and web pages. It's normalised before it's compared.
  • /edge without nodejs_compat (3.9.1). Cached pipelines and cost estimates on Cloudflare Workers no longer throw "process.emitWarning is not a function"; the warning goes to console.warn.

Release notes · Changelog

Upgrading from 3.8.1 or earlier? Upgrade to 3.8.2 or later for its security fixes; 3.9.0 is recommended. If you store documents with top-level access restrictions in Qdrant, Pinecone, Weaviate or pgvector, re-ingest them: see 3.8.2.

Catch the made-up bits

Bring an answer from anywhere: this library, LangChain, Mastra, the AI SDK or LlamaIndex. Pass it in with the sources it was given:

import { checkAnswer } from "@devilsdev/rag-pipeline-utils";

const check = await checkAnswer({
  answer:
    "Full-time employees receive thirty days of paid vacation per year. " +
    "Remote work is allowed two days per week.",
  sources: [
    {
      pageContent:
        "Full-time employees receive twenty days of paid vacation per year.",
    },
    {
      pageContent:
        "Remote work is allowed two days per week with manager approval.",
    },
  ],
});

console.log(check.grounded); // false
console.log(check.groundedness); // 0
console.log(check.unsupported); // ["Full-time employees receive thirty days of paid vacation per year.", "Remote work is allowed two days per week."]
What checkAnswer catches: sentence 1 states the wrong number (thirty where the source says twenty); sentence 2 drops the condition "with manager approval". grounded: false.

Both sentences are caught: the first states the wrong number, and the second drops the "with manager approval" its source requires, which makes it claim more than the handbook says. That runs locally, with no API key and nothing sent anywhere. Worried about paraphrases? Add judge and your LLM gets asked about the sentences that failed on wording alone, and nothing else. Try it on StackBlitz with an answer of your own.

A pipeline in a dozen lines

No API key needed for this one either: a built-in TF-IDF embedder and an in-memory store. Swap in OpenAI, Anthropic, Ollama or any AI SDK model when you're ready.

import {
  createRagPipeline,
  LocalEmbedder,
  MemoryRetriever,
} from "@devilsdev/rag-pipeline-utils";

const docs = [
  { id: "vacation", content: "Full-time employees get twenty vacation days." },
  { id: "remote", content: "Remote work is allowed two days per week." },
];

const embedder = new LocalEmbedder();
embedder.train(docs.map((doc) => doc.content));
const retriever = new MemoryRetriever();
await retriever.store(
  docs.map((doc) => ({ ...doc, vector: embedder.embed(doc.content) })),
);

const pipeline = createRagPipeline({ embedder, retriever });
const result = await pipeline.run({ query: "How many vacation days?" });

console.log(result.results[0].id); // "vacation"

Rather start from a working app? npm create rag-pipeline@latest scaffolds one for Next.js with the AI SDK, Mastra, or Cloudflare Workers.

Why people reach for it

Nine reasons: grounding you can see, regressions fail the build, plays well with your stack, guardrails with receipts, ready for production, connectors included, a real CLI, runs at the edge, talk to it from Claude.
  • Grounding you can see. Per-sentence citations and a groundedness score, with numbers, units, dates and negation actually checked. verifyCitations() double-checks the citations Claude and OpenAI hand back.
  • Regressions fail the build. rag-pipeline eval scores a test set in CI and goes red when answers get worse. rag-eval-action posts the results on your pull request.
  • Plays well with your stack. Grounding middleware for any Vercel AI SDK model, Mastra scorers and guardrails, Jest and Vitest matchers.
  • Guardrails with receipts. Prompt-injection detection and PII redaction with published precision and recall, plus ACL filtering before anything reaches the model.
  • Ready for production. Hybrid search, reranking, token budgets, timeouts and cancellation, retries, caching, and OpenTelemetry (or Langfuse) traces with the scores attached.
  • Connectors included. OpenAI, Anthropic, Cohere, Ollama, pgvector, Qdrant, Pinecone and Weaviate. Anything with an embed() or generate() method works too.
  • A real CLI. init, ingest, query, eval and serve, against a local index, offline if you like.
  • Runs at the edge. A /edge build for Cloudflare Workers, Vercel Edge and Deno.
  • Talk to it from Claude. @devilsdev/rag-mcp-server lets Claude search a folder of your docs and check its own answers.

Take only what you need

The main package has everything. The smaller ones are there if install size matters:

PackageWhat you getInstalled
@devilsdev/rag-pipeline-utilsEverything, including the CLIabout 34 MB
@devilsdev/rag-coreThe pipeline, retrieval, caching and cost trackingabout 6 MB
@devilsdev/rag-connectorsModel and vector store connectorsabout 10 MB
@devilsdev/rag-evalEvaluation and answer checksabout 6 MB
@devilsdev/rag-guardrailsInjection detection, ACL filtering and PII redactionabout 6 MB
@devilsdev/rag-mcp-serverSearch and check a folder of documents from Claude (MCP)about 34 MB
create-rag-pipelinenpm create rag-pipeline: Next.js, Mastra or Workersunder 1 MB

Go further

Found a bug or have an idea? Open an issue. A star on GitHub helps other devs find it.

Published from GitHub Actions with npm provenance. Security reports: see SECURITY.md. MIT licensed.

版本与发布记录

@devilsdev/rag-pipeline-utils 共发布 49 个版本,首次发布于 2025/04/14;过去 12 个月发布了 30 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.9.1latest2026/11/111 天前
3.9.02026/11/101 天前
3.8.32026/11/093 天前
3.8.22026/11/093 天前
3.8.12026/11/074 天前
3.8.02026/11/065 天前

关于 @devilsdev/rag-pipeline-utils 的常见问题

@devilsdev/rag-pipeline-utils 是什么?

RAG for Node.js that tells you when your LLM is making things up

如何安装 @devilsdev/rag-pipeline-utils?

在项目目录运行 npm install @devilsdev/rag-pipeline-utils,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 rag-pipeline,可以用 npx rag-pipeline 直接运行。

@devilsdev/rag-pipeline-utils 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@devilsdev/rag-pipeline-utils 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@devilsdev/rag-pipeline-utils 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@devilsdev/rag-pipeline-utils 可以商用吗?

@devilsdev/rag-pipeline-utils 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@devilsdev/rag-pipeline-utils 的下载量有多少?

根据 npm 官方下载统计,@devilsdev/rag-pipeline-utils 在 2026/10/12 – 2026/11/10 这 30 天内被下载 5,296 次,日均约 177 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@devilsdev/rag-pipeline-utils 还在维护吗?

最新版本 3.9.1 发布于 2026/11/11(1 天前);至今共发布 49 个版本,其中过去 12 个月发布了 30 个;首次发布于 2025/04/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。