Skip to main content

RAG Pipeline Utils

Enterprise-grade composable RAG pipelines with advanced AI capabilities

3
Core Primitives
2050+
Tests
MIT
License
Zero
Production Vulnerabilities

Modular Plugin Architecture

5 plugin types with JSON Schema contracts and 7 provider connectors (OpenAI, Anthropic, Cohere, Ollama, and more). Swap any component without rewriting your pipeline.

Smart Chunking & Retrieval

5 chunking strategies, hybrid vector + BM25 search, and reciprocal rank fusion for highly relevant context retrieval across large document sets.

RAG Evaluation

Faithfulness, relevance, context precision/recall, and groundedness metrics to measure and improve RAG pipeline quality.

Quick Start

Build a complete RAG pipeline in minutes. Install the package, configure your plugins, and start querying your documents with AI-powered retrieval.

npm install @devilsdev/rag-pipeline-utils

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 },
});

Three Paths, One Pipeline

Start with retrieval. Add evaluation when quality matters. Add guardrails when you ship. Each primitive is optional — pick what your team actually needs.

Document Q&A

Answer questions with citations

Return grounded answers where every sentence links back to the source chunk. Per-sentence citation tracking and groundedness scoring built in.

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

Assistants with faithfulness guarantees

Score every answer on faithfulness, relevance, context precision, and recall. Alert when quality drops below your production threshold.

const result = await pipeline.run({
  query: userQuestion,
  options: { evaluate: true },
});
// result.evaluation.scores
//   = { faithfulness, relevance, ... }
Evaluation harness docs
Enterprise service

Pipelines with production guardrails

Three-layer defense: prompt-injection detection pre-retrieval, relevance thresholds during retrieval, and PII + groundedness checks post-generation.

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

Production-Ready Features

Modular Plugin Architecture

5 plugin types with JSON Schema contracts and 7 provider connectors (OpenAI, Anthropic, Cohere, Ollama, and more).

Learn more →

Smart Chunking & Retrieval

5 chunking strategies, hybrid vector + BM25 search, and reciprocal rank fusion for highly relevant context retrieval.

Learn more →

RAG Evaluation

Faithfulness, relevance, context precision/recall, and groundedness metrics to measure and improve pipeline quality.

Learn more →

Citation & Grounding

Source attribution, hallucination detection, and groundedness scoring to ensure trustworthy AI-generated answers.

Learn more →

Agentic RAG & GraphRAG

Query planning, iterative retrieval, self-critique loops, and knowledge graph traversal for complex multi-hop questions.

Learn more →

3-Layer Guardrails

Prompt injection detection, ACL filtering, and PII detection to protect your pipeline at input, retrieval, and output stages.

Learn more →

Streaming & Connectors

SSE/WebSocket streaming plus built-in OpenAI, Anthropic, Cohere, and Ollama connectors for flexible deployment.

Learn more →

Cost & Debugging

Token tracking, budget enforcement, execution tracing, and bottleneck detection for full pipeline observability.

Learn more →

Enterprise Security

JWT replay protection, plugin sandboxing, audit logging, and multi-tenancy support for production deployments.

Learn more →

Ready to Build Production RAG Systems?

Join developers building enterprise-grade RAG pipelines with modular architecture, comprehensive security, and production observability.