# @devilsdev/rag-pipeline-utils 中文文档

规范地址：https://npmcn.com/package/%40devilsdev/rag-pipeline-utils/

版本：3\.9\.1
npm 元数据更新时间：2026-11-10T20:19:34.252Z
中文译文更新时间：2026-11-12T03:19:08.989Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40devilsdev/rag-pipeline-utils
原文对照：https://npmcn.com/package/%40devilsdev/rag-pipeline-utils/?lang=original
项目主页：https://devilsdev.github.io/rag-pipeline-utils/
源码仓库：https://github.com/DevilsDev/rag-pipeline-utils

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：4 MB，186 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=22
- 运行依赖：13 个
- peer 依赖：pg \>=8\.11\.0，openai \>=4\.93\.0，isolated-vm \>=6\.0\.0，pino-pretty \>=10\.0\.0，@opentelemetry/api \>=1\.0\.0 \<2
- 首次发布：2025-04-14T13:36:58.984Z
- 最新版本发布：2026-11-10T20:19:33.892Z
- 近 30 天下载量：5296（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：49（近 12 个月 30 个）

## 中文简介

{\\fn黑体\\fs22\\bord1\\shad0\\3aHBE\\4aH00\\fscx67\\fscy66\\2cHFFFFFF\\3cH808080}RAG for Node.js {\\fn黑体\\fs22\\bord1\\shad0\\3aHBE\\4aH00\\fscx67\\fscy66\\2cHFFFFFF\\3cH808080}告诉你LLM什么时候编造出来的

## 安装

```sh
npm install @devilsdev/rag-pipeline-utils
```

也可以使用：`pnpm add @devilsdev/rag-pipeline-utils`、`yarn add @devilsdev/rag-pipeline-utils`、`bun add @devilsdev/rag-pipeline-utils`

## README

