@ragleap/rag (TypeScript)
version 0.2.0 · Node.js 22 or later · early
TypeScript RAG utilities for RagLeap, for Node.js 22 and later: typed building blocks for document ingestion, text chunking, embeddings, answer generation, vector search, PostgreSQL and pgvector, conversation memory, structured-output validation, caching, sanitization and observability hooks. It is an early port: parity with the Python ragleap-rag has not been checked.
npm install @ragleap/rag
Highlights
- Typed building blocks exported from one entry point, including an
IngestionService, aRagLeapclass and aTextChunker - Text sanitization and prompt-injection risk detection (
sanitize_textanddetect_injection_risk) - Query helpers (
reciprocal_rank_fusion,multi_query_variants,hyde_documentandcontextual_rewrite), aQueryEmbeddingCacheand token cost tracking - Optional reranking with
RerankerService: the Transformers.js runtime is optional (npm install @ragleap/rag @huggingface/transformers), the default model isXenova/ms-marco-MiniLM-L-6-v2, the first call may download model files, and scores are raw model scores (logits), not probabilities
Example from the README
import {
TextChunker,
sanitize_text,
detect_injection_risk,
} from "@ragleap/rag";
const text = sanitize_text("Example document text");
const chunker = new TextChunker();
const chunks = chunker.chunk_text(text);
console.log(chunks);
console.log(detect_injection_risk(text));
Copied from the package README. We have not run this snippet for this page.
Not verified
- Parity with the Python or Java ragleap-rag has not been checked: missing features and behavioural differences have not been audited, and no comparison against recordings of the real Python code has been done. Do not assume it behaves like them
- No mutation checks, and no live provider or database test was run by the author of the pull request that added the source (#1045)
- 0.2.0 was published by hand without provenance; later releases are meant to come from GitHub Actions. There is no tag or release for this folder yet, and no JavaScript job in CI yet
Tech stack
Node.js 22 or later, ES modules. One runtime dependency, pg; @huggingface/transformers is optional and only for the reranker. MIT licensed.
Testing
158 test() calls across 20 test files (run with node --test), counted directly from the main branch. The published 0.2.0 predates the source in the repo, so there is no release tag to count. The pull request that added the source reported 158 tests passing on a fresh install and build under Node 24, and a fresh build matching the compiled files of the published 0.2.0 (source maps not compared). See the per-file list.