@devilsdev/rag-pipeline-utils 2.6.0 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +100 -23
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,34 @@ page.
|
|
|
11
11
|
|
|
12
12
|
## [Unreleased]
|
|
13
13
|
|
|
14
|
+
## [2.6.2] - 2026-10-29
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **`npm install` failed on machines without husky installed globally.**
|
|
19
|
+
Every release from 2.2.1 to 2.6.1 declared
|
|
20
|
+
`"postinstall": "husky install"`. husky is a development tool that isn't
|
|
21
|
+
installed in users' projects, so installing the package failed with
|
|
22
|
+
`husky: not found` (or `'husky' is not recognized` on Windows) on clean
|
|
23
|
+
machines and CI runners. The hook now runs from `prepare`, which npm runs
|
|
24
|
+
only in this repository, and the pack smoke test fails if the package
|
|
25
|
+
has any install-time script. No code changes.
|
|
26
|
+
|
|
27
|
+
## [2.6.1] - 2026-10-29
|
|
28
|
+
|
|
29
|
+
Documentation only; no code changes.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- **README covers the 2.6.0 features**, so the npm package page shows
|
|
34
|
+
them: `checkAnswer` for answers from other frameworks, the `/testing`
|
|
35
|
+
entry, caching, the `query` `--explain`, `--trace`, `--stats` and
|
|
36
|
+
`--streaming` options, `OpenAIConnector` `baseURL` and the AI SDK
|
|
37
|
+
adapter.
|
|
38
|
+
- **StackBlitz examples checked**: the basic pipeline, OpenAI with
|
|
39
|
+
Pinecone (offline mock) and the Fastify service each install and run.
|
|
40
|
+
The docs now say to reload if StackBlitz stalls while cloning.
|
|
41
|
+
|
|
14
42
|
## [2.6.0] - 2026-10-29
|
|
15
43
|
|
|
16
44
|
### Added
|
|
@@ -552,6 +580,8 @@ First public release on the 2.4 line, introducing the v2.4 feature set.
|
|
|
552
580
|
For release notes prior to v2.4.0, see
|
|
553
581
|
[github.com/DevilsDev/rag-pipeline-utils/releases](https://github.com/DevilsDev/rag-pipeline-utils/releases).
|
|
554
582
|
|
|
583
|
+
[2.6.2]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.6.2
|
|
584
|
+
[2.6.1]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.6.1
|
|
555
585
|
[2.6.0]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.6.0
|
|
556
586
|
[2.5.0]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.5.0
|
|
557
587
|
[2.4.5]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.4.5
|
package/README.md
CHANGED
|
@@ -52,6 +52,8 @@ npm install @devilsdev/rag-pipeline-utils
|
|
|
52
52
|
|
|
53
53
|
Requires Node.js 18 or later. The package ships CommonJS, ESM and TypeScript declarations.
|
|
54
54
|
|
|
55
|
+
> **`npm install` failed with `husky: not found`?** Versions 2.2.1 to 2.6.1 ran a development hook on install. Install 2.6.2 or later: `npm install @devilsdev/rag-pipeline-utils@latest`.
|
|
56
|
+
|
|
55
57
|
## Quick start
|
|
56
58
|
|
|
57
59
|
This example runs offline: it uses the built-in TF-IDF embedder and an in-memory vector store.
|
|
@@ -143,7 +145,15 @@ npx rag-pipeline serve --port 3000 # local HTTP API: GET /health, POST /
|
|
|
143
145
|
npx rag-pipeline doctor # checks config, API keys, plugins and the index
|
|
144
146
|
```
|
|
145
147
|
|
|
146
|
-
The default `local` template needs no API keys. Use `init --template openai`, `anthropic` or `ollama` to generate answers with a model. Other commands include `validate`, `hub install` for plugins and `ai benchmark` for measured latency.
|
|
148
|
+
The default `local` template needs no API keys. Use `init --template openai`, `anthropic` or `ollama` to generate answers with a model. Other commands include `validate`, `hub install` for plugins and `ai benchmark` for measured latency.
|
|
149
|
+
|
|
150
|
+
`query` can also show its work: `--explain` lists each passage's score and which passages support each sentence, `--trace` times each stage, `--stats` estimates tokens and cost, and `--streaming` prints the answer as it is generated:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npx rag-pipeline query "How many vacation days do I get?" --explain --trace
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
See the [CLI reference](https://devilsdev.github.io/rag-pipeline-utils/docs/CLI).
|
|
147
157
|
|
|
148
158
|
## Use cases
|
|
149
159
|
|
|
@@ -198,6 +208,45 @@ console.log(report.scores); // includes contextRecall because a reference was gi
|
|
|
198
208
|
if (report.scores.faithfulness < 0.8) process.exitCode = 1;
|
|
199
209
|
```
|
|
200
210
|
|
|
211
|
+
### Check answers from another framework
|
|
212
|
+
|
|
213
|
+
Already on LangChain, LlamaIndex, Mastra or the AI SDK? `checkAnswer` checks the answer your chain produced against the sources it was given, in the shape your framework returns them:
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
import { checkAnswer } from "@devilsdev/rag-pipeline-utils";
|
|
217
|
+
|
|
218
|
+
const check = await checkAnswer({
|
|
219
|
+
question: "How many vacation days do I get?",
|
|
220
|
+
answer: "Full-time employees receive thirty days of paid vacation per year.",
|
|
221
|
+
sources: [
|
|
222
|
+
{
|
|
223
|
+
pageContent:
|
|
224
|
+
"Full-time employees receive twenty days of paid vacation per year.",
|
|
225
|
+
metadata: { source: "handbook.md" },
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
console.log(check.grounded); // false
|
|
231
|
+
console.log(check.unsupported.length); // 1
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Test your RAG code offline
|
|
235
|
+
|
|
236
|
+
`@devilsdev/rag-pipeline-utils/testing` has a deterministic embedder, an LLM that echoes the top passage and records its calls, and fixture documents, so tests need no network or API keys:
|
|
237
|
+
|
|
238
|
+
```js
|
|
239
|
+
import { createTestPipeline } from "@devilsdev/rag-pipeline-utils/testing";
|
|
240
|
+
|
|
241
|
+
const { pipeline, llm } = await createTestPipeline();
|
|
242
|
+
const result = await pipeline.run({
|
|
243
|
+
query: "How many vacation days do I get?",
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
console.log(result.results[0].id); // "vacation"
|
|
247
|
+
console.log(llm.calls.length); // 1
|
|
248
|
+
```
|
|
249
|
+
|
|
201
250
|
### Protect an internal assistant
|
|
202
251
|
|
|
203
252
|
`GuardrailsPipeline` wraps any pipeline. Access control runs before the LLM sees a document, prompt-injection detection runs on the query, and PII is redacted from the answer, its citations and its evaluation details.
|
|
@@ -354,6 +403,30 @@ const result = await pipeline.run({
|
|
|
354
403
|
if (!result.success) console.error(result.error); // "Execution timeout" or "Execution aborted"
|
|
355
404
|
```
|
|
356
405
|
|
|
406
|
+
### Cache repeated questions
|
|
407
|
+
|
|
408
|
+
`cache: true` caches query embeddings, retrieval results and answers in memory, so a repeated question makes no model calls. Use `RedisCache` to share the cache between processes. Cached results are not reused when the index, embedder, model or its settings change, and access-control filtering still runs on every request:
|
|
409
|
+
|
|
410
|
+
```js
|
|
411
|
+
import { createRagPipeline } from "@devilsdev/rag-pipeline-utils";
|
|
412
|
+
import {
|
|
413
|
+
createTestPipeline,
|
|
414
|
+
EchoLLM,
|
|
415
|
+
} from "@devilsdev/rag-pipeline-utils/testing";
|
|
416
|
+
|
|
417
|
+
const { embedder, retriever } = await createTestPipeline();
|
|
418
|
+
const llm = new EchoLLM();
|
|
419
|
+
const pipeline = createRagPipeline({ embedder, retriever, llm, cache: true });
|
|
420
|
+
|
|
421
|
+
await pipeline.run({ query: "How many vacation days do I get?" });
|
|
422
|
+
const again = await pipeline.run({ query: "How many vacation days do I get?" });
|
|
423
|
+
|
|
424
|
+
console.log(again.cache.generation); // "hit"
|
|
425
|
+
console.log(llm.calls.length); // 1
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Answers are cached only at temperature 0. See [Caching](https://devilsdev.github.io/rag-pipeline-utils/docs/Caching).
|
|
429
|
+
|
|
357
430
|
### Run fully local
|
|
358
431
|
|
|
359
432
|
Pair the `LocalEmbedder` or Ollama embeddings with an Ollama model and `FileVectorStore` for a private, offline setup. The CLI's `local` and `ollama` templates set this up for you:
|
|
@@ -391,19 +464,22 @@ The result of `run()` is:
|
|
|
391
464
|
|
|
392
465
|
## Capabilities
|
|
393
466
|
|
|
394
|
-
| Area
|
|
395
|
-
|
|
|
396
|
-
| **Chunking**
|
|
397
|
-
| **Retrieval**
|
|
398
|
-
| **Reranking**
|
|
399
|
-
| **Citations**
|
|
400
|
-
| **Evaluation**
|
|
401
|
-
| **
|
|
402
|
-
| **
|
|
403
|
-
| **
|
|
404
|
-
| **
|
|
405
|
-
| **
|
|
406
|
-
| **
|
|
467
|
+
| Area | What you get |
|
|
468
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
469
|
+
| **Chunking** | `ChunkingEngine` with sentence, fixed-size, recursive, semantic and structure-aware strategies |
|
|
470
|
+
| **Retrieval** | `MemoryRetriever`, persistent `FileVectorStore`, `BM25Search`, `HybridRetriever` (Reciprocal Rank Fusion) |
|
|
471
|
+
| **Reranking** | `ScoringReranker`, `EmbeddingReranker` (cached), `CascadeReranker` |
|
|
472
|
+
| **Citations** | Per-sentence source mapping, hallucination report, numeric-consistency check |
|
|
473
|
+
| **Evaluation** | Faithfulness, relevance, context precision, context recall (with a reference), groundedness, BLEU/ROUGE, semantic similarity with any embedder |
|
|
474
|
+
| **Integrations** | `checkAnswer` for answers from LangChain, LlamaIndex, Mastra or the AI SDK; `createAiSdkAdapter` |
|
|
475
|
+
| **Caching** | Opt-in caches for query embeddings, retrieval and answers, in memory (`MemoryCache`) or Redis (`RedisCache`) |
|
|
476
|
+
| **Testing** | `/testing` entry: offline `HashEmbedder`, `EchoLLM`, fixtures, `createTestPipeline()`; `validatePlugin` for plugin tests |
|
|
477
|
+
| **Guardrails** | Injection detection with input normalisation, ACL and relevance filtering before generation, PII redaction |
|
|
478
|
+
| **Agentic** | `QueryPlanner`, `IterativeRetriever`, `SelfCritiqueChecker`, `AgenticPipeline` |
|
|
479
|
+
| **GraphRAG** | `KnowledgeGraph`, `EntityExtractor`, `GraphRetriever` |
|
|
480
|
+
| **Streaming** | Token streaming with a final chunk carrying citations and evaluation; `SSEAdapter`, `WebSocketAdapter` |
|
|
481
|
+
| **Cost** | `CostTracker`, `TokenBudget`, `CostCalculator` with sourced, overridable pricing |
|
|
482
|
+
| **Operations** | `DevServer` HTTP API, `ExecutionTracer`, `AuditLogger`, MCP tool server (`MCPServer`) |
|
|
407
483
|
|
|
408
484
|
## How it compares
|
|
409
485
|
|
|
@@ -422,17 +498,18 @@ A short summary of the [comparison page](https://devilsdev.github.io/rag-pipelin
|
|
|
422
498
|
| Stability | Documented [SEMVER policy](SEMVER.md) with deprecations | Versioned per package | Versioned |
|
|
423
499
|
|
|
424
500
|
Choose LangChain.js for the widest integration catalogue or work that goes well beyond RAG, and LlamaIndex.TS for rich index types and structured data sources. Choose this library when evaluation, citations and guardrails are requirements and you want a small surface to review.
|
|
425
|
-
3
|
|
426
501
|
|
|
427
502
|
## Connectors and plugins
|
|
428
503
|
|
|
429
|
-
| Connector | Embeddings | Generation | Notes
|
|
430
|
-
| -------------------- | :--------: | :--------: |
|
|
431
|
-
| `OpenAIConnector` | ✓ | ✓ | `OPENAI_API_KEY`
|
|
432
|
-
| `AnthropicConnector` | | ✓ | `ANTHROPIC_API_KEY`
|
|
433
|
-
| `CohereConnector` | ✓ | | Embeddings and reranking, `COHERE_API_KEY`
|
|
434
|
-
| `OllamaConnector` | ✓ | ✓ | Local models, no key
|
|
435
|
-
| `LocalEmbedder` | ✓ | | Offline TF-IDF, fitted to your corpus
|
|
504
|
+
| Connector | Embeddings | Generation | Notes |
|
|
505
|
+
| -------------------- | :--------: | :--------: | ---------------------------------------------------------------------------------------- |
|
|
506
|
+
| `OpenAIConnector` | ✓ | ✓ | `OPENAI_API_KEY`; `baseURL` for OpenAI-compatible APIs (Groq, Together, vLLM, LM Studio) |
|
|
507
|
+
| `AnthropicConnector` | | ✓ | `ANTHROPIC_API_KEY` |
|
|
508
|
+
| `CohereConnector` | ✓ | | Embeddings and reranking, `COHERE_API_KEY` |
|
|
509
|
+
| `OllamaConnector` | ✓ | ✓ | Local models, no key |
|
|
510
|
+
| `LocalEmbedder` | ✓ | | Offline TF-IDF, fitted to your corpus |
|
|
511
|
+
|
|
512
|
+
Vercel AI SDK models (any provider it supports) work as the embedder and LLM through `createAiSdkAdapter`; see [Use with other frameworks](https://devilsdev.github.io/rag-pipeline-utils/docs/Integrations).
|
|
436
513
|
|
|
437
514
|
Connectors read API keys when they are created, retry only transient failures (network errors, 429, 5xx) with backoff, and send retrieved documents to the model as clearly delimited, untrusted reference data rather than as instructions.
|
|
438
515
|
|
|
@@ -451,7 +528,7 @@ Simulated or incomplete modules live under a separate entry point and are not co
|
|
|
451
528
|
import { TenantManager } from "@devilsdev/rag-pipeline-utils/experimental";
|
|
452
529
|
```
|
|
453
530
|
|
|
454
|
-
They are still exported from the main entry in 2.
|
|
531
|
+
They are still exported from the main entry in 2.x with a one-time deprecation warning, and will be removed from it in 3.0. Do not use them for authentication, tenant isolation or compliance. The [Experimental modules](https://devilsdev.github.io/rag-pipeline-utils/docs/Experimental) page describes what each one really does.
|
|
455
532
|
|
|
456
533
|
## Compatibility
|
|
457
534
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devilsdev/rag-pipeline-utils",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "Composable retrieval-augmented generation (RAG) for Node.js: grounded citations, evaluation, guardrails, hybrid retrieval and a CLI.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"lint:diagnostic:ts": "eslint . --ext .js,.jsx,.ts,.tsx --format=stylish",
|
|
66
66
|
"lint:errors-only:ts": "eslint . --ext .js,.jsx,.ts,.tsx --quiet",
|
|
67
67
|
"lint-staged": "lint-staged",
|
|
68
|
-
"
|
|
68
|
+
"prepare": "husky install",
|
|
69
69
|
"verify:mocks": "node scripts/verify-fixture-mocks.js",
|
|
70
70
|
"build:docs": "npm run docs:build",
|
|
71
71
|
"ci": "node scripts/ci-runner.js",
|