![rag-pipeline-utils: RAG for Node.js that tells you when your LLM is making things up](https://cdn.jsdelivr.net/gh/DevilsDev/rag-pipeline-utils@v3.9.1/assets/banner.svg)

[![npm version](https://img.shields.io/npm/v/@devilsdev/rag-pipeline-utils?label=npm&labelColor=1f3a5a&color=b93815)](https://www.npmjs.com/package/@devilsdev/rag-pipeline-utils) [![CI](https://img.shields.io/github/actions/workflow/status/DevilsDev/rag-pipeline-utils/ci.yml?branch=main&label=CI&labelColor=1f3a5a)](https://github.com/DevilsDev/rag-pipeline-utils/actions/workflows/ci.yml) [![TypeScript types](https://img.shields.io/npm/types/@devilsdev/rag-pipeline-utils?labelColor=1f3a5a&color=57534e)](https://www.npmjs.com/package/@devilsdev/rag-pipeline-utils) [![Node.js version](https://img.shields.io/node/v/@devilsdev/rag-pipeline-utils?labelColor=1f3a5a&color=57534e)](https://nodejs.org/) [![License: MIT](https://img.shields.io/badge/license-MIT-57534e?labelColor=1f3a5a)](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/LICENSE)

# 破碎管式设备

**你的LLM是编造出来的.**

你的聊天员刚刚告诉别人了 _三十个_ 假期时间。 手册说二十. 这个库捕捉到:它对照它给出的源头检查一个答案的每一个句子,数字,"不"和包括条件,没有额外的模型呼叫. 如果你需要的话,它也会为你修建管道.

```bash
npm install @devilsdev/rag-pipeline-utils
```

节点.js 22+. 普通JS,无害环境管理和类型Script类型出框.

## 3.9中新设

-   **下降的条件被抓住.** 一个答案,不包含一个条件 它的源设置, 像"经管理者批准", 现在失败检查.
-   **长的答案要快得多.** 不到半秒,就会收到1000份判决答复.
-   **来自PDF和网页的更清洁文本.** 相取相取前正入正觉.
-   **`/edge` 无 `nodejs_compat` (3.9.1) (中文(简体) ).** Cloudflare工人的缓冲管线和成本估算不再抛出"process.emitwarning不是一个函数";警告到 `console.warn`。 。 。 .

[发布注释](https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v3.9.0) • 妇女 [更改日志](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/CHANGELOG.md)

> **从3.8.1升级还是提前升级?** 升级到3.8.2或以后的安保措施;建议3.9.0。 如果您在 Qdrant 、 Pinecone 、 Weaviate 或 pgvector 中存储具有顶级访问限制的文档, 请重新输入 : [3.8.2 联合国](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/CHANGELOG.md#382---2026-11-09)。 。 。 .

## 抓住化妆品

从任何地方带来一个答案:这个图书馆,LangChain, Mastra, AI SDK或LlamaIndex. 用它得到的来源传过来:

```js
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.](https://cdn.jsdelivr.net/gh/DevilsDev/rag-pipeline-utils@v3.9.1/assets/check-result.svg)

两个句子被抓住:第一个句子写错了号码,第二个句子删除了它的源头要求的"经管理者批准",这就使得它声称的比手册所说的要多. 运行于本地,没有API密钥 和没有发送任何地方。 担心句子吗? 添加 `judge` 你的LLM被问到 单凭措辞就失败的句子 而别无他法. [在StackBlitz上试试看](https://stackblitz.com/github/DevilsDev/rag-pipeline-utils/tree/main/examples/use-cases?file=check-your-answer.js) 带着你自己的答案.

## 一条十几条线路的管道

这一个也不需要 API 密钥: 内置的 TF- IDF 嵌入器和内存存储器 。 在OpenAI,Anthropic,Ollama或任何AI SDK模型中进行交换,当你准备好了.

```js
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"
```

从工作应用开始? `npm create rag-pipeline@latest` 脚手架为Next.js配有AI SDK,Mastra,或Cloudflare工人.

## 为什么人们会来找它

![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.](https://cdn.jsdelivr.net/gh/DevilsDev/rag-pipeline-utils@v3.9.1/assets/features.svg)

-   **{\\fn华文楷体\\fs16\\1cHE0E0E0}你可以看到地面.** 判决引用和依据得分,实际核对数字、单位、日期和否定. `verifyCitations()` 重复检查引用的 Claude 和 OpenAI 手.
-   **后退辜负了建设.** `rag-pipeline eval` 得分在CI的一组测试,当答案变得更糟时会红. [破旧行动](https://github.com/DevilsDev/rag-eval-action) 将结果张贴在您的拉动请求上.
-   **弹得不错.** 为任何Vercel AI SDK型号的中间软件打地基,马斯特拉分数和护栏,捷士和维特选手.
-   **有收据的护栏.** 快速注射检测和 PII 校正 [发表准确性和召回性](https://devilsdev.github.io/rag-pipeline-utils/docs/Benchmarks#guardrail-accuracy),加ACL过滤器,在任何东西到达模型之前.
-   **准备生产.** 混合搜索,再排行,符号预算,超时和取消,重试,缓存,以及带有分数的OpenTeleometry(或Langfuse)痕迹.
-   **包括连接器.** OpenAI, Anthropic, Cohere, Ollama, pgvector, Qdrant, Pinecone 和 韦维特. 任何与一个 `embed()` 或者说 `generate()` 方法也是可行的.
-   **一个真正的CLI.** `init`, (中文(简体) ), `ingest`, (中文(简体) ), `query`, (中文(简体) ), `eval` 财务报告和审定财务报表 `serve`在本地指数下,如果喜欢的话.
-   **奔跑在边缘.** A 类 `/edge` 为Cloudflare工人,Vercel Edge和德诺建造.
-   **和克劳德谈谈.** `@devilsdev/rag-mcp-server` 让克洛德搜索您的文件文件夹, 并检查自己的答案 .

## 随便拿吧

主包有诸相. 如果安装大小问题, 较小的就在那里 :

| 软件包 | 你得到的东西 | 已安装 |
| --- | --- | --- |
| [`@devilsdev/rag-pipeline-utils`](https://www.npmjs.com/package/@devilsdev/rag-pipeline-utils) | 所有的一切,包括CLI | 大约34 MB |
| [`@devilsdev/rag-core`](https://www.npmjs.com/package/@devilsdev/rag-core) | 管道、检索、缓存和费用追踪 | 约 6 MB |
| [`@devilsdev/rag-connectors`](https://www.npmjs.com/package/@devilsdev/rag-connectors) | 模型和向量存储连接器 | 大约 10 MB |
| [`@devilsdev/rag-eval`](https://www.npmjs.com/package/@devilsdev/rag-eval) | 评价和答复检查 | 约 6 MB |
| [`@devilsdev/rag-guardrails`](https://www.npmjs.com/package/@devilsdev/rag-guardrails) | 注射检测、ACL过滤和PII校正 | 约 6 MB |
| [`@devilsdev/rag-mcp-server`](https://www.npmjs.com/package/@devilsdev/rag-mcp-server) | 搜索和检查 Claude (MCP) 的文件文件夹 | 大约34 MB |
| [`create-rag-pipeline`](https://www.npmjs.com/package/create-rag-pipeline) | `npm create rag-pipeline`: 下个.js, Mastra 或工人 | 低于 1 MB |

## 继续

-   [使用可运行代码的大小写](https://github.com/DevilsDev/rag-pipeline-utils#use-cases)在StackBlitz上点击一次
-   [文档](https://devilsdev.github.io/rag-pipeline-utils/): 向导、 API 参考和 [国 际](https://devilsdev.github.io/rag-pipeline-utils/docs/CLI)
-   [如何比较](https://devilsdev.github.io/rag-pipeline-utils/docs/Comparison) 与LangChain.js,马斯特拉和AI SDK合作
-   [实例](https://github.com/DevilsDev/rag-pipeline-utils/tree/main/examples) 编辑 [更改日志](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/CHANGELOG.md)

找到窃听器还是有主意? [打开一个问题](https://github.com/DevilsDev/rag-pipeline-utils/issues)。一颗恒星在 [GitHub 图像](https://github.com/DevilsDev/rag-pipeline-utils) 帮助其他devs找到它.

发表于GitHub Actions with npm出处. 安保报告:见 [警卫](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/SECURITY.md)。 。 。 . [麻省理工学院](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/LICENSE) 有执照.

## 常见问题

### @devilsdev/rag-pipeline-utils 是什么？

\{\\fn黑体\\fs22\\bord1\\shad0\\3aHBE\\4aH00\\fscx67\\fscy66\\2cHFFFFFF\\3cH808080\}RAG for Node\.js \{\\fn黑体\\fs22\\bord1\\shad0\\3aHBE\\4aH00\\fscx67\\fscy66\\2cHFFFFFF\\3cH808080\}告诉你LLM什么时候编造出来的

### 如何安装 @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 和提交记录判断。

