@devilsdev/rag-pipeline-utils 1.0.1 โ 2.0.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/.codecov.yml +21 -0
- package/.github/workflows/ci.yml +18 -0
- package/.github/workflows/docs-deploy.yml +36 -0
- package/.github/workflows/publish-release-blog.yml +51 -0
- package/.husky/pre-commit +6 -0
- package/CHANGELOG.md +40 -0
- package/README.md +101 -72
- package/USE_CASES.md +134 -0
- package/__tests__/fixtures/.ragrc.json +8 -0
- package/__tests__/fixtures/invalid-ragrc.json +4 -0
- package/__tests__/fixtures/src/mocks/openai-embedder.js +16 -0
- package/__tests__/fixtures/src/mocks/openai-llm.js +9 -0
- package/__tests__/fixtures/src/mocks/pdf-loader.js +17 -0
- package/__tests__/fixtures/src/mocks/pinecone-retriever.js +26 -0
- package/__tests__/fixtures/valid-ragrc.json +16 -0
- package/__tests__/integration/cli/config-flow.test.js +84 -15
- package/__tests__/integration/config/load-config.test.js +45 -30
- package/__tests__/unit/config/validate-schema.test.js +121 -0
- package/__tests__/unit/reranker/llm-reranker.test.js +9 -33
- package/__tests__/unit/reranker/reranker.enriched.test.js +19 -0
- package/__tests__/unit/reranker/reranker.fallback.test.js +15 -0
- package/__tests__/unit/reranker/reranker.snapshot.test.js +9 -11
- package/__tests__/unit/reranker/reranker.structured-output.test.js +17 -0
- package/bin/cli.js +49 -155
- package/docs-site/blog/2021-08-26-welcome/index.md +0 -1
- package/docs-site/blog/2025-04-17-release-2.0.md +67 -0
- package/docs-site/blog/2025-04-18-release-2.0.0.md +21 -0
- package/docs-site/blog/authors.yml +5 -23
- package/docs-site/blog/tags.yml +9 -0
- package/docs-site/docs/USE_CASES.md +0 -0
- package/docs-site/docusaurus.config.js +13 -0
- package/docs-site/sidebars.js +21 -9
- package/package.json +25 -2
- package/plugin.config.json +14 -0
- package/scripts/banner-injector.js +89 -0
- package/scripts/ci-runner.js +51 -0
- package/scripts/repair-fixtures.js +30 -0
- package/scripts/setup.js +26 -2
- package/scripts/validate-changelog-version.js +48 -0
- package/scripts/verify-fixture-mocks.js +45 -0
- package/scripts/verify-fixtures.js +36 -0
- package/src/config/load-config.js +19 -21
- package/src/config/load-plugin-config.js +56 -0
- package/src/config/validate-plugin-schema.js +28 -0
- package/src/config/validate-schema.js +88 -30
- package/src/core/create-pipeline.js +40 -26
- package/src/core/plugin-contracts.js +21 -0
- package/src/core/plugin-registry.js +4 -17
- package/src/mocks/openai-embedder.js +30 -0
- package/src/mocks/openai-llm.js +18 -0
- package/src/mocks/pdf-loader.js +17 -0
- package/src/mocks/pinecone-retriever.js +25 -0
- package/src/reranker/llm-reranker.js +28 -43
- package/src/utils/ci/diagnostic-reporter.js +36 -0
- package/src/utils/validate-plugin-contract.js +36 -0
- package/.github/workflows/release.yml +0 -20
- package/docs-site/blog/2019-05-28-first-blog-post.md +0 -12
- package/docs-site/blog/2019-05-29-long-blog-post.md +0 -44
- package/docs-site/blog/2021-08-01-mdx-blog-post.mdx +0 -24
package/.codecov.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# .codecov.yml
|
|
2
|
+
|
|
3
|
+
codecov:
|
|
4
|
+
notify:
|
|
5
|
+
after_n_builds: 1
|
|
6
|
+
|
|
7
|
+
coverage:
|
|
8
|
+
status:
|
|
9
|
+
project:
|
|
10
|
+
default:
|
|
11
|
+
target: 90%
|
|
12
|
+
threshold: 5%
|
|
13
|
+
patch:
|
|
14
|
+
default:
|
|
15
|
+
target: 90%
|
|
16
|
+
threshold: 5%
|
|
17
|
+
|
|
18
|
+
comment:
|
|
19
|
+
layout: "reach, diff, flags, files"
|
|
20
|
+
behavior: default
|
|
21
|
+
require_changes: false
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -44,3 +44,21 @@ jobs:
|
|
|
44
44
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
45
45
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # ๐ critical for npm publi
|
|
46
46
|
run: npx semantic-release
|
|
47
|
+
|
|
48
|
+
- name: ๐งช Run Tests with Coverage
|
|
49
|
+
run: npm test
|
|
50
|
+
|
|
51
|
+
- name: Validate Fixtures
|
|
52
|
+
run: npm run validate-fixtures
|
|
53
|
+
|
|
54
|
+
- name: Lint code
|
|
55
|
+
run: npm run lint
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
- name: ๐ Upload coverage to Codecov
|
|
59
|
+
uses: codecov/codecov-action@v5
|
|
60
|
+
with:
|
|
61
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
62
|
+
slug: DevilsDev/rag-pipeline-utils
|
|
63
|
+
|
|
64
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Deploy Docusaurus to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- 'docs-site/**'
|
|
8
|
+
- 'blog/**'
|
|
9
|
+
- 'sidebars.js'
|
|
10
|
+
- 'docusaurus.config.js'
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
deploy:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: ๐ฅ Checkout
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: โ๏ธ Setup Node.js
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: 20
|
|
23
|
+
|
|
24
|
+
- name: ๐ฆ Install dependencies
|
|
25
|
+
run: npm ci
|
|
26
|
+
|
|
27
|
+
- name: ๐ ๏ธ Build static site
|
|
28
|
+
run: npm run build:docs
|
|
29
|
+
|
|
30
|
+
- name: ๐ Deploy to GitHub Pages
|
|
31
|
+
uses: peaceiris/actions-gh-pages@v4
|
|
32
|
+
with:
|
|
33
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
34
|
+
publish_dir: ./docs-site/build
|
|
35
|
+
|
|
36
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# .github/workflows/publish-release-blog.yml
|
|
2
|
+
# Version: 1.0.0
|
|
3
|
+
# Description: Auto-publish blog post from CHANGELOG or prepared .md after NPM release
|
|
4
|
+
# Author: Ali Kahwaji
|
|
5
|
+
|
|
6
|
+
name: โจ Publish Release Blog Post
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
release:
|
|
10
|
+
types: [published]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish-blog-post:
|
|
14
|
+
name: Generate & Commit Blog Post
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: โฌ๏ธ Checkout code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: ๐ง Set up Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: 20
|
|
25
|
+
|
|
26
|
+
- name: โ๏ธ Generate blog post
|
|
27
|
+
run: |
|
|
28
|
+
VERSION=${GITHUB_REF#refs/tags/}
|
|
29
|
+
DATE=$(date +'%Y-%m-%d')
|
|
30
|
+
FILE="docs-site/blog/${DATE}-release-${VERSION}.md"
|
|
31
|
+
|
|
32
|
+
echo "---" > $FILE
|
|
33
|
+
echo "slug: release-${VERSION}" >> $FILE
|
|
34
|
+
echo "title: โจ Version ${VERSION} Released" >> $FILE
|
|
35
|
+
echo "authors: [ali]" >> $FILE
|
|
36
|
+
echo "tags: [release, changelog]" >> $FILE
|
|
37
|
+
echo "---" >> $FILE
|
|
38
|
+
echo >> $FILE
|
|
39
|
+
|
|
40
|
+
echo "RAG Pipeline Utils v${VERSION} is now available on NPM!" >> $FILE
|
|
41
|
+
echo >> $FILE
|
|
42
|
+
echo "#### Highlights" >> $FILE
|
|
43
|
+
echo "- Automated blog generation on GitHub releases" >> $FILE
|
|
44
|
+
echo "- Version bump: ${VERSION}" >> $FILE
|
|
45
|
+
echo "- Ensure CHANGELOG.md is synced" >> $FILE
|
|
46
|
+
|
|
47
|
+
- name: ๐ Commit blog post
|
|
48
|
+
uses: stefanzweifel/git-auto-commit-action@v5
|
|
49
|
+
with:
|
|
50
|
+
commit_message: "docs(blog): add release post for ${{ github.ref_name }}"
|
|
51
|
+
file_pattern: "docs-site/blog/*.md"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.0.1](https://github.com/DevilsDev/rag-pipeline-utils/compare/v2.0.0...v2.0.1) (2025-04-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* add @docusaurus/preset-classic to enable CI builds ([ed5e771](https://github.com/DevilsDev/rag-pipeline-utils/commit/ed5e771f919face4693a6a7abfed4cf0fe1325ca))
|
|
9
|
+
|
|
10
|
+
## [2.0.0] - 2025-04-17 (2025-04-17)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **ci:** correct .ragrc.json plugin paths and CLI test cwd to resolve plugin loading in CI ([911c23b](https://github.com/DevilsDev/rag-pipeline-utils/commit/911c23b1d3ddb9e2d938b37f4422a5d81995e97f))
|
|
16
|
+
* **ci:** resolve plugin path error in .ragrc.json for GitHub Actions compatibility ([affc739](https://github.com/DevilsDev/rag-pipeline-utils/commit/affc739d5c4ff2070b1a1ca0ccf3f9137d6cee5a))
|
|
17
|
+
* **ci:** resolve plugin path failures in .ragrc.json during CLI integration tests ([04b977b](https://github.com/DevilsDev/rag-pipeline-utils/commit/04b977b3b745fa3d3ab47c84b2aeee3285896068))
|
|
18
|
+
* **cli:** correct path to load-plugin-config.js after moving to /src/config ([f743498](https://github.com/DevilsDev/rag-pipeline-utils/commit/f743498ec32e03151eda9ba7fe5886bda8da792f))
|
|
19
|
+
* **config:** use default export when importing plugin registry ([ef8dce1](https://github.com/DevilsDev/rag-pipeline-utils/commit/ef8dce12bfab62bc9faec764198b98c0c356472e))
|
|
20
|
+
* **test:** ensure .ragrc.json copied to project root for CLI fallback in CI ([31bd2b8](https://github.com/DevilsDev/rag-pipeline-utils/commit/31bd2b844279fb0404056d9929e5f28f9127eb12))
|
|
21
|
+
* **tests:** define __dirname manually for ESM compatibility in CLI integration test ([18b8dad](https://github.com/DevilsDev/rag-pipeline-utils/commit/18b8dadabb852243dda2b78de048c71106a759fc))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* **ci:** integrate full fixture validation, schema contracts, and CLI test flow ([2b57fe9](https://github.com/DevilsDev/rag-pipeline-utils/commit/2b57fe90e64a806815c1f66f5e2a745780270ce6))
|
|
27
|
+
* **cli:** dynamic plugin registration with config fallback and middleware injection ([cc24b7e](https://github.com/DevilsDev/rag-pipeline-utils/commit/cc24b7e74d0a2630eb1c6d2def69b370329dcc2b))
|
|
28
|
+
* **plugins:** enable dynamic plugin registration from JSON config ([d81d6d7](https://github.com/DevilsDev/rag-pipeline-utils/commit/d81d6d7d5f2d21b5a46b379b530c162ba9c30398))
|
|
29
|
+
* **testing:** integrate full fixture and validation setup for CLI + reranker ([ab96037](https://github.com/DevilsDev/rag-pipeline-utils/commit/ab9603765594e7718e2688b80797e1f5e8afe86f))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### BREAKING CHANGES
|
|
33
|
+
|
|
34
|
+
* **cli:** now requires named options for middleware injection; existing usage must be updated.
|
|
35
|
+
|
|
36
|
+
## [1.0.2] - 2025-04-15
|
|
37
|
+
### Fixed
|
|
38
|
+
- Corrected plugin path resolution in `.ragrc.json` fixture for CI compatibility.
|
|
39
|
+
- Resolved `ERR_MODULE_NOT_FOUND` during CLI integration tests in GitHub Actions.
|
|
40
|
+
- Ensured consistent module resolution across environments (Windows, Linux, CI).
|
|
41
|
+
|
|
42
|
+
|
|
3
43
|
## [1.0.1](https://github.com/DevilsDev/rag-pipeline-utils/compare/v1.0.0...v1.0.1) (2025-04-14)
|
|
4
44
|
|
|
5
45
|
|
package/README.md
CHANGED
|
@@ -1,117 +1,146 @@
|
|
|
1
1
|
# @DevilsDev/rag-pipeline-utils
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# RAG Pipeline Utils
|
|
6
|
+
|
|
7
|
+
> Modular utilities for building Retrieval-Augmented Generation (RAG) pipelines, with CI-verified plugin contracts and mockable interfaces.
|
|
8
|
+
|
|
3
9
|
[](https://github.com/DevilsDev/rag-pipeline-utils/actions)
|
|
4
10
|
[](https://codecov.io/gh/DevilsDev/rag-pipeline-utils)
|
|
5
11
|

|
|
12
|
+

|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
## Description
|
|
8
15
|
|
|
9
|
-
|
|
16
|
+
`@devilsdev/rag-pipeline-utils` provides a clean, extensible, and test-friendly foundation for constructing robust RAG pipelines using a plugin-based architecture. It enables developers to plug in their own document loaders, embedders, retrievers, and LLMs via configuration, and includes a CLI, mock contract verification, schema validation, and test harnesses to ensure production-readiness.
|
|
10
17
|
|
|
11
|
-
## Features
|
|
18
|
+
## Key Features
|
|
12
19
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
- โ
Reranker support and evaluation tooling
|
|
20
|
-
- โ
React dashboard for evaluation results
|
|
20
|
+
- **Plugin Contracts**: Runtime and CI verification of plugin interfaces (loader, embedder, retriever, llm).
|
|
21
|
+
- **CLI Support**: Easily run `ingest` and `query` commands using `.ragrc.json` configuration.
|
|
22
|
+
- **Test Fixtures**: Snapshot, fallback, and structured reranker validation.
|
|
23
|
+
- **Schema Enforcement**: `.ragrc.json` schema validation to catch config issues early.
|
|
24
|
+
- **Mock Repair Utilities**: Auto-fix for missing or broken mock implementations.
|
|
25
|
+
- **Modular Design**: Drop-in plugin support using custom class-based implementations.
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
## Benefits of This Modular Design
|
|
28
|
+
|
|
29
|
+
- **Extensibility**: Developers can inject their own loader, retriever, or LLM logic without modifying the core.
|
|
30
|
+
- **Testability**: Mocks and CI tools validate contract adherence for reliable test coverage.
|
|
31
|
+
- **Decoupling**: Each plugin can be independently implemented and swapped in via `.ragrc.json`.
|
|
32
|
+
- **CI Resilience**: The CI pipeline includes linting, contract verification, and test coverage enforcement.
|
|
23
33
|
|
|
24
34
|
## Installation
|
|
25
35
|
|
|
26
36
|
```bash
|
|
27
|
-
npm install @
|
|
37
|
+
npm install @devilsdev/rag-pipeline-utils
|
|
28
38
|
```
|
|
29
39
|
|
|
30
|
-
|
|
40
|
+
## Basic Usage
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
1. Create a `.ragrc.json` config:
|
|
33
43
|
|
|
34
|
-
```
|
|
35
|
-
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"loader": {
|
|
47
|
+
"pdf": "./src/mocks/pdf-loader.js"
|
|
48
|
+
},
|
|
49
|
+
"embedder": {
|
|
50
|
+
"openai": "./src/mocks/openai-embedder.js"
|
|
51
|
+
},
|
|
52
|
+
"retriever": {
|
|
53
|
+
"pinecone": "./src/mocks/pinecone-retriever.js"
|
|
54
|
+
},
|
|
55
|
+
"llm": {
|
|
56
|
+
"openai": "./src/mocks/openai-llm.js"
|
|
57
|
+
},
|
|
58
|
+
"namespace": "demo-namespace",
|
|
59
|
+
"pipeline": ["loader", "embedder", "retriever"]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
36
62
|
|
|
37
|
-
|
|
38
|
-
loader: 'markdown',
|
|
39
|
-
embedder: 'openai',
|
|
40
|
-
retriever: 'pinecone',
|
|
41
|
-
llm: 'openai-gpt-4',
|
|
42
|
-
useReranker: true
|
|
43
|
-
});
|
|
63
|
+
2. Run an ingestion:
|
|
44
64
|
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
```bash
|
|
66
|
+
node bin/cli.js ingest ./docs/sample.pdf
|
|
47
67
|
```
|
|
48
68
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## Testing
|
|
69
|
+
3. Run a query:
|
|
52
70
|
|
|
53
71
|
```bash
|
|
54
|
-
|
|
72
|
+
node bin/cli.js query "What is in the document?"
|
|
55
73
|
```
|
|
56
74
|
|
|
57
|
-
|
|
75
|
+
## Plugin Contracts
|
|
76
|
+
|
|
77
|
+
Each plugin must implement the following interface:
|
|
78
|
+
|
|
79
|
+
| Type | Required Methods |
|
|
80
|
+
| --------- | ------------------------------------------- |
|
|
81
|
+
| loader | `load(filePath)` |
|
|
82
|
+
| embedder | `embed(documents)`, `embedQuery(query)` |
|
|
83
|
+
| retriever | `store(vectors)`, `search(queryVector)` |
|
|
84
|
+
| llm | `ask(prompt)` |
|
|
85
|
+
|
|
86
|
+
## Folder Structure
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
/project-root
|
|
90
|
+
โโโ /src
|
|
91
|
+
โ โโโ /routes
|
|
92
|
+
โ โโโ /services
|
|
93
|
+
โ โโโ /utils
|
|
94
|
+
โ โโโ app.js
|
|
95
|
+
โโโ /scripts
|
|
96
|
+
โ โโโ setup.js
|
|
97
|
+
โ โโโ ci-runner.js
|
|
98
|
+
โ โโโ repair-fixtures.js
|
|
99
|
+
โโโ /__tests__
|
|
100
|
+
โ โโโ /fixtures
|
|
101
|
+
โ โโโ /unit
|
|
102
|
+
โ โโโ /integration
|
|
103
|
+
โโโ /public
|
|
104
|
+
โโโ README.md
|
|
105
|
+
โโโ USE_CASES.md
|
|
106
|
+
โโโ CHANGELOG.md
|
|
107
|
+
โโโ .env.example
|
|
108
|
+
```
|
|
58
109
|
|
|
59
|
-
## CLI
|
|
60
110
|
|
|
61
|
-
```bash
|
|
62
|
-
rag-pipeline ingest ./docs/my.pdf --loader pdf
|
|
63
|
-
rag-pipeline query "Explain RAG pipelines" --llm openai-gpt-4
|
|
64
|
-
rag-pipeline evaluate ./fixtures/sample-eval-dataset.json
|
|
65
|
-
rag-pipeline rerank "Explain embeddings" --retriever pinecone
|
|
66
|
-
```
|
|
67
111
|
|
|
68
|
-
|
|
112
|
+
## Why Use This?
|
|
69
113
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"retriever": "pinecone",
|
|
75
|
-
"llm": "openai-gpt-4",
|
|
76
|
-
"useReranker": true
|
|
77
|
-
}
|
|
78
|
-
```
|
|
114
|
+
- **Developer Experience**: Fast iteration, full contract CI
|
|
115
|
+
- **Pluggable Design**: Swap in your stack (OpenAI, Pinecone, Langchain, etc.)
|
|
116
|
+
- **Minimal & Modular**: Clean separation of concerns
|
|
117
|
+
- **Prod-ready**: 100% test coverage, schema validation, CLI control
|
|
79
118
|
|
|
80
|
-
---
|
|
81
119
|
|
|
82
|
-
## Project Structure
|
|
83
120
|
|
|
84
|
-
|
|
85
|
-
/src
|
|
86
|
-
โโโ core/ # Pipeline + registry
|
|
87
|
-
โโโ loader/ # Loaders for md, html, csv, dir
|
|
88
|
-
โโโ reranker/ # LLM-based context reranker
|
|
89
|
-
โโโ evaluate/ # Scoring, batch QA evaluation
|
|
90
|
-
โโโ utils/ # Logger, retry, schema
|
|
91
|
-
/bin/cli.js # CLI entrypoint
|
|
92
|
-
/__tests__/ # Unit, integration, snapshot tests
|
|
93
|
-
/public/ # Evaluation dashboard (React)
|
|
94
|
-
.github/workflows/ci.yml # CI config
|
|
95
|
-
```
|
|
121
|
+
## Use Cases
|
|
96
122
|
|
|
97
|
-
|
|
123
|
+
Explore real-world DevX-focused examples in [USE_CASES.md](./USE_CASES.md), including:
|
|
98
124
|
|
|
99
|
-
|
|
125
|
+
- Mock-driven plugin TDD
|
|
126
|
+
- CI-based interface validation
|
|
127
|
+
- Multivendor ingestion and search
|
|
128
|
+
- Runtime swap of LLM, retrievers, or embedders
|
|
129
|
+
- Bootstrap pipelines with auto-repairable defaults
|
|
100
130
|
|
|
101
|
-
```bash
|
|
102
|
-
node server.js
|
|
103
|
-
```
|
|
104
131
|
|
|
105
|
-
Visit: [http://localhost:3000](http://localhost:3000) โ Visualizes metrics, BLEU/ROUGE, pass rate.
|
|
106
132
|
|
|
107
|
-
|
|
133
|
+
## Contributing
|
|
134
|
+
|
|
135
|
+
We welcome contributions via PRs, especially new mock providers, validation helpers, and runtime extensions. Please follow the test + CI conventions before submitting.
|
|
136
|
+
|
|
137
|
+
|
|
108
138
|
|
|
109
139
|
## License
|
|
110
140
|
|
|
111
|
-
|
|
141
|
+
This project is licensed under the **GNU GPL v3.0** License - see the [LICENSE](./LICENSE) file for details.
|
|
112
142
|
|
|
113
143
|
---
|
|
114
144
|
|
|
115
|
-
|
|
145
|
+
Built with โค๏ธ by [Ali Kahwaji].
|
|
116
146
|
|
|
117
|
-
Ali Kahwaji โ [@DevilsDev](https://github.com/DevilsDev)
|
package/USE_CASES.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# RAG Pipeline Utils โ Developer-Focused Use Cases
|
|
2
|
+
|
|
3
|
+
> Modular, composable, and CI-verified RAG orchestration for modern AI applications.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Use Case 1: Pluggable Local RAG Stack for Prototyping
|
|
8
|
+
|
|
9
|
+
**Problem:** Traditional RAG tools force tight vendor dependencies.
|
|
10
|
+
|
|
11
|
+
**Solution:** Use mockable local plugin implementations to simulate loaders, embedders, retrievers, and LLMs.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @devilsdev/rag-pipeline-utils
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
// cli.js or app.js
|
|
19
|
+
import { PluginRegistry } from './src/core/plugin-registry.js';
|
|
20
|
+
import { loadRagConfig } from './src/config/load-config.js';
|
|
21
|
+
|
|
22
|
+
const config = loadRagConfig('.ragrc.json');
|
|
23
|
+
const loader = PluginRegistry.getPlugin('loader', 'pdf');
|
|
24
|
+
const docs = loader.load('./test.pdf');
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Benefits**
|
|
28
|
+
- Local plugin mocks with expected method contracts
|
|
29
|
+
- Reusable plugin templates (`pdf-loader.js`, `openai-embedder.js`)
|
|
30
|
+
- Dev-first DX: debug, snapshot, iterate without cloud costs
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Use Case 2: Declarative CLI RAG Pipelines (CI-Ready)
|
|
35
|
+
|
|
36
|
+
**Problem:** Hardcoded pipeline steps can't be validated or changed by non-engineers.
|
|
37
|
+
|
|
38
|
+
**Solution:** Define `.ragrc.json` once and reuse across environments.
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"loader": { "pdf": "./src/mocks/pdf-loader.js" },
|
|
43
|
+
"embedder": { "openai": "./src/mocks/openai-embedder.js" },
|
|
44
|
+
"retriever": { "pinecone": "./src/mocks/pinecone-retriever.js" },
|
|
45
|
+
"llm": { "openai": "./src/mocks/openai-llm.js" },
|
|
46
|
+
"namespace": "docs-poc",
|
|
47
|
+
"pipeline": ["loader", "embedder", "retriever"]
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
node ./bin/cli.js ingest ./docs/whitepaper.pdf
|
|
53
|
+
node ./bin/cli.js query "Whatโs the goal of this architecture?"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Benefits**
|
|
57
|
+
- Teams can standardize pipelines in source control
|
|
58
|
+
- Tests fail fast if structure or mocks drift
|
|
59
|
+
- Non-devs can operate pipelines via CLI
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Use Case 3: Mock-First TDD for Plugin Development
|
|
64
|
+
|
|
65
|
+
**Problem:** LLM, vector, and loader logic are often developed without tests.
|
|
66
|
+
|
|
67
|
+
**Solution:** Define contract-compliant mocks and CI-validate their structure before connecting to APIs.
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
export default class CustomEmbedder {
|
|
71
|
+
embed(docs) { return docs.map(...); }
|
|
72
|
+
embedQuery(q) { return [...]; }
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Run full contract verification:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run ci
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Benefits**
|
|
83
|
+
- Every plugin is CI-verified for method presence
|
|
84
|
+
- Shared contracts enforce required interfaces
|
|
85
|
+
- Onboarding new devs? Just follow `pluginContracts.js`
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Use Case 4: Vendor-Neutral AI Data Pipelines
|
|
90
|
+
|
|
91
|
+
**Problem:** Every RAG stack is locked to OpenAI + Pinecone + Langchain.
|
|
92
|
+
|
|
93
|
+
**Solution:** Use this project to mix, match, or mock vector/LLM pairs:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
"retriever": { "localstore": "./src/plugins/local-retriever.js" },
|
|
97
|
+
"llm": { "cohere": "./src/plugins/cohere-llm.js" }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Benefits**
|
|
101
|
+
- Run multiple RAG pipelines in parallel (A/B testing, evals)
|
|
102
|
+
- Lower infra cost with offline/local plugin support
|
|
103
|
+
- Integrate with tools outside Langchain ecosystem
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## ๐ Use Case 5: Plugin Engineering with Guardrails
|
|
108
|
+
|
|
109
|
+
**Problem:** Complex plugin systems break silently.
|
|
110
|
+
|
|
111
|
+
**Solution:** This framework has:
|
|
112
|
+
- Plugin method contract enforcement
|
|
113
|
+
- CLI test runner (`scripts/ci-runner.js`)
|
|
114
|
+
- Auto repair tool (`scripts/repair-fixtures.js`)
|
|
115
|
+
|
|
116
|
+
**DX Boost**
|
|
117
|
+
- One-line plugin repairs
|
|
118
|
+
- Validated schema structure
|
|
119
|
+
- Aligned to real-world developer workflows
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Cross References
|
|
124
|
+
|
|
125
|
+
- [README](./README.md) โ Project overview, architecture, CLI and configuration details
|
|
126
|
+
- [pluginContracts.js](./src/core/plugin-contracts.js) โ Interface contracts for loader, embedder, retriever, LLM
|
|
127
|
+
- [diagnostic-reporter.js](./src/utils/ci/diagnostic-reporter.js) โ CI error helper
|
|
128
|
+
- [repair-fixtures.js](./scripts/repair-fixtures.js) โ Auto-regeneration of mocks
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
Licensed under the **GPL-3.0 License** โ see [LICENSE](./LICENSE) for full terms.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"loader": { "pdf": "./src/mocks/pdf-loader.js" },
|
|
3
|
+
"embedder": { "openai": "./src/mocks/openai-embedder.js" },
|
|
4
|
+
"retriever": { "pinecone": "./src/mocks/pinecone-retriever.js" },
|
|
5
|
+
"llm": { "openai": "./src/mocks/openai-llm.js" },
|
|
6
|
+
"namespace": "cli-config-test",
|
|
7
|
+
"pipeline": ["loader", "embedder", "retriever"]
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock OpenAI Embedder Plugin
|
|
3
|
+
* Implements: embedder.embed(docs), embedder.embedQuery(query)
|
|
4
|
+
*/
|
|
5
|
+
export default class OpenAIEmbedder {
|
|
6
|
+
embed(documents) {
|
|
7
|
+
return documents.map(doc => ({
|
|
8
|
+
id: doc.id,
|
|
9
|
+
values: [0.1, 0.2, 0.3],
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
embedQuery(query) {
|
|
14
|
+
return [0.1, 0.2, 0.3];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock PDF Loader Plugin
|
|
3
|
+
* Implements: loader.load(filePath)
|
|
4
|
+
*/
|
|
5
|
+
export default class PdfLoader {
|
|
6
|
+
/**
|
|
7
|
+
* Loads a file and returns mock document chunks.
|
|
8
|
+
* @param {string} filePath
|
|
9
|
+
* @returns {Array<{ id: string, content: string }>}
|
|
10
|
+
*/
|
|
11
|
+
load(filePath) {
|
|
12
|
+
return [
|
|
13
|
+
{ id: 'doc1', content: `Loaded content from ${filePath}` },
|
|
14
|
+
{ id: 'doc2', content: 'Second document content' },
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Pinecone Retriever Plugin
|
|
3
|
+
* Implements: retriever.store(vectors), retriever.search(queryVector)
|
|
4
|
+
*/
|
|
5
|
+
export default class PineconeRetriever {
|
|
6
|
+
constructor() {
|
|
7
|
+
this._store = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Stores embedded vectors.
|
|
12
|
+
* @param {Array<{ id: string, values: number[] }>} vectors
|
|
13
|
+
*/
|
|
14
|
+
store(vectors) {
|
|
15
|
+
this._store = vectors;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Searches mock memory and returns matching docs.
|
|
20
|
+
* @param {number[]} queryVector
|
|
21
|
+
* @returns {Array<{ id: string, score: number }>}
|
|
22
|
+
*/
|
|
23
|
+
search(queryVector) {
|
|
24
|
+
return this._store.map(v => ({ id: v.id, score: 0.99 }));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"loader": {
|
|
3
|
+
"pdf": "./src/mocks/pdf-loader.js"
|
|
4
|
+
},
|
|
5
|
+
"embedder": {
|
|
6
|
+
"openai": "./src/mocks/openai-embedder.js"
|
|
7
|
+
},
|
|
8
|
+
"retriever": {
|
|
9
|
+
"pinecone": "./src/mocks/pinecone-retriever.js"
|
|
10
|
+
},
|
|
11
|
+
"llm": {
|
|
12
|
+
"openai": "./src/mocks/openai-llm.js"
|
|
13
|
+
},
|
|
14
|
+
"namespace": "cli-config-test",
|
|
15
|
+
"pipeline": ["loader", "embedder", "retriever"]
|
|
16
|
+
}
|