npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@devilsdev/rag-pipeline-utils

v2.4.5

Published

Composable RAG for Node.js — with built-in evaluation, citations, guardrails, and observability.

Readme

rag-pipeline-utils

Composable RAG for Node.js — with built-in evaluation, citations, guardrails, and observability.

npm version Downloads Types License: MIT Node.js

Start small with three core primitives — pipeline, plugin, connector — and opt in to evaluation, citations, guardrails, agentic reasoning, and GraphRAG as you need them.

Installation

npm install @devilsdev/rag-pipeline-utils

Quick Start

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

const pipeline = createRagPipeline({
  retriever: new MemoryRetriever(),
  llm: new OpenAIConnector({ apiKey: process.env.OPENAI_API_KEY }),
});

const result = await pipeline.run({
  query: "What is the vacation policy?",
  options: { citations: true, evaluate: true },
});

console.log(result.results); // retrieved documents
console.log(result.citations.groundednessScore); // 0.85
console.log(result.evaluation.scores); // { faithfulness, relevance, ... }

Requirements: Node.js ≥ 18 · ESM or CommonJS

Who This Is For

Teams building production Node.js RAG services who need:

  • Grounded outputs they can trace back to sources
  • Modular architecture that doesn't lock them into a single provider
  • Operational discipline — tracing, metrics, cost controls, guardrails
  • A stable foundation with clear plugin contracts that outlast any vendor

If you're looking for a framework you can grow into — start with retrieval, add evaluation when it matters, add guardrails when you ship to production — this is built for you.

Use Cases

Document Q&A with citations

const result = await pipeline.run({
  query: "Which policy covers remote work?",
  options: { citations: true },
});
// result.citations maps each answer sentence to its source documents

Internal knowledge assistant with evaluation

const result = await pipeline.run({
  query: userQuestion,
  options: { evaluate: true },
});
// result.evaluation.scores = { faithfulness, relevance, contextPrecision, ... }
// Alert when faithfulness drops below threshold in production

Enterprise service with guardrails

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

const safePipeline = new GuardrailsPipeline(createRagPipeline({ ... }), {
  preRetrieval:  { enableInjectionDetection: true },
  retrieval:     { minRelevanceScore: 0.6 },
  postGeneration:{ enablePIIDetection: true, enableGroundednessCheck: true },
});

Architecture

Ingestion:  Documents → Chunking → Embedder → Vector Store

Query:      User Query
              ↓
            Guardrails      → prompt injection, topic filtering
              ↓
            Query Planner   → decomposes complex queries
              ↓
            Hybrid Retriever → vector + BM25 with Reciprocal Rank Fusion
              ↓
            Reranker        → BM25 / embedding / cascade
              ↓
            LLM             → generates answer from context
              ↓
            Citation Tracker → maps sentences to sources
              ↓
            Evaluator       → scores faithfulness & groundedness
              ↓
            Response { answer, citations, evaluation }

Each stage is optional, pluggable, and observable.

Capabilities

Opt in only to what you need:

| Capability | What you get | | -------------- | ------------------------------------------------------------------------ | | Chunking | 5 strategies: sentence, fixed-size, recursive, semantic, structure-aware | | Retrieval | Hybrid vector + BM25 with Reciprocal Rank Fusion | | Reranking | LLM, BM25 scoring, embedding similarity, or cascade | | Evaluation | Faithfulness, relevance, context precision/recall, groundedness | | Citation | Per-sentence source attribution, hallucination detection | | Agentic | Query planning, iterative retrieval, self-critique | | Guardrails | Injection detection, PII filtering, ACL-aware access control | | GraphRAG | Knowledge graph construction with entity extraction | | Streaming | SSE and WebSocket adapters with backpressure control | | Cost | Token tracking, budget enforcement, provider pricing | | Debugging | Execution tracing, bottleneck detection | | MCP | Expose pipelines as Model Context Protocol tools | | Enterprise | Multi-tenancy, SSO (SAML/OAuth2/AD/OIDC), audit logs |

See full documentation for complete API reference.

Provider Connectors

Built-in connectors for popular providers — or implement the contract for your own:

import {
  OpenAIConnector, // GPT-4, text-embedding-3
  AnthropicConnector, // Claude 3 Opus, Sonnet, Haiku
  CohereConnector, // Embed + Rerank
  OllamaConnector, // Llama 3, Mistral (local, offline)
  LocalEmbedder, // TF-IDF (offline, no API)
  MemoryRetriever, // In-memory cosine similarity
} from "@devilsdev/rag-pipeline-utils";

Documentation

Roadmap

Current (v2.4): chunking, citation, evaluation, agentic RAG, hybrid retrieval, 3-layer guardrails, GraphRAG, streaming, cost management, MCP integration, 7 provider connectors.

Next (v3.0): intelligent caching, native Rust bindings, Kubernetes operator, edge deployment.

Vote on features in GitHub Discussions.

Community

License

MIT — see LICENSE.