@devilsdev/rag-pipeline-utils 2.2.0 → 2.2.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.
package/README.md CHANGED
@@ -1,918 +1,286 @@
1
- # @devilsdev/rag-pipeline-utils
1
+ # rag-pipeline-utils
2
+
3
+ **Modular toolkit for building production-ready RAG pipelines in Node.js**
2
4
 
3
5
  [![CI](https://github.com/DevilsDev/rag-pipeline-utils/actions/workflows/ci.yml/badge.svg)](https://github.com/DevilsDev/rag-pipeline-utils/actions)
4
- [![npm version](https://badge.fury.io/js/%40devilsdev%2Frag-pipeline-utils.svg)](https://badge.fury.io/js/%40devilsdev%2Frag-pipeline-utils)
6
+ [![npm version](https://badge.fury.io/js/%40devilsdev%2Frag-pipeline-utils.svg)](https://www.npmjs.com/package/@devilsdev/rag-pipeline-utils)
7
+ [![codecov](https://codecov.io/gh/DevilsDev/rag-pipeline-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/DevilsDev/rag-pipeline-utils)
8
+ [![License: GPL-3.0](https://img.shields.io/badge/License-GPL%203.0-blue.svg)](https://opensource.org/licenses/GPL-3.0)
5
9
  [![Node.js Version](https://img.shields.io/node/v/@devilsdev/rag-pipeline-utils.svg)](https://nodejs.org/)
6
- [![License](https://img.shields.io/npm/l/@devilsdev/rag-pipeline-utils.svg)](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/LICENSE)
7
10
  [![Downloads](https://img.shields.io/npm/dm/@devilsdev/rag-pipeline-utils.svg)](https://www.npmjs.com/package/@devilsdev/rag-pipeline-utils)
8
-
9
- Enterprise-grade toolkit for building Retrieval-Augmented Generation (RAG) pipelines in Node.js with modular plugin architecture, streaming support, and observability.
10
-
11
- ## 🎉 What's New in v2.2.0
12
-
13
- ### Major Improvements
14
-
15
- **✅ Fixed ESM Build (Critical)**
16
-
17
- - Implemented CJS→ESM interop pattern for proper module compatibility
18
- - All 15 exports now working correctly in both CommonJS and ES Modules
19
- - Verified compatibility with Node.js 18.x, 20.x, and 22.x
20
-
21
- **📦 50% Smaller Install Size**
22
-
23
- - Reduced from ~30MB to ~15MB by optimizing dependencies
24
- - Moved CLI-only tools to devDependencies
25
- - Zero production vulnerabilities (npm audit clean)
26
-
27
- **📝 Enhanced TypeScript Support**
28
-
29
- - Added 5 complete plugin contract interfaces:
30
- - `LoaderPlugin` - Document loading interface
31
- - `EmbedderPlugin` - Text embedding interface
32
- - `RetrieverPlugin` - Vector search interface
33
- - `LLMPlugin` - Language model interface
34
- - `RerankerPlugin` - Result reranking interface
35
- - Added 4 helper types: `Document`, `SearchResult`, `RetrieveOptions`, `LLMResponse`
36
- - 236 lines of comprehensive type definitions
37
- - Full IDE autocomplete and type checking support
38
-
39
- **🔧 Real-World Example**
40
-
41
- - Complete OpenAI + Pinecone integration example in `examples/openai-pinecone/`
42
- - Mock mode for testing without API keys
43
- - Production-ready error handling and cost estimation guidance
44
- - See [OpenAI + Pinecone Example](#openai--pinecone-example) below
45
-
46
- **📚 Documentation Enhancements**
47
-
48
- - Platform compatibility matrix (Linux, macOS, Windows, Docker)
49
- - Module system examples (CommonJS + ES Modules)
50
- - Docker usage examples
51
- - Troubleshooting guides
52
-
53
- ### Migration from v2.1.x
54
-
55
- **No breaking changes!** v2.2.0 is fully backward compatible. Simply update:
56
-
57
- ```bash
58
- npm install @devilsdev/rag-pipeline-utils@latest
59
- ```
60
-
61
- All existing code will continue to work without modifications.
11
+ [![GitHub Discussions](https://img.shields.io/github/discussions/DevilsDev/rag-pipeline-utils)](https://github.com/DevilsDev/rag-pipeline-utils/discussions)
62
12
 
63
13
  ---
64
14
 
65
- ## Installation
66
-
67
- ```bash
68
- npm install @devilsdev/rag-pipeline-utils
69
- ```
70
-
71
- **Requirements:** Node.js >= 18.0.0
15
+ ## Why This Exists
72
16
 
73
- ## Compatibility
17
+ Building Retrieval-Augmented Generation (RAG) systems is harder than it should be. Most solutions lock you into specific vendors, force opinionated architectures, or sacrifice observability for simplicity.
74
18
 
75
- ### Platform Support
19
+ **rag-pipeline-utils** takes a different approach: it provides the building blocks—loaders, embedders, retrievers, LLM connectors, and rerankers—that you compose into pipelines that fit your needs. Every component follows clear contracts. Every integration is optional. Every decision is yours.
76
20
 
77
- | Platform | Status | Notes |
78
- | ----------- | ------------------ | ------------------------------------------------------------- |
79
- | **Linux** | ✅ Fully Supported | Tested on Ubuntu 20.04+, Debian 11+, RHEL 8+ |
80
- | **macOS** | ✅ Fully Supported | Tested on macOS 12+ (Intel & Apple Silicon) |
81
- | **Windows** | ✅ Fully Supported | Tested on Windows 10/11, WSL2 recommended for best experience |
82
- | **Docker** | ✅ Fully Supported | Alpine & Debian-based images available |
21
+ We built this toolkit because we believe infrastructure should be:
83
22
 
84
- ### Module Systems
23
+ - **Modular** – swap any component without rewriting your pipeline
24
+ - **Observable** – metrics, tracing, and audit logs built in from day one
25
+ - **Secure** – enterprise-grade defaults, validated inputs, safe JWT handling
26
+ - **Open** – no vendor lock-in, no proprietary APIs, just JavaScript
85
27
 
86
- This package supports both CommonJS and ES Modules:
28
+ Whether you're prototyping a document Q&A system or scaling a production knowledge base, this toolkit grows with you.
87
29
 
88
- **CommonJS (require)**
89
-
90
- ```javascript
91
- const {
92
- createRagPipeline,
93
- DAGEngine,
94
- } = require("@devilsdev/rag-pipeline-utils");
95
-
96
- const pipeline = createRagPipeline({
97
- /* config */
98
- });
99
- const dag = new DAGEngine();
100
- ```
101
-
102
- **ES Modules (import)**
103
-
104
- ```javascript
105
- import { createRagPipeline, DAGEngine } from "@devilsdev/rag-pipeline-utils";
106
-
107
- const pipeline = createRagPipeline({
108
- /* config */
109
- });
110
- const dag = new DAGEngine();
111
- ```
112
-
113
- ### TypeScript Support
114
-
115
- **New in v2.2.0:** Complete plugin contract interfaces with 236 lines of type definitions:
116
-
117
- ```typescript
118
- import {
119
- createRagPipeline,
120
- DAGEngine,
121
- RagPipelineConfig,
122
- // Plugin contract interfaces (NEW in v2.2.0)
123
- LoaderPlugin,
124
- EmbedderPlugin,
125
- RetrieverPlugin,
126
- LLMPlugin,
127
- RerankerPlugin,
128
- // Helper types (NEW in v2.2.0)
129
- Document,
130
- SearchResult,
131
- RetrieveOptions,
132
- LLMResponse,
133
- } from "@devilsdev/rag-pipeline-utils";
134
-
135
- // Type-safe plugin implementation
136
- class MyLoader implements LoaderPlugin {
137
- async load(source: string, options?: any): Promise<Document[]> {
138
- // Your implementation with full type checking
139
- return [
140
- {
141
- id: "doc-1",
142
- content: "Document content",
143
- metadata: { source },
144
- },
145
- ];
146
- }
147
- }
148
-
149
- const config: RagPipelineConfig = {
150
- loader: new MyLoader(),
151
- embedder: "my-embedder",
152
- };
153
-
154
- const pipeline = createRagPipeline(config);
155
- ```
156
-
157
- ### Package Size & Dependencies
158
-
159
- - **Package size**: 244KB (gzipped), 1.1MB (unpacked)
160
- - **Runtime dependencies**: Only 11 production dependencies
161
- - **Total install size**: ~15MB (including dependencies) - **50% smaller than v2.1.x**
162
- - **Tree-shakeable**: ES module exports support tree-shaking
163
- - **Zero vulnerabilities**: npm audit clean (production dependencies)
164
-
165
- ### Docker Usage
166
-
167
- **Basic Docker setup:**
168
-
169
- ```dockerfile
170
- FROM node:18-alpine
171
-
172
- WORKDIR /app
173
- COPY package*.json ./
174
- RUN npm ci --production
175
- COPY . .
176
-
177
- CMD ["node", "index.js"]
178
- ```
179
-
180
- **Docker Compose example:**
181
-
182
- ```yaml
183
- version: "3.8"
184
- services:
185
- rag-pipeline:
186
- image: node:18-alpine
187
- working_dir: /app
188
- volumes:
189
- - ./:/app
190
- environment:
191
- - NODE_ENV=production
192
- command: npm start
193
- ```
30
+ ---
194
31
 
195
32
  ## Quick Start
196
33
 
197
- ### Basic Pipeline Setup
34
+ Here's a complete RAG pipeline in 15 lines:
198
35
 
199
36
  ```javascript
200
37
  const { createRagPipeline } = require("@devilsdev/rag-pipeline-utils");
201
38
 
202
- // Create pipeline with your plugin implementations
39
+ // Implement your plugins (or use existing ones)
203
40
  const pipeline = createRagPipeline({
204
- loader: yourLoaderPlugin,
205
- embedder: yourEmbedderPlugin,
206
- retriever: yourRetrieverPlugin,
207
- llm: yourLLMPlugin,
41
+ loader: new MyPDFLoader(),
42
+ embedder: new MyOpenAIEmbedder({ apiKey: process.env.OPENAI_API_KEY }),
43
+ retriever: new MyVectorDBRetriever({ url: "http://localhost:8000" }),
44
+ llm: new MyLLMConnector({ model: "gpt-4" }),
208
45
  });
209
46
 
210
- // Use the pipeline
211
- await pipeline.ingest("./document.pdf");
212
- const result = await pipeline.query("What is this document about?");
213
- console.log(result);
214
- ```
47
+ // Ingest documents
48
+ await pipeline.ingest("./company-docs.pdf");
215
49
 
216
- ### Using Configuration File
217
-
218
- Create `.ragrc.json`:
219
-
220
- ```json
221
- {
222
- "loader": {
223
- "pdf": "your-pdf-loader-plugin"
224
- },
225
- "embedder": {
226
- "default": "your-embedder-plugin"
227
- },
228
- "retriever": {
229
- "default": "your-vector-db-plugin"
230
- },
231
- "llm": {
232
- "default": "your-llm-plugin"
233
- }
234
- }
50
+ // Query with natural language
51
+ const answer = await pipeline.query("What is the vacation policy?");
52
+ console.log(answer.text);
53
+ // Output: "Based on the company handbook, employees receive 20 days of vacation per year..."
235
54
  ```
236
55
 
237
- Load and use configuration:
56
+ **Requirements:** Node.js >= 18.0.0
238
57
 
239
- ```javascript
240
- const {
241
- loadConfig,
242
- createRagPipeline,
243
- } = require("@devilsdev/rag-pipeline-utils");
58
+ Install with:
244
59
 
245
- const config = await loadConfig(".ragrc.json");
246
- const pipeline = createRagPipeline(config);
60
+ ```bash
61
+ npm install @devilsdev/rag-pipeline-utils
247
62
  ```
248
63
 
249
- ## Core API
250
-
251
- ### Exported Modules
252
-
253
- ```javascript
254
- const {
255
- // Core pipeline
256
- createRagPipeline,
257
-
258
- // Configuration
259
- loadConfig,
260
- validateRagrc,
261
- normalizeConfig,
262
-
263
- // Plugin system
264
- pluginRegistry,
265
-
266
- // DAG workflow engine
267
- DAGEngine,
268
-
269
- // Observability
270
- eventLogger,
271
- metrics,
64
+ ---
272
65
 
273
- // Performance
274
- ParallelProcessor,
66
+ ## How It Works
275
67
 
276
- // AI/ML
277
- MultiModalProcessor,
278
- AdaptiveRetrievalEngine,
68
+ **rag-pipeline-utils** orchestrates data through a clear, predictable flow:
279
69
 
280
- // Enterprise
281
- AuditLogger,
282
- DataGovernance,
70
+ ```mermaid
71
+ graph LR
72
+ A[Documents] --> B[Loader]
73
+ B --> C[Embedder]
74
+ C --> D[Vector Store]
75
+ D --> E[Retriever]
76
+ F[User Query] --> C
77
+ F --> E
78
+ E --> G[Reranker]
79
+ G --> H[LLM]
80
+ H --> I[Response]
283
81
 
284
- // Utilities
285
- logger,
286
- } = require("@devilsdev/rag-pipeline-utils");
82
+ style B fill:#e1f5e1
83
+ style C fill:#e1f5e1
84
+ style E fill:#e1f5e1
85
+ style G fill:#fff4e1
86
+ style H fill:#e1f5e1
87
+ style I fill:#e3f2fd
287
88
  ```
288
89
 
289
- ### createRagPipeline(config)
290
-
291
- Creates a RAG pipeline instance.
292
-
293
- **Parameters:**
294
-
295
- - `config.loader` - Document loader plugin
296
- - `config.embedder` - Text embedding plugin
297
- - `config.retriever` - Vector storage and retrieval plugin
298
- - `config.llm` - Language model plugin
299
- - `config.reranker` (optional) - Result reranking plugin
300
-
301
- **Returns:** Pipeline instance with `ingest()` and `query()` methods
90
+ 1. **Loader** – Parse documents (PDF, HTML, Markdown, etc.)
91
+ 2. **Embedder** – Convert text to vector embeddings
92
+ 3. **Vector Store** – Index and persist embeddings
93
+ 4. **Retriever** – Find semantically similar content
94
+ 5. **Reranker** (optional) – Refine retrieval results
95
+ 6. **LLM** – Generate contextual responses
302
96
 
303
- ### Configuration Management
97
+ Every component is replaceable. Every step is observable.
304
98
 
305
- ```javascript
306
- // Load configuration from file
307
- const config = await loadConfig(".ragrc.json");
308
-
309
- // Validate configuration
310
- const isValid = validateRagrc(config);
311
-
312
- // Normalize configuration
313
- const normalized = normalizeConfig(config);
314
- ```
99
+ ---
315
100
 
316
- ### Plugin Registry
101
+ ## Features
317
102
 
318
- ```javascript
319
- const { pluginRegistry } = require("@devilsdev/rag-pipeline-utils");
103
+ ### Modular Plugin Architecture
320
104
 
321
- // Register a plugin
322
- pluginRegistry.register("my-plugin", MyPluginClass);
105
+ Swap any component without rewriting your pipeline. Use OpenAI embeddings with Pinecone storage, or mix Hugging Face models with PostgreSQL—your choice.
323
106
 
324
- // Get a plugin
325
- const Plugin = pluginRegistry.get("my-plugin");
107
+ ### Enterprise Observability
326
108
 
327
- // List all plugins
328
- const plugins = pluginRegistry.list();
329
-
330
- // Check if plugin exists
331
- const exists = pluginRegistry.has("my-plugin");
332
- ```
109
+ Built-in structured logging, Prometheus metrics, OpenTelemetry tracing, and audit logs for compliance-grade transparency.
333
110
 
334
111
  ### DAG Workflow Engine
335
112
 
336
- Build complex multi-step workflows:
113
+ Chain complex multi-step operations with retry logic, parallel execution, and graceful error handling. Perfect for batch ingestion or multi-stage transformations.
337
114
 
338
- ```javascript
339
- const { DAGEngine } = require("@devilsdev/rag-pipeline-utils");
340
-
341
- const dag = new DAGEngine({
342
- nodes: [
343
- {
344
- id: "load",
345
- type: "loader",
346
- config: {
347
- /* loader config */
348
- },
349
- },
350
- {
351
- id: "embed",
352
- type: "embedder",
353
- dependencies: ["load"],
354
- config: {
355
- /* embedder config */
356
- },
357
- },
358
- {
359
- id: "store",
360
- type: "retriever",
361
- dependencies: ["embed"],
362
- config: {
363
- /* retriever config */
364
- },
365
- },
366
- ],
367
- });
115
+ ### Type-Safe Contracts
368
116
 
369
- await dag.execute();
370
- ```
117
+ Complete TypeScript interfaces for all plugin types. Full IDE autocomplete and compile-time validation.
371
118
 
372
- ### Observability
119
+ ### Production-Ready Security
373
120
 
374
- ```javascript
375
- const { eventLogger, metrics } = require("@devilsdev/rag-pipeline-utils");
121
+ Secure defaults everywhere: validated JSON parsing, JWT algorithm whitelisting, automatic secret redaction in logs, and dependency scanning.
376
122
 
377
- // Configure event logging
378
- eventLogger.configure({
379
- level: "info",
380
- format: "json",
381
- });
123
+ ### Streaming & Batching
382
124
 
383
- // Log events
384
- eventLogger.log("info", "Pipeline started", { pipelineId: "abc123" });
125
+ Stream LLM responses in real-time. Batch embed thousands of documents efficiently with parallel processing and backpressure control.
385
126
 
386
- // Access metrics
387
- const pipelineMetrics = metrics.getMetrics();
388
- console.log(pipelineMetrics);
389
- ```
127
+ ### Framework Agnostic
390
128
 
391
- ### Parallel Processing
129
+ Works with Express, Fastify, Next.js, or any Node.js runtime. Deploy to AWS Lambda, Vercel, Docker, or bare metal.
392
130
 
393
- ```javascript
394
- const { ParallelProcessor } = require("@devilsdev/rag-pipeline-utils");
131
+ ---
395
132
 
396
- const processor = new ParallelProcessor({
397
- maxConcurrency: 5,
398
- });
133
+ ## Join the Community
399
134
 
400
- await processor.process(items, async (item) => {
401
- // Process each item
402
- return processItem(item);
403
- });
404
- ```
135
+ We're building this together.
405
136
 
406
- ## Plugin Development
137
+ Whether you're implementing a new retriever, writing documentation, reporting bugs, or sharing ideas—every contribution makes this toolkit better for everyone.
407
138
 
408
- This package provides a plugin-based architecture. You need to implement plugins for your specific use case.
139
+ **Getting Started:**
409
140
 
410
- ### Plugin Contracts
141
+ - 💬 [GitHub Discussions](https://github.com/DevilsDev/rag-pipeline-utils/discussions) – Ask questions, share use cases, propose features
142
+ - 🐛 [Issue Tracker](https://github.com/DevilsDev/rag-pipeline-utils/issues) – Report bugs or request features
143
+ - 🤝 [Contributing Guide](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/docs/CONTRIBUTING.md) – Learn how to submit pull requests
144
+ - 📖 [Code of Conduct](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/CODE_OF_CONDUCT.md) – Our community standards
411
145
 
412
- **New in v2.2.0:** TypeScript interfaces for all plugin contracts. See [TypeScript Support](#typescript-support) for full type definitions.
146
+ **Good First Issues:** Look for issues tagged `good first issue` to find beginner-friendly contributions.
413
147
 
414
- #### Loader Plugin
148
+ **Office Hours:** Join our monthly community calls to discuss roadmap priorities and architectural decisions.
415
149
 
416
- ```javascript
417
- /**
418
- * Loader plugin interface (NEW TypeScript interface in v2.2.0)
419
- * Implements: LoaderPlugin
420
- */
421
- class MyLoader {
422
- async load(source, options) {
423
- // Load and parse document
424
- // Return array of Document objects
425
- return [
426
- {
427
- id: "doc-1",
428
- content: "Document text...",
429
- metadata: { page: 1, source },
430
- // embedding: optional pre-computed embedding
431
- },
432
- ];
433
- }
434
- }
435
- ```
150
+ ---
436
151
 
437
- #### Embedder Plugin
152
+ ## Security and Quality
438
153
 
439
- ```javascript
440
- /**
441
- * Embedder plugin interface (NEW TypeScript interface in v2.2.0)
442
- * Implements: EmbedderPlugin
443
- */
444
- class MyEmbedder {
445
- async embed(text, options) {
446
- // Generate embedding for a single text string
447
- // Return: Promise<number[]> - embedding vector
448
- return [0.1, 0.2, 0.3 /* ... 1536 dimensions for OpenAI */];
449
- }
450
-
451
- // Optional batch embedding method
452
- async embedBatch(texts) {
453
- // Generate embeddings for multiple texts
454
- return texts.map((text) => this.embed(text));
455
- }
456
- }
457
- ```
154
+ Security isn't optional. This toolkit is built with defense in depth:
458
155
 
459
- #### Retriever Plugin
156
+ - **Validated Inputs** – All JSON parsed through schema validation (AJV)
157
+ - **Secure Logging** – Automatic redaction of 36 sensitive field patterns (API keys, JWTs, tokens)
158
+ - **JWT Best Practices** – Algorithm whitelisting, issuer/audience validation, expiration enforcement
159
+ - **Dependency Scanning** – Weekly Dependabot updates, CI blocks on critical vulnerabilities
160
+ - **Audit Trail** – Immutable compliance-grade logs for all security-sensitive operations
161
+ - **Plugin Sandboxing** – Third-party plugins run with declared permissions and resource limits
162
+ - **Supply Chain Security** – All GitHub Actions pinned to commit SHAs, SBOM generation available
460
163
 
461
- ```javascript
462
- /**
463
- * Retriever plugin interface (NEW TypeScript interface in v2.2.0)
464
- * Implements: RetrieverPlugin
465
- */
466
- class MyRetriever {
467
- async retrieve(query, options) {
468
- // query can be:
469
- // - string: search by text
470
- // - { embedding: number[] }: search by vector
471
- const { topK = 5, minScore = 0.7, filter } = options || {};
472
-
473
- // Search for similar vectors
474
- // Return: Promise<SearchResult[]>
475
- return [
476
- {
477
- id: "result-1",
478
- score: 0.95,
479
- document: {
480
- id: "doc-1",
481
- content: "Document text...",
482
- metadata: { source: "file.pdf" },
483
- },
484
- metadata: {
485
- /* additional search metadata */
486
- },
487
- },
488
- ];
489
- }
490
- }
491
- ```
164
+ **Zero Production Vulnerabilities:** `npm audit --production` returns clean on every release.
492
165
 
493
- #### LLM Plugin
166
+ **Test Coverage:** 845+ tests across 61 suites, with 100% coverage on critical paths.
494
167
 
495
- ```javascript
496
- /**
497
- * LLM plugin interface (NEW TypeScript interface in v2.2.0)
498
- * Implements: LLMPlugin
499
- */
500
- class MyLLM {
501
- async generate(prompt, options) {
502
- // Generate text from prompt
503
- // Return: Promise<LLMResponse>
504
- return {
505
- text: "Generated response...",
506
- usage: {
507
- promptTokens: 100,
508
- completionTokens: 50,
509
- totalTokens: 150,
510
- },
511
- metadata: {
512
- model: "gpt-4",
513
- finishReason: "stop",
514
- },
515
- };
516
- }
517
-
518
- // Optional streaming support
519
- async *stream(prompt, options) {
520
- // Stream response chunks
521
- yield "Generated ";
522
- yield "response ";
523
- yield "chunks...";
524
- }
525
- }
526
- ```
168
+ **Supported Node Versions:** 18.x, 20.x, 22.x (tested in CI)
527
169
 
528
- #### Reranker Plugin (Optional)
170
+ ---
529
171
 
530
- ```javascript
531
- /**
532
- * Reranker plugin interface (NEW TypeScript interface in v2.2.0)
533
- * Implements: RerankerPlugin
534
- */
535
- class MyReranker {
536
- async rerank(results, query, options) {
537
- // Rerank search results based on relevance to query
538
- // Return: Promise<SearchResult[]> - reranked results
539
- return results
540
- .map((result) => ({
541
- ...result,
542
- score: calculateRelevanceScore(query, result),
543
- }))
544
- .sort((a, b) => b.score - a.score);
545
- }
546
- }
547
- ```
172
+ ## Installation & Development
548
173
 
549
- ## Environment Configuration
174
+ ### Install
550
175
 
551
176
  ```bash
552
- # Example environment variables for your plugins
553
- OPENAI_API_KEY=your_api_key
554
- PINECONE_API_KEY=your_api_key
555
- PINECONE_ENVIRONMENT=us-east-1
556
- CHROMA_URL=http://localhost:8000
557
-
558
- # Performance settings
559
- RAG_MAX_CONCURRENCY=5
560
- RAG_BATCH_SIZE=10
561
- ```
562
-
563
- ## Advanced Features
564
-
565
- ### Multi-Modal Processing
566
-
567
- ```javascript
568
- const { MultiModalProcessor } = require("@devilsdev/rag-pipeline-utils");
569
-
570
- const processor = new MultiModalProcessor({
571
- // Configuration for processing text, images, audio, etc.
572
- });
573
-
574
- await processor.process(multiModalData);
575
- ```
576
-
577
- ### Adaptive Retrieval
578
-
579
- ```javascript
580
- const { AdaptiveRetrievalEngine } = require("@devilsdev/rag-pipeline-utils");
581
-
582
- const retriever = new AdaptiveRetrievalEngine({
583
- // Configuration for adaptive retrieval strategies
584
- });
585
-
586
- const results = await retriever.retrieve(query, context);
587
- ```
588
-
589
- ### Enterprise Audit Logging
590
-
591
- ```javascript
592
- const { AuditLogger } = require("@devilsdev/rag-pipeline-utils");
593
-
594
- const auditLogger = new AuditLogger({
595
- destination: "./audit-logs",
596
- });
597
-
598
- auditLogger.log("query", {
599
- user: "user@example.com",
600
- query: "sensitive query",
601
- timestamp: new Date(),
602
- });
603
- ```
604
-
605
- ### Data Governance
606
-
607
- ```javascript
608
- const { DataGovernance } = require("@devilsdev/rag-pipeline-utils");
609
-
610
- const governance = new DataGovernance({
611
- policies: {
612
- retention: "90d",
613
- encryption: true,
614
- },
615
- });
616
-
617
- await governance.enforce(data);
177
+ npm install @devilsdev/rag-pipeline-utils
618
178
  ```
619
179
 
620
- ## CLI Usage
621
-
622
- The package includes a CLI tool for pipeline operations:
180
+ ### Development Setup
623
181
 
624
182
  ```bash
625
- # Initialize configuration
626
- npx rag-pipeline init
627
-
628
- # Run pipeline operations (requires plugin implementation)
629
- npx rag-pipeline ingest ./documents
630
- npx rag-pipeline query "Your question"
631
-
632
- # Run system diagnostics
633
- npx rag-pipeline doctor
634
- ```
635
-
636
- ## Error Handling
637
-
638
- ```javascript
639
- try {
640
- const result = await pipeline.query("What is AI?");
641
- } catch (error) {
642
- if (error.code === "PLUGIN_NOT_FOUND") {
643
- console.error("Required plugin not found:", error.message);
644
- } else if (error.code === "INVALID_CONFIG") {
645
- console.error("Invalid configuration:", error.message);
646
- } else {
647
- console.error("Pipeline error:", error.message);
648
- }
649
- }
650
- ```
183
+ # Clone the repository
184
+ git clone https://github.com/DevilsDev/rag-pipeline-utils.git
185
+ cd rag-pipeline-utils
651
186
 
652
- ## Use Cases
653
-
654
- ### Document Q&A System
655
-
656
- ```javascript
657
- // Implement your plugins
658
- const loader = new PDFLoaderPlugin();
659
- const embedder = new OpenAIEmbedderPlugin({
660
- apiKey: process.env.OPENAI_API_KEY,
661
- });
662
- const retriever = new ChromaRetrieverPlugin({ url: "http://localhost:8000" });
663
- const llm = new OpenAILLMPlugin({ model: "gpt-4" });
664
-
665
- // Create pipeline
666
- const pipeline = createRagPipeline({
667
- loader,
668
- embedder,
669
- retriever,
670
- llm,
671
- });
672
-
673
- // Ingest documents
674
- await pipeline.ingest("./company-handbook.pdf");
675
-
676
- // Query
677
- const answer = await pipeline.query("What is the vacation policy?");
678
- console.log(answer);
679
- ```
680
-
681
- ### Knowledge Base Search
682
-
683
- ```javascript
684
- // Use your custom database retriever
685
- class PostgresRetriever {
686
- constructor(connectionString) {
687
- this.db = new PostgresClient(connectionString);
688
- }
689
-
690
- async retrieve(queryVector, options) {
691
- const results = await this.db.query(
692
- "SELECT content, metadata, vector <-> $1 as score FROM embeddings ORDER BY score LIMIT $2",
693
- [queryVector, options.topK],
694
- );
695
- return results.rows;
696
- }
697
- }
698
-
699
- const pipeline = createRagPipeline({
700
- loader: yourLoader,
701
- embedder: yourEmbedder,
702
- retriever: new PostgresRetriever("postgresql://localhost/kb"),
703
- llm: yourLLM,
704
- });
705
- ```
706
-
707
- ## Performance Tips
708
-
709
- ### Batch Processing
710
-
711
- ```javascript
712
- const { ParallelProcessor } = require("@devilsdev/rag-pipeline-utils");
713
-
714
- const processor = new ParallelProcessor({
715
- maxConcurrency: 5,
716
- batchSize: 10,
717
- });
718
-
719
- // Process documents in parallel
720
- await processor.process(documents, async (doc) => {
721
- return await pipeline.ingest(doc);
722
- });
723
- ```
187
+ # Install dependencies
188
+ npm install
724
189
 
725
- ### Logging and Monitoring
190
+ # Run tests
191
+ npm test
726
192
 
727
- ```javascript
728
- const { logger, metrics } = require("@devilsdev/rag-pipeline-utils");
193
+ # Run linter
194
+ npm run lint
729
195
 
730
- // Set log level
731
- logger.setLevel("debug");
196
+ # Build distribution
197
+ npm run build
732
198
 
733
- // Monitor performance
734
- const stats = metrics.getMetrics();
735
- console.log("Total queries:", stats.queries?.total || 0);
736
- console.log("Average latency:", stats.queries?.avgLatency || 0);
199
+ # Run development tools
200
+ npm run dev
737
201
  ```
738
202
 
739
- ## Common Integration Examples
740
-
741
- ### OpenAI + Pinecone Example
742
-
743
- **New in v2.2.0:** Complete working example with OpenAI embeddings and Pinecone vector database.
744
-
745
- See the full example in [`examples/openai-pinecone/`](examples/openai-pinecone/) with:
746
-
747
- - ✅ Complete plugin implementations
748
- - ✅ Mock mode (no API keys required for testing)
749
- - ✅ Real OpenAI integration
750
- - ✅ Real Pinecone integration
751
- - ✅ Error handling and cost estimation
752
- - ✅ Comprehensive documentation
753
-
754
- **Quick start:**
203
+ ### Common Commands
755
204
 
756
205
  ```bash
757
- cd examples/openai-pinecone
758
- npm install
759
-
760
- # Test with mock mode (no API keys needed)
761
- USE_MOCK_MODE=true npm start
762
-
763
- # Run with real APIs (requires API keys in .env)
764
- npm start
206
+ npm test # Run test suite
207
+ npm run test:watch # Watch mode for TDD
208
+ npm run lint # Check code style
209
+ npm run lint:fix # Auto-fix linting issues
210
+ npm run security:audit # Scan dependencies
211
+ npm run docs:api # Generate API documentation
212
+ npm run benchmark # Performance benchmarks
765
213
  ```
766
214
 
767
- ### With OpenAI
215
+ ---
768
216
 
769
- You need to implement OpenAI plugin wrappers:
217
+ ## Roadmap
770
218
 
771
- ```javascript
772
- class OpenAIEmbedder {
773
- constructor({ apiKey, model = "text-embedding-ada-002" }) {
774
- this.client = new OpenAI({ apiKey });
775
- this.model = model;
776
- }
777
-
778
- async embed(texts) {
779
- const response = await this.client.embeddings.create({
780
- model: this.model,
781
- input: texts,
782
- });
783
- return response.data.map((d) => d.embedding);
784
- }
785
- }
786
-
787
- class OpenAILLM {
788
- constructor({ apiKey, model = "gpt-4" }) {
789
- this.client = new OpenAI({ apiKey });
790
- this.model = model;
791
- }
792
-
793
- async generate(prompt) {
794
- const response = await this.client.chat.completions.create({
795
- model: this.model,
796
- messages: [{ role: "user", content: prompt }],
797
- });
798
- return { text: response.choices[0].message.content };
799
- }
800
- }
801
- ```
219
+ ### v2.3.0 (Q2 2025)
802
220
 
803
- ### With ChromaDB
221
+ - **Enhanced CLI** – Interactive wizard for pipeline setup, validation commands, and migration tools
222
+ - **Plugin Marketplace** – Curated registry of community-contributed plugins with ratings and verification
223
+ - **Streaming Embeddings** – Real-time embedding generation with backpressure control
224
+ - **Multi-Tenant Support** – Workspace isolation, resource quotas, and tenant-specific configurations
804
225
 
805
- ```javascript
806
- class ChromaRetriever {
807
- constructor({ url, collection }) {
808
- this.client = new ChromaClient({ path: url });
809
- this.collectionName = collection;
810
- }
811
-
812
- async store(vectors, metadata) {
813
- const collection = await this.client.getOrCreateCollection({
814
- name: this.collectionName,
815
- });
816
-
817
- await collection.add({
818
- embeddings: vectors,
819
- metadatas: metadata,
820
- ids: metadata.map((_, i) => `doc_${i}`),
821
- });
822
- }
823
-
824
- async retrieve(queryVector, options) {
825
- const collection = await this.client.getCollection({
826
- name: this.collectionName,
827
- });
828
-
829
- const results = await collection.query({
830
- queryEmbeddings: [queryVector],
831
- nResults: options.topK || 5,
832
- });
833
-
834
- return results.metadatas[0].map((meta, i) => ({
835
- content: results.documents[0][i],
836
- metadata: meta,
837
- score: 1 - results.distances[0][i],
838
- }));
839
- }
840
- }
841
- ```
226
+ ### v2.4.0 (Q3 2025)
842
227
 
843
- ## Troubleshooting
228
+ - **GraphRAG Support** – Native knowledge graph integration for entity-relationship retrieval
229
+ - **Federated Learning** – Privacy-preserving model training across distributed datasets
230
+ - **Advanced Reranking** – Cross-encoder models and learned ranking functions
231
+ - **Performance Dashboard** – Web UI for monitoring pipeline health and cost metrics
844
232
 
845
- ### Common Issues
233
+ ### Beyond
846
234
 
847
- **Error: Cannot find module**
235
+ - Native Rust bindings for performance-critical paths
236
+ - Kubernetes operator for production deployments
237
+ - Real-time collaboration features for team-based pipelines
848
238
 
849
- ```bash
850
- npm install @devilsdev/rag-pipeline-utils
851
- ```
852
-
853
- **Error: Plugin not registered**
854
-
855
- ```javascript
856
- // Make sure to register your plugins
857
- pluginRegistry.register("my-embedder", MyEmbedderClass);
858
- ```
239
+ **Vote on features:** Share your priorities in [GitHub Discussions](https://github.com/DevilsDev/rag-pipeline-utils/discussions/categories/roadmap).
859
240
 
860
- **Error: Invalid configuration**
861
-
862
- ```javascript
863
- // Validate your configuration
864
- const { validateRagrc } = require("@devilsdev/rag-pipeline-utils");
865
- const isValid = validateRagrc(config);
866
- if (!isValid) {
867
- console.error("Configuration is invalid");
868
- }
869
- ```
241
+ ---
870
242
 
871
- ### Debug Mode
243
+ ## Contributing
872
244
 
873
- ```javascript
874
- const { logger } = require("@devilsdev/rag-pipeline-utils");
245
+ We welcome contributions of all kinds:
875
246
 
876
- // Enable debug logging
877
- logger.setLevel("debug");
878
- ```
247
+ - **Code** – Fix bugs, add features, improve performance
248
+ - **Documentation** – Write guides, improve examples, clarify concepts
249
+ - **Testing** – Expand test coverage, add integration tests, report edge cases
250
+ - **Design** – Propose API improvements, suggest architectural patterns
251
+ - **Community** – Answer questions, review pull requests, mentor new contributors
879
252
 
880
- ## Examples
253
+ **Before You Start:**
881
254
 
882
- ### Real-World Integration Examples
255
+ 1. Read the [Contributing Guide](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/docs/CONTRIBUTING.md)
256
+ 2. Check existing [Issues](https://github.com/DevilsDev/rag-pipeline-utils/issues) and [Discussions](https://github.com/DevilsDev/rag-pipeline-utils/discussions)
257
+ 3. Open an issue to discuss major changes before coding
258
+ 4. Follow our [Code of Conduct](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/CODE_OF_CONDUCT.md)
883
259
 
884
- **[OpenAI + Pinecone Example](examples/openai-pinecone/)** (NEW in v2.2.0)
260
+ **Pull Request Checklist:**
885
261
 
886
- - Complete RAG pipeline implementation
887
- - OpenAI embeddings (text-embedding-3-small)
888
- - Pinecone vector database integration
889
- - Mock mode for testing without API keys
890
- - Production-ready with error handling
262
+ - [ ] Tests pass (`npm test`)
263
+ - [ ] Linter passes (`npm run lint`)
264
+ - [ ] Documentation updated
265
+ - [ ] Changelog entry added
266
+ - [ ] Type definitions updated (if applicable)
891
267
 
892
- **Basic Pipeline Example**
268
+ ---
893
269
 
894
- - See `examples/basic-pipeline/` for minimal setup
895
- - Simple in-memory implementation
896
- - Perfect for learning and prototyping
270
+ ## License
897
271
 
898
- ## Documentation
272
+ **GPL-3.0** – See [LICENSE](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/LICENSE) for full terms.
899
273
 
900
- - [GitHub Repository](https://github.com/DevilsDev/rag-pipeline-utils)
901
- - [Issue Tracker](https://github.com/DevilsDev/rag-pipeline-utils/issues)
902
- - [Discussions](https://github.com/DevilsDev/rag-pipeline-utils/discussions)
903
- - [OpenAI + Pinecone Example](examples/openai-pinecone/) (NEW)
904
- - [Release Notes](https://github.com/DevilsDev/rag-pipeline-utils/releases)
905
- - [CHANGELOG](CHANGELOG.md)
274
+ This is free software: you are free to change and redistribute it under the terms of the GNU General Public License version 3.
906
275
 
907
- ## Contributing
276
+ ---
908
277
 
909
- Contributions are welcome. Please see the [contribution guidelines](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/docs/CONTRIBUTING.md).
278
+ ## What's Next?
910
279
 
911
- ## License
280
+ ⭐ **Star this repository** if you find it useful—it helps others discover the project.
912
281
 
913
- GPL-3.0 - See [LICENSE](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/LICENSE) for details.
282
+ 📢 **Share your use case** in [Discussions](https://github.com/DevilsDev/rag-pipeline-utils/discussions/categories/show-and-tell) to inspire the community.
914
283
 
915
- ## Support
284
+ 🤝 **Contribute** your first pull request—check out issues tagged [good first issue](https://github.com/DevilsDev/rag-pipeline-utils/labels/good%20first%20issue).
916
285
 
917
- - Issues: https://github.com/DevilsDev/rag-pipeline-utils/issues
918
- - Discussions: https://github.com/DevilsDev/rag-pipeline-utils/discussions
286
+ Happy building. 🚀