@devilsdev/rag-pipeline-utils 2.6.0 → 2.6.1

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +98 -23
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -11,6 +11,21 @@ page.
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [2.6.1] - 2026-10-29
15
+
16
+ Documentation only; no code changes.
17
+
18
+ ### Changed
19
+
20
+ - **README covers the 2.6.0 features**, so the npm package page shows
21
+ them: `checkAnswer` for answers from other frameworks, the `/testing`
22
+ entry, caching, the `query` `--explain`, `--trace`, `--stats` and
23
+ `--streaming` options, `OpenAIConnector` `baseURL` and the AI SDK
24
+ adapter.
25
+ - **StackBlitz examples checked**: the basic pipeline, OpenAI with
26
+ Pinecone (offline mock) and the Fastify service each install and run.
27
+ The docs now say to reload if StackBlitz stalls while cloning.
28
+
14
29
  ## [2.6.0] - 2026-10-29
15
30
 
16
31
  ### Added
@@ -552,6 +567,7 @@ First public release on the 2.4 line, introducing the v2.4 feature set.
552
567
  For release notes prior to v2.4.0, see
553
568
  [github.com/DevilsDev/rag-pipeline-utils/releases](https://github.com/DevilsDev/rag-pipeline-utils/releases).
554
569
 
570
+ [2.6.1]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.6.1
555
571
  [2.6.0]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.6.0
556
572
  [2.5.0]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.5.0
557
573
  [2.4.5]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.4.5
package/README.md CHANGED
@@ -143,7 +143,15 @@ npx rag-pipeline serve --port 3000 # local HTTP API: GET /health, POST /
143
143
  npx rag-pipeline doctor # checks config, API keys, plugins and the index
144
144
  ```
145
145
 
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. See the [CLI reference](https://devilsdev.github.io/rag-pipeline-utils/docs/CLI).
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.
147
+
148
+ `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:
149
+
150
+ ```bash
151
+ npx rag-pipeline query "How many vacation days do I get?" --explain --trace
152
+ ```
153
+
154
+ See the [CLI reference](https://devilsdev.github.io/rag-pipeline-utils/docs/CLI).
147
155
 
148
156
  ## Use cases
149
157
 
@@ -198,6 +206,45 @@ console.log(report.scores); // includes contextRecall because a reference was gi
198
206
  if (report.scores.faithfulness < 0.8) process.exitCode = 1;
199
207
  ```
200
208
 
209
+ ### Check answers from another framework
210
+
211
+ 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:
212
+
213
+ ```js
214
+ import { checkAnswer } from "@devilsdev/rag-pipeline-utils";
215
+
216
+ const check = await checkAnswer({
217
+ question: "How many vacation days do I get?",
218
+ answer: "Full-time employees receive thirty days of paid vacation per year.",
219
+ sources: [
220
+ {
221
+ pageContent:
222
+ "Full-time employees receive twenty days of paid vacation per year.",
223
+ metadata: { source: "handbook.md" },
224
+ },
225
+ ],
226
+ });
227
+
228
+ console.log(check.grounded); // false
229
+ console.log(check.unsupported.length); // 1
230
+ ```
231
+
232
+ ### Test your RAG code offline
233
+
234
+ `@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:
235
+
236
+ ```js
237
+ import { createTestPipeline } from "@devilsdev/rag-pipeline-utils/testing";
238
+
239
+ const { pipeline, llm } = await createTestPipeline();
240
+ const result = await pipeline.run({
241
+ query: "How many vacation days do I get?",
242
+ });
243
+
244
+ console.log(result.results[0].id); // "vacation"
245
+ console.log(llm.calls.length); // 1
246
+ ```
247
+
201
248
  ### Protect an internal assistant
202
249
 
203
250
  `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 +401,30 @@ const result = await pipeline.run({
354
401
  if (!result.success) console.error(result.error); // "Execution timeout" or "Execution aborted"
355
402
  ```
356
403
 
404
+ ### Cache repeated questions
405
+
406
+ `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:
407
+
408
+ ```js
409
+ import { createRagPipeline } from "@devilsdev/rag-pipeline-utils";
410
+ import {
411
+ createTestPipeline,
412
+ EchoLLM,
413
+ } from "@devilsdev/rag-pipeline-utils/testing";
414
+
415
+ const { embedder, retriever } = await createTestPipeline();
416
+ const llm = new EchoLLM();
417
+ const pipeline = createRagPipeline({ embedder, retriever, llm, cache: true });
418
+
419
+ await pipeline.run({ query: "How many vacation days do I get?" });
420
+ const again = await pipeline.run({ query: "How many vacation days do I get?" });
421
+
422
+ console.log(again.cache.generation); // "hit"
423
+ console.log(llm.calls.length); // 1
424
+ ```
425
+
426
+ Answers are cached only at temperature 0. See [Caching](https://devilsdev.github.io/rag-pipeline-utils/docs/Caching).
427
+
357
428
  ### Run fully local
358
429
 
359
430
  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 +462,22 @@ The result of `run()` is:
391
462
 
392
463
  ## Capabilities
393
464
 
394
- | Area | What you get |
395
- | -------------- | ---------------------------------------------------------------------------------------------------------- |
396
- | **Chunking** | `ChunkingEngine` with sentence, fixed-size, recursive, semantic and structure-aware strategies |
397
- | **Retrieval** | `MemoryRetriever`, persistent `FileVectorStore`, `BM25Search`, `HybridRetriever` (Reciprocal Rank Fusion) |
398
- | **Reranking** | `ScoringReranker`, `EmbeddingReranker` (cached), `CascadeReranker` |
399
- | **Citations** | Per-sentence source mapping, hallucination report, numeric-consistency check |
400
- | **Evaluation** | Faithfulness, relevance, context precision, context recall (with a reference), groundedness, BLEU/ROUGE |
401
- | **Guardrails** | Injection detection with input normalisation, ACL and relevance filtering before generation, PII redaction |
402
- | **Agentic** | `QueryPlanner`, `IterativeRetriever`, `SelfCritiqueChecker`, `AgenticPipeline` |
403
- | **GraphRAG** | `KnowledgeGraph`, `EntityExtractor`, `GraphRetriever` |
404
- | **Streaming** | Token streaming with a final chunk carrying citations and evaluation; `SSEAdapter`, `WebSocketAdapter` |
405
- | **Cost** | `CostTracker`, `TokenBudget`, `CostCalculator` with sourced, overridable pricing |
406
- | **Operations** | `DevServer` HTTP API, `ExecutionTracer`, `AuditLogger`, MCP tool server (`MCPServer`) |
465
+ | Area | What you get |
466
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
467
+ | **Chunking** | `ChunkingEngine` with sentence, fixed-size, recursive, semantic and structure-aware strategies |
468
+ | **Retrieval** | `MemoryRetriever`, persistent `FileVectorStore`, `BM25Search`, `HybridRetriever` (Reciprocal Rank Fusion) |
469
+ | **Reranking** | `ScoringReranker`, `EmbeddingReranker` (cached), `CascadeReranker` |
470
+ | **Citations** | Per-sentence source mapping, hallucination report, numeric-consistency check |
471
+ | **Evaluation** | Faithfulness, relevance, context precision, context recall (with a reference), groundedness, BLEU/ROUGE, semantic similarity with any embedder |
472
+ | **Integrations** | `checkAnswer` for answers from LangChain, LlamaIndex, Mastra or the AI SDK; `createAiSdkAdapter` |
473
+ | **Caching** | Opt-in caches for query embeddings, retrieval and answers, in memory (`MemoryCache`) or Redis (`RedisCache`) |
474
+ | **Testing** | `/testing` entry: offline `HashEmbedder`, `EchoLLM`, fixtures, `createTestPipeline()`; `validatePlugin` for plugin tests |
475
+ | **Guardrails** | Injection detection with input normalisation, ACL and relevance filtering before generation, PII redaction |
476
+ | **Agentic** | `QueryPlanner`, `IterativeRetriever`, `SelfCritiqueChecker`, `AgenticPipeline` |
477
+ | **GraphRAG** | `KnowledgeGraph`, `EntityExtractor`, `GraphRetriever` |
478
+ | **Streaming** | Token streaming with a final chunk carrying citations and evaluation; `SSEAdapter`, `WebSocketAdapter` |
479
+ | **Cost** | `CostTracker`, `TokenBudget`, `CostCalculator` with sourced, overridable pricing |
480
+ | **Operations** | `DevServer` HTTP API, `ExecutionTracer`, `AuditLogger`, MCP tool server (`MCPServer`) |
407
481
 
408
482
  ## How it compares
409
483
 
@@ -422,17 +496,18 @@ A short summary of the [comparison page](https://devilsdev.github.io/rag-pipelin
422
496
  | Stability | Documented [SEMVER policy](SEMVER.md) with deprecations | Versioned per package | Versioned |
423
497
 
424
498
  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
499
 
427
500
  ## Connectors and plugins
428
501
 
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 |
502
+ | Connector | Embeddings | Generation | Notes |
503
+ | -------------------- | :--------: | :--------: | ---------------------------------------------------------------------------------------- |
504
+ | `OpenAIConnector` | ✓ | ✓ | `OPENAI_API_KEY`; `baseURL` for OpenAI-compatible APIs (Groq, Together, vLLM, LM Studio) |
505
+ | `AnthropicConnector` | | ✓ | `ANTHROPIC_API_KEY` |
506
+ | `CohereConnector` | ✓ | | Embeddings and reranking, `COHERE_API_KEY` |
507
+ | `OllamaConnector` | ✓ | ✓ | Local models, no key |
508
+ | `LocalEmbedder` | ✓ | | Offline TF-IDF, fitted to your corpus |
509
+
510
+ 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
511
 
437
512
  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
513
 
@@ -451,7 +526,7 @@ Simulated or incomplete modules live under a separate entry point and are not co
451
526
  import { TenantManager } from "@devilsdev/rag-pipeline-utils/experimental";
452
527
  ```
453
528
 
454
- They are still exported from the main entry in 2.5 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.
529
+ 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
530
 
456
531
  ## Compatibility
457
532
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devilsdev/rag-pipeline-utils",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
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",