@devilsdev/rag-pipeline-utils 2.4.5 ā 2.6.0
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/.ragrc.schema.json +83 -192
- package/CHANGELOG.md +431 -0
- package/README.md +418 -117
- package/SECURITY.md +5 -5
- package/dist/experimental.cjs +2 -0
- package/dist/experimental.d.ts +1 -0
- package/dist/experimental.mjs +5 -0
- package/dist/index.cjs +6442 -1355
- package/dist/index.d.ts +129 -2
- package/dist/index.mjs +1 -1
- package/dist/testing.cjs +2 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.mjs +5 -0
- package/dist/types/adapters/ai-sdk.d.ts +53 -0
- package/dist/types/agentic/agentic-pipeline.d.ts +103 -0
- package/dist/types/agentic/iterative-retriever.d.ts +85 -0
- package/dist/types/agentic/query-planner.d.ts +145 -0
- package/dist/types/agentic/self-critique.d.ts +45 -0
- package/dist/types/ai/adaptive-retrieval.d.ts +44 -0
- package/dist/types/ai/federation/federated-learning-coordinator.d.ts +62 -0
- package/dist/types/ai/multimodal-processing.d.ts +32 -0
- package/dist/types/ai/multimodal.d.ts +39 -0
- package/dist/types/ai/retrieval-engine.d.ts +37 -0
- package/dist/types/ai/training/model-training-orchestrator.d.ts +31 -0
- package/dist/types/cache/component-keys.d.ts +7 -0
- package/dist/types/cache/memory-cache.d.ts +54 -0
- package/dist/types/cache/pipeline-cache.d.ts +66 -0
- package/dist/types/cache/redis-cache.d.ts +46 -0
- package/dist/types/chunking/chunking-engine.d.ts +70 -0
- package/dist/types/chunking/strategies/fixed-size.d.ts +17 -0
- package/dist/types/chunking/strategies/recursive.d.ts +20 -0
- package/dist/types/chunking/strategies/semantic.d.ts +19 -0
- package/dist/types/chunking/strategies/sentence.d.ts +13 -0
- package/dist/types/chunking/strategies/structure-aware.d.ts +19 -0
- package/dist/types/citation/citation-tracker.d.ts +64 -0
- package/dist/types/citation/hallucination-detector.d.ts +40 -0
- package/dist/types/citation/source-mapper.d.ts +37 -0
- package/dist/types/connectors/anthropic-connector.d.ts +97 -0
- package/dist/types/connectors/base-connector.d.ts +87 -0
- package/dist/types/connectors/cohere-connector.d.ts +94 -0
- package/dist/types/connectors/connector-utils.d.ts +110 -0
- package/dist/types/connectors/local-embedder.d.ts +95 -0
- package/dist/types/connectors/memory-retriever.d.ts +99 -0
- package/dist/types/connectors/ollama-connector.d.ts +115 -0
- package/dist/types/connectors/openai-connector.d.ts +129 -0
- package/dist/types/connectors/rag-prompt.d.ts +40 -0
- package/dist/types/core/create-pipeline.d.ts +8 -0
- package/dist/types/core/plugin-registry.d.ts +136 -0
- package/dist/types/core/stage-contracts.d.ts +36 -0
- package/dist/types/core/validate-plugin.d.ts +45 -0
- package/dist/types/cost/cost-calculator.d.ts +152 -0
- package/dist/types/cost/cost-tracker.d.ts +126 -0
- package/dist/types/cost/token-budget.d.ts +110 -0
- package/dist/types/dag/core/error-context.d.ts +239 -0
- package/dist/types/dag/core/execution-scheduler.d.ts +191 -0
- package/dist/types/dag/core/topology-validation.d.ts +226 -0
- package/dist/types/dag/dag-engine.d.ts +156 -0
- package/dist/types/dag/dag-node.d.ts +37 -0
- package/dist/types/dashboard/dashboard-generator.d.ts +127 -0
- package/dist/types/dashboard/metrics-aggregator.d.ts +218 -0
- package/dist/types/debug/execution-tracer.d.ts +57 -0
- package/dist/types/debug/trace-inspector.d.ts +31 -0
- package/dist/types/ecosystem/plugin-certification.d.ts +169 -0
- package/dist/types/enterprise/data-governance.d.ts +203 -0
- package/dist/types/enterprise/multi-tenancy.d.ts +137 -0
- package/dist/types/enterprise/sso-integration.d.ts +420 -0
- package/dist/types/evaluate/context-metrics.d.ts +55 -0
- package/dist/types/evaluate/faithfulness.d.ts +41 -0
- package/dist/types/evaluate/groundedness.d.ts +60 -0
- package/dist/types/evaluate/pipeline-evaluator.d.ts +88 -0
- package/dist/types/evaluate/relevance.d.ts +21 -0
- package/dist/types/evaluate/scoring.d.ts +123 -0
- package/dist/types/evaluate/semantic-similarity.d.ts +14 -0
- package/dist/types/experimental.d.ts +15 -0
- package/dist/types/graph/entity-extractor.d.ts +84 -0
- package/dist/types/graph/graph-index.d.ts +49 -0
- package/dist/types/graph/graph-retriever.d.ts +81 -0
- package/dist/types/graph/knowledge-graph.d.ts +129 -0
- package/dist/types/grounding/check-answer.d.ts +101 -0
- package/dist/types/guardrails/guardrails-pipeline.d.ts +63 -0
- package/dist/types/guardrails/injection-detector.d.ts +47 -0
- package/dist/types/guardrails/post-generation-guard.d.ts +61 -0
- package/dist/types/guardrails/pre-retrieval-guard.d.ts +64 -0
- package/dist/types/guardrails/retrieval-guard.d.ts +57 -0
- package/dist/types/mcp/mcp-server.d.ts +85 -0
- package/dist/types/mcp/mcp-tool-builder.d.ts +55 -0
- package/dist/types/reranker/cascade-reranker.d.ts +40 -0
- package/dist/types/reranker/embedding-reranker.d.ts +77 -0
- package/dist/types/reranker/scoring-reranker.d.ts +41 -0
- package/dist/types/retrieval/bm25-search.d.ts +43 -0
- package/dist/types/retrieval/file-vector-store.d.ts +99 -0
- package/dist/types/retrieval/hybrid-retriever.d.ts +35 -0
- package/dist/types/retrieval/rank-fusion.d.ts +10 -0
- package/dist/types/security/jwt-config.d.ts +80 -0
- package/dist/types/security/jwt-validator.d.ts +195 -0
- package/dist/types/security/plugin-sandbox.d.ts +158 -0
- package/dist/types/security/plugin-signature-verifier.d.ts +139 -0
- package/dist/types/security/validator.d.ts +5 -0
- package/dist/types/streaming/embedding-stream.d.ts +65 -0
- package/dist/types/streaming/sse-adapter.d.ts +59 -0
- package/dist/types/streaming/stream-router.d.ts +88 -0
- package/dist/types/streaming/streaming-embedder.d.ts +99 -0
- package/dist/types/streaming/websocket-adapter.d.ts +71 -0
- package/dist/types/templates/scaffold.d.ts +55 -0
- package/dist/types/templates/template-registry.d.ts +63 -0
- package/dist/types/testing.d.ts +168 -0
- package/dist/types/utils/embed-query.d.ts +20 -0
- package/dist/types/utils/logger.d.ts +50 -0
- package/dist/types/utils/rate-limiter.d.ts +66 -0
- package/dist/types/utils/retry.d.ts +27 -0
- package/dist/types/utils/run-abort.d.ts +34 -0
- package/dist/types/utils/secure-logging.d.ts +51 -0
- package/dist/types/utils/structured-logger.d.ts +126 -0
- package/package.json +72 -33
- package/src/adapters/ai-sdk.js +215 -0
- package/src/agentic/agentic-pipeline.js +75 -7
- package/src/agentic/iterative-retriever.js +47 -10
- package/src/agentic/query-planner.js +329 -78
- package/src/cache/component-keys.js +38 -0
- package/src/cache/memory-cache.js +87 -0
- package/src/cache/pipeline-cache.js +260 -0
- package/src/cache/redis-cache.js +83 -0
- package/src/citation/citation-tracker.js +6 -4
- package/src/citation/hallucination-detector.js +2 -2
- package/src/citation/source-mapper.js +15 -28
- package/src/cli/commands/ai.js +106 -0
- package/src/cli/commands/plugin-hub/event-handlers.js +6 -0
- package/src/cli/commands/plugin-hub/hub-commands.js +0 -74
- package/src/cli/commands/plugin-hub/local-commands.js +143 -0
- package/src/cli/commands/plugin-hub.js +114 -49
- package/src/cli/diagnostics/config-checker.js +76 -63
- package/src/cli/diagnostics/environment-checker.js +62 -31
- package/src/cli/diagnostics/plugin-checker.js +36 -89
- package/src/cli/doctor-command.js +39 -5
- package/src/cli/enhanced-cli-commands.js +104 -233
- package/src/cli/handlers/ai-handler.js +364 -0
- package/src/cli/handlers/diagnostics-handler.js +78 -31
- package/src/cli/handlers/ingest-handler.js +28 -22
- package/src/cli/handlers/init-handler.js +148 -25
- package/src/cli/handlers/query-handler.js +203 -25
- package/src/cli/handlers/run-handler.js +16 -167
- package/src/cli/handlers/serve-handler.js +60 -0
- package/src/cli/services/bench-stats.js +54 -0
- package/src/cli/services/benchmark.js +161 -0
- package/src/cli/services/feedback.js +155 -0
- package/src/cli/services/instrument.js +83 -0
- package/src/cli/services/rag-service.js +361 -0
- package/src/cli/shared/cli-utils.js +24 -7
- package/src/cli/shared/config-context.js +21 -0
- package/src/cli/wizard/config-builder.js +81 -0
- package/src/cli/wizard/init-wizard.js +602 -0
- package/src/config/component-factory.js +125 -0
- package/src/config/enhanced-ragrc-schema.js +0 -2
- package/src/config/load-config.js +29 -10
- package/src/config/load-plugin-config.js +46 -2
- package/src/config/validate-schema.js +4 -1
- package/src/connectors/anthropic-connector.js +115 -57
- package/src/connectors/base-connector.js +74 -19
- package/src/connectors/cohere-connector.js +108 -34
- package/src/connectors/connector-utils.js +302 -0
- package/src/connectors/local-embedder.js +63 -5
- package/src/connectors/memory-retriever.js +125 -14
- package/src/connectors/ollama-connector.js +112 -51
- package/src/connectors/openai-connector.js +153 -44
- package/src/connectors/rag-prompt.js +88 -0
- package/src/core/create-pipeline.js +307 -61
- package/src/core/performance/parallel-processor.js +62 -1
- package/src/core/plugin-registry.js +125 -26
- package/src/core/stage-contracts.js +36 -0
- package/src/core/validate-plugin.js +85 -0
- package/src/cost/cost-calculator.js +205 -32
- package/src/debug/execution-tracer.js +14 -4
- package/src/dev/dev-server.js +173 -11
- package/src/dev/hot-reload.js +44 -4
- package/src/ecosystem/plugin-checks.js +181 -0
- package/src/ecosystem/plugin-hub.js +50 -125
- package/src/ecosystem/plugin-installer.js +298 -0
- package/src/ecosystem/plugin-probe.js +127 -0
- package/src/ecosystem/plugin-scanner.js +185 -0
- package/src/ecosystem/tar-extract.js +114 -0
- package/src/enterprise/audit-logging.js +158 -29
- package/src/enterprise/sso-integration.js +716 -228
- package/src/evaluate/context-metrics.js +28 -16
- package/src/evaluate/evaluator.js +3 -3
- package/src/evaluate/faithfulness.js +18 -14
- package/src/evaluate/groundedness.js +43 -12
- package/src/evaluate/pipeline-evaluator.js +35 -8
- package/src/evaluate/scoring.js +251 -3
- package/src/evaluate/semantic-similarity.js +79 -0
- package/src/experimental.js +71 -0
- package/src/grounding/check-answer.js +173 -0
- package/src/guardrails/guardrails-pipeline.js +69 -7
- package/src/guardrails/injection-detector.js +283 -0
- package/src/guardrails/post-generation-guard.js +19 -0
- package/src/guardrails/pre-retrieval-guard.js +36 -36
- package/src/guardrails/retrieval-guard.js +58 -8
- package/src/index.js +58 -1
- package/src/loader/csv-loader.js +3 -2
- package/src/loader/document-reader.js +91 -0
- package/src/loader/html-loader.js +3 -1
- package/src/loader/markdown-loader.js +3 -2
- package/src/reranker/cascade-reranker.js +3 -0
- package/src/reranker/embedding-reranker.js +136 -21
- package/src/reranker/llm-reranker.js +79 -12
- package/src/reranker/scoring-reranker.js +3 -0
- package/src/retrieval/bm25-search.js +12 -6
- package/src/retrieval/file-vector-store.js +241 -0
- package/src/retrieval/hybrid-retriever.js +22 -19
- package/src/security/jwt-config.js +13 -2
- package/src/security/jwt-validator.js +139 -34
- package/src/security/plugin-sandbox.js +18 -1
- package/src/security/plugin-signature-verifier.js +245 -70
- package/src/testing.js +254 -0
- package/src/utils/deprecate.js +69 -0
- package/src/utils/embed-query.js +33 -0
- package/src/utils/input-sanitizer.js +19 -4
- package/src/utils/logger.js +34 -4
- package/src/utils/run-abort.js +102 -0
- package/src/ai/federated-learning.js +0 -211
- package/src/ai/federation.js +0 -71
- package/src/ai/index.js +0 -22
- package/src/ai/model-trainer.js +0 -217
- package/src/ai/model-training.js +0 -202
- package/src/ai/multimodal/multi-modal-processor.js +0 -345
- package/src/ai/orchestrator.js +0 -65
- package/src/ai/retrieval/adaptive-retrieval-engine.js +0 -398
- package/src/cli/commands/ai-ml/adaptive-commands.js +0 -178
- package/src/cli/commands/ai-ml/federated-commands.js +0 -207
- package/src/cli/commands/ai-ml/index.js +0 -17
- package/src/cli/commands/ai-ml/multimodal-commands.js +0 -187
- package/src/cli/commands/ai-ml/shared.js +0 -51
- package/src/cli/commands/ai-ml/training-commands.js +0 -228
- package/src/cli/commands/ai-ml.js +0 -386
- package/src/cli/commands/docs.js +0 -228
- package/src/cli/commands/dx.js +0 -538
- package/src/cli/commands/wizard.js +0 -627
- package/src/cli/input-sanitization-middleware.js +0 -356
- package/src/cli/interactive-wizard.js +0 -373
- package/src/cli/templates/development.template.json +0 -64
- package/src/cli/templates/minimal.template.json +0 -33
- package/src/cli/templates/production.template.json +0 -104
- package/src/cli/templates/testing.template.json +0 -45
- package/src/cli/wizard/configuration.js +0 -148
- package/src/cli/wizard/observability.js +0 -79
- package/src/cli/wizard/performance.js +0 -76
- package/src/cli/wizard/plugin-selection.js +0 -297
- package/src/cli/wizard/preview-save.js +0 -172
- package/src/cli/wizard/project-setup.js +0 -66
- package/src/core/pipeline-factory.js +0 -59
- package/src/dag/enhanced-dag-engine.js +0 -894
- package/src/dx/index.js +0 -40
- package/src/dx/integration-templates.js +0 -662
- package/src/dx/performance-profiler.js +0 -968
- package/src/dx/realtime-debugger.js +0 -755
- package/src/dx/visual-pipeline-builder.js +0 -578
- package/src/ingest.js +0 -59
- package/src/pipeline/pipeline.js +0 -18
- package/src/query.js +0 -117
|
@@ -1,627 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interactive Configuration Wizard CLI Command
|
|
5
|
-
*
|
|
6
|
-
* Provides an interactive CLI wizard for creating and managing
|
|
7
|
-
* RAG pipeline configurations with:
|
|
8
|
-
* - Template-based configuration
|
|
9
|
-
* - Real-time validation
|
|
10
|
-
* - Plugin discovery and selection
|
|
11
|
-
* - Configuration preview and testing
|
|
12
|
-
*
|
|
13
|
-
* @module cli/commands/wizard
|
|
14
|
-
* @since 2.4.0
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const { Command } = require("commander");
|
|
18
|
-
const chalk = require("chalk");
|
|
19
|
-
const inquirer = require("inquirer");
|
|
20
|
-
const fs = require("fs/promises");
|
|
21
|
-
const path = require("path");
|
|
22
|
-
const {
|
|
23
|
-
InteractiveWizard,
|
|
24
|
-
runInteractiveWizard,
|
|
25
|
-
} = require("../interactive-wizard");
|
|
26
|
-
const { validateRagrc } = require("../../config/enhanced-ragrc-schema");
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Configuration Templates
|
|
30
|
-
*
|
|
31
|
-
* Pre-defined templates for common use cases
|
|
32
|
-
*/
|
|
33
|
-
const TEMPLATES = {
|
|
34
|
-
minimal: {
|
|
35
|
-
name: "Minimal Setup",
|
|
36
|
-
description: "Basic RAG pipeline with essential plugins",
|
|
37
|
-
config: {
|
|
38
|
-
metadata: {
|
|
39
|
-
name: "minimal-rag-pipeline",
|
|
40
|
-
version: "1.0.0",
|
|
41
|
-
description: "Minimal RAG pipeline configuration",
|
|
42
|
-
environment: "development",
|
|
43
|
-
},
|
|
44
|
-
plugins: {
|
|
45
|
-
loader: {
|
|
46
|
-
"file-loader": "latest",
|
|
47
|
-
},
|
|
48
|
-
embedder: {
|
|
49
|
-
"openai-embedder": "latest",
|
|
50
|
-
},
|
|
51
|
-
retriever: {
|
|
52
|
-
"vector-retriever": "latest",
|
|
53
|
-
},
|
|
54
|
-
llm: {
|
|
55
|
-
"openai-llm": "latest",
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
pipeline: {
|
|
59
|
-
stages: ["loader", "embedder", "retriever", "llm"],
|
|
60
|
-
},
|
|
61
|
-
observability: {
|
|
62
|
-
logging: {
|
|
63
|
-
level: "info",
|
|
64
|
-
structured: true,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
production: {
|
|
71
|
-
name: "Production Ready",
|
|
72
|
-
description:
|
|
73
|
-
"Production-grade configuration with monitoring and optimization",
|
|
74
|
-
config: {
|
|
75
|
-
metadata: {
|
|
76
|
-
name: "production-rag-pipeline",
|
|
77
|
-
version: "1.0.0",
|
|
78
|
-
description: "Production RAG pipeline with full observability",
|
|
79
|
-
environment: "production",
|
|
80
|
-
},
|
|
81
|
-
plugins: {
|
|
82
|
-
loader: {
|
|
83
|
-
"file-loader": "latest",
|
|
84
|
-
},
|
|
85
|
-
embedder: {
|
|
86
|
-
"openai-embedder": {
|
|
87
|
-
name: "openai-embedder",
|
|
88
|
-
version: "latest",
|
|
89
|
-
config: {
|
|
90
|
-
batchSize: 100,
|
|
91
|
-
timeout: 30000,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
retriever: {
|
|
96
|
-
"vector-retriever": {
|
|
97
|
-
name: "vector-retriever",
|
|
98
|
-
version: "latest",
|
|
99
|
-
config: {
|
|
100
|
-
topK: 10,
|
|
101
|
-
threshold: 0.7,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
llm: {
|
|
106
|
-
"openai-llm": "latest",
|
|
107
|
-
},
|
|
108
|
-
reranker: {
|
|
109
|
-
"similarity-reranker": "latest",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
pipeline: {
|
|
113
|
-
stages: ["loader", "embedder", "retriever", "reranker", "llm"],
|
|
114
|
-
retries: {
|
|
115
|
-
enabled: true,
|
|
116
|
-
maxAttempts: 3,
|
|
117
|
-
backoff: "exponential",
|
|
118
|
-
},
|
|
119
|
-
timeout: 60000,
|
|
120
|
-
},
|
|
121
|
-
performance: {
|
|
122
|
-
caching: {
|
|
123
|
-
enabled: true,
|
|
124
|
-
maxSize: 1000,
|
|
125
|
-
ttl: 3600,
|
|
126
|
-
},
|
|
127
|
-
parallel: {
|
|
128
|
-
enabled: true,
|
|
129
|
-
maxConcurrency: 5,
|
|
130
|
-
batchSize: 10,
|
|
131
|
-
},
|
|
132
|
-
streaming: {
|
|
133
|
-
enabled: true,
|
|
134
|
-
maxMemoryMB: 512,
|
|
135
|
-
bufferSize: 100,
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
observability: {
|
|
139
|
-
logging: {
|
|
140
|
-
level: "info",
|
|
141
|
-
structured: true,
|
|
142
|
-
events: true,
|
|
143
|
-
},
|
|
144
|
-
tracing: {
|
|
145
|
-
enabled: true,
|
|
146
|
-
sampleRate: 0.1,
|
|
147
|
-
},
|
|
148
|
-
metrics: {
|
|
149
|
-
enabled: true,
|
|
150
|
-
interval: 60000,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
development: {
|
|
157
|
-
name: "Development",
|
|
158
|
-
description: "Development environment with verbose logging",
|
|
159
|
-
config: {
|
|
160
|
-
metadata: {
|
|
161
|
-
name: "dev-rag-pipeline",
|
|
162
|
-
version: "1.0.0",
|
|
163
|
-
description: "Development RAG pipeline",
|
|
164
|
-
environment: "development",
|
|
165
|
-
},
|
|
166
|
-
plugins: {
|
|
167
|
-
loader: {
|
|
168
|
-
"file-loader": "latest",
|
|
169
|
-
},
|
|
170
|
-
embedder: {
|
|
171
|
-
"local-embedder": "latest",
|
|
172
|
-
},
|
|
173
|
-
retriever: {
|
|
174
|
-
"vector-retriever": "latest",
|
|
175
|
-
},
|
|
176
|
-
llm: {
|
|
177
|
-
"local-llm": "latest",
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
pipeline: {
|
|
181
|
-
stages: ["loader", "embedder", "retriever", "llm"],
|
|
182
|
-
timeout: 30000,
|
|
183
|
-
},
|
|
184
|
-
observability: {
|
|
185
|
-
logging: {
|
|
186
|
-
level: "debug",
|
|
187
|
-
structured: true,
|
|
188
|
-
events: true,
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
testing: {
|
|
195
|
-
name: "Testing",
|
|
196
|
-
description: "Testing configuration with mock plugins",
|
|
197
|
-
config: {
|
|
198
|
-
metadata: {
|
|
199
|
-
name: "test-rag-pipeline",
|
|
200
|
-
version: "1.0.0",
|
|
201
|
-
description: "Testing RAG pipeline",
|
|
202
|
-
environment: "testing",
|
|
203
|
-
},
|
|
204
|
-
plugins: {
|
|
205
|
-
loader: {
|
|
206
|
-
"mock-loader": "./src/mocks/pdf-loader.js",
|
|
207
|
-
},
|
|
208
|
-
embedder: {
|
|
209
|
-
"mock-embedder": "./src/mocks/openai-embedder.js",
|
|
210
|
-
},
|
|
211
|
-
retriever: {
|
|
212
|
-
"mock-retriever": "./src/mocks/pinecone-retriever.js",
|
|
213
|
-
},
|
|
214
|
-
llm: {
|
|
215
|
-
"mock-llm": "./src/mocks/openai-llm.js",
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
pipeline: {
|
|
219
|
-
stages: ["loader", "embedder", "retriever", "llm"],
|
|
220
|
-
},
|
|
221
|
-
observability: {
|
|
222
|
-
logging: {
|
|
223
|
-
level: "warn",
|
|
224
|
-
structured: true,
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
custom: {
|
|
231
|
-
name: "Custom (Interactive)",
|
|
232
|
-
description: "Build your configuration from scratch",
|
|
233
|
-
config: null, // Will use interactive wizard
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Create wizard command
|
|
239
|
-
*
|
|
240
|
-
* @returns {Command} Wizard command
|
|
241
|
-
*/
|
|
242
|
-
function createWizardCommand() {
|
|
243
|
-
const wizardCmd = new Command("wizard");
|
|
244
|
-
|
|
245
|
-
wizardCmd
|
|
246
|
-
.description("Interactive configuration wizard for RAG pipeline setup")
|
|
247
|
-
.option(
|
|
248
|
-
"-o, --output <path>",
|
|
249
|
-
"Output configuration file path",
|
|
250
|
-
".ragrc.json",
|
|
251
|
-
)
|
|
252
|
-
.option(
|
|
253
|
-
"-t, --template <name>",
|
|
254
|
-
"Use a configuration template (minimal|production|development|testing|custom)",
|
|
255
|
-
)
|
|
256
|
-
.option("--list-templates", "List available templates")
|
|
257
|
-
.option("--validate <file>", "Validate an existing configuration file")
|
|
258
|
-
.option("--no-save", "Don't save configuration (preview only)")
|
|
259
|
-
.option("--quiet", "Minimal output")
|
|
260
|
-
.action(async (options) => {
|
|
261
|
-
try {
|
|
262
|
-
// List templates
|
|
263
|
-
if (options.listTemplates) {
|
|
264
|
-
await listTemplates();
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Validate existing configuration
|
|
269
|
-
if (options.validate) {
|
|
270
|
-
await validateConfiguration(options.validate);
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// Run interactive wizard
|
|
275
|
-
if (!options.quiet) {
|
|
276
|
-
console.log(
|
|
277
|
-
chalk.cyan("āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā"),
|
|
278
|
-
);
|
|
279
|
-
console.log(
|
|
280
|
-
chalk.cyan("ā RAG Pipeline Configuration Wizard ā"),
|
|
281
|
-
);
|
|
282
|
-
console.log(
|
|
283
|
-
chalk.cyan("āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n"),
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Template selection or custom
|
|
288
|
-
let config;
|
|
289
|
-
if (options.template) {
|
|
290
|
-
config = await useTemplate(options.template, options);
|
|
291
|
-
} else {
|
|
292
|
-
// Ask user to select template or custom
|
|
293
|
-
const templateChoice = await inquirer.prompt([
|
|
294
|
-
{
|
|
295
|
-
type: "list",
|
|
296
|
-
name: "template",
|
|
297
|
-
message: "Choose a starting point:",
|
|
298
|
-
choices: Object.entries(TEMPLATES).map(([key, template]) => ({
|
|
299
|
-
name: `${template.name} - ${template.description}`,
|
|
300
|
-
value: key,
|
|
301
|
-
short: template.name,
|
|
302
|
-
})),
|
|
303
|
-
default: "custom",
|
|
304
|
-
},
|
|
305
|
-
]);
|
|
306
|
-
|
|
307
|
-
if (templateChoice.template === "custom") {
|
|
308
|
-
config = await runCustomWizard(options);
|
|
309
|
-
} else {
|
|
310
|
-
config = await useTemplate(templateChoice.template, options);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Display success message
|
|
315
|
-
if (!options.quiet && config) {
|
|
316
|
-
console.log(
|
|
317
|
-
chalk.green("\nā
Configuration wizard completed successfully!"),
|
|
318
|
-
);
|
|
319
|
-
console.log(
|
|
320
|
-
chalk.gray(` Configuration saved to: ${options.output}`),
|
|
321
|
-
);
|
|
322
|
-
console.log(chalk.gray("\n Next steps:"));
|
|
323
|
-
console.log(
|
|
324
|
-
chalk.gray(
|
|
325
|
-
" 1. Review your configuration: cat " + options.output,
|
|
326
|
-
),
|
|
327
|
-
);
|
|
328
|
-
console.log(
|
|
329
|
-
chalk.gray(" 2. Test your pipeline: npm run pipeline:test"),
|
|
330
|
-
);
|
|
331
|
-
console.log(chalk.gray(" 3. Start your pipeline: npm start"));
|
|
332
|
-
}
|
|
333
|
-
} catch (error) {
|
|
334
|
-
console.error(chalk.red("\nā Wizard failed:"), error.message);
|
|
335
|
-
if (error.stack && !options.quiet) {
|
|
336
|
-
console.error(chalk.gray(error.stack));
|
|
337
|
-
}
|
|
338
|
-
process.exit(1);
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
return wizardCmd;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* List available templates
|
|
347
|
-
*/
|
|
348
|
-
async function listTemplates() {
|
|
349
|
-
console.log(chalk.cyan("\nš Available Configuration Templates:\n"));
|
|
350
|
-
|
|
351
|
-
for (const [key, template] of Object.entries(TEMPLATES)) {
|
|
352
|
-
console.log(chalk.bold(` ${key}:`));
|
|
353
|
-
console.log(` ${template.description}`);
|
|
354
|
-
|
|
355
|
-
if (template.config) {
|
|
356
|
-
const pluginCount = Object.values(template.config.plugins || {}).reduce(
|
|
357
|
-
(sum, plugins) => sum + Object.keys(plugins).length,
|
|
358
|
-
0,
|
|
359
|
-
);
|
|
360
|
-
const features = [];
|
|
361
|
-
|
|
362
|
-
if (template.config.performance?.caching?.enabled)
|
|
363
|
-
features.push("caching");
|
|
364
|
-
if (template.config.performance?.parallel?.enabled)
|
|
365
|
-
features.push("parallel");
|
|
366
|
-
if (template.config.observability?.tracing?.enabled)
|
|
367
|
-
features.push("tracing");
|
|
368
|
-
|
|
369
|
-
console.log(chalk.gray(` ⢠${pluginCount} plugins configured`));
|
|
370
|
-
if (features.length > 0) {
|
|
371
|
-
console.log(chalk.gray(` ⢠Features: ${features.join(", ")}`));
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
console.log();
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
console.log(chalk.gray("Usage: npm run wizard -- --template <name>"));
|
|
378
|
-
console.log(
|
|
379
|
-
chalk.gray(" or: npm run wizard (for interactive selection)\n"),
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Use configuration template
|
|
385
|
-
*
|
|
386
|
-
* @param {string} templateName - Template name
|
|
387
|
-
* @param {object} options - Command options
|
|
388
|
-
* @returns {Promise<object>} Configuration
|
|
389
|
-
*/
|
|
390
|
-
async function useTemplate(templateName, options) {
|
|
391
|
-
const template = TEMPLATES[templateName];
|
|
392
|
-
|
|
393
|
-
if (!template) {
|
|
394
|
-
throw new Error(
|
|
395
|
-
`Unknown template: ${templateName}. Use --list-templates to see available options.`,
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (templateName === "custom") {
|
|
400
|
-
return await runCustomWizard(options);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
console.log(chalk.blue(`\nšÆ Using template: ${template.name}\n`));
|
|
404
|
-
console.log(chalk.gray(` ${template.description}\n`));
|
|
405
|
-
|
|
406
|
-
// Clone template configuration
|
|
407
|
-
const config = JSON.parse(JSON.stringify(template.config));
|
|
408
|
-
|
|
409
|
-
// Allow customization
|
|
410
|
-
const customizeAnswer = await inquirer.prompt([
|
|
411
|
-
{
|
|
412
|
-
type: "confirm",
|
|
413
|
-
name: "customize",
|
|
414
|
-
message: "Would you like to customize this template?",
|
|
415
|
-
default: false,
|
|
416
|
-
},
|
|
417
|
-
]);
|
|
418
|
-
|
|
419
|
-
if (customizeAnswer.customize) {
|
|
420
|
-
// Customize project metadata
|
|
421
|
-
const metadata = await inquirer.prompt([
|
|
422
|
-
{
|
|
423
|
-
type: "input",
|
|
424
|
-
name: "name",
|
|
425
|
-
message: "Project name:",
|
|
426
|
-
default: config.metadata.name,
|
|
427
|
-
validate: (input) => input.length > 0 || "Project name is required",
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
type: "input",
|
|
431
|
-
name: "description",
|
|
432
|
-
message: "Project description:",
|
|
433
|
-
default: config.metadata.description,
|
|
434
|
-
},
|
|
435
|
-
]);
|
|
436
|
-
|
|
437
|
-
config.metadata.name = metadata.name;
|
|
438
|
-
config.metadata.description = metadata.description;
|
|
439
|
-
config.metadata.createdAt = new Date().toISOString();
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// Validate configuration
|
|
443
|
-
const validation = validateRagrc(config);
|
|
444
|
-
if (!validation.valid) {
|
|
445
|
-
console.error(chalk.red("\nā Template configuration is invalid:"));
|
|
446
|
-
validation.errors?.forEach((error) => {
|
|
447
|
-
console.error(chalk.red(` ${error.instancePath}: ${error.message}`));
|
|
448
|
-
});
|
|
449
|
-
throw new Error("Invalid template configuration");
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// Use normalized configuration
|
|
453
|
-
const finalConfig = validation.normalized;
|
|
454
|
-
|
|
455
|
-
// Save configuration if not disabled
|
|
456
|
-
if (options.save !== false) {
|
|
457
|
-
await fs.writeFile(
|
|
458
|
-
options.output,
|
|
459
|
-
JSON.stringify(finalConfig, null, 2),
|
|
460
|
-
"utf-8",
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// Display configuration summary
|
|
465
|
-
displayConfigSummary(finalConfig);
|
|
466
|
-
|
|
467
|
-
return finalConfig;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Run custom wizard
|
|
472
|
-
*
|
|
473
|
-
* @param {object} options - Command options
|
|
474
|
-
* @returns {Promise<object>} Configuration
|
|
475
|
-
*/
|
|
476
|
-
async function runCustomWizard(options) {
|
|
477
|
-
console.log(
|
|
478
|
-
chalk.blue("\nš§ Starting interactive configuration wizard...\n"),
|
|
479
|
-
);
|
|
480
|
-
|
|
481
|
-
const wizard = new InteractiveWizard({
|
|
482
|
-
outputPath: options.output,
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
const config = await wizard.run();
|
|
486
|
-
|
|
487
|
-
return config;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Validate configuration file
|
|
492
|
-
*
|
|
493
|
-
* @param {string} filePath - Configuration file path
|
|
494
|
-
*/
|
|
495
|
-
async function validateConfiguration(filePath) {
|
|
496
|
-
console.log(chalk.blue(`\nš Validating configuration: ${filePath}\n`));
|
|
497
|
-
|
|
498
|
-
try {
|
|
499
|
-
// Read configuration file
|
|
500
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
501
|
-
const config = JSON.parse(content);
|
|
502
|
-
|
|
503
|
-
// Validate against schema
|
|
504
|
-
const validation = validateRagrc(config);
|
|
505
|
-
|
|
506
|
-
if (validation.valid) {
|
|
507
|
-
console.log(chalk.green("ā
Configuration is valid!\n"));
|
|
508
|
-
|
|
509
|
-
// Display summary
|
|
510
|
-
displayConfigSummary(config);
|
|
511
|
-
|
|
512
|
-
// Display warnings if any
|
|
513
|
-
if (validation.warnings && validation.warnings.length > 0) {
|
|
514
|
-
console.log(chalk.yellow("\nā ļø Warnings:"));
|
|
515
|
-
validation.warnings.forEach((warning) => {
|
|
516
|
-
console.log(chalk.yellow(` ⢠${warning}`));
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
} else {
|
|
520
|
-
console.log(chalk.red("ā Configuration is invalid:\n"));
|
|
521
|
-
|
|
522
|
-
validation.errors?.forEach((error) => {
|
|
523
|
-
console.log(chalk.red(` ⢠${error.instancePath}: ${error.message}`));
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
process.exit(1);
|
|
527
|
-
}
|
|
528
|
-
} catch (error) {
|
|
529
|
-
if (error.code === "ENOENT") {
|
|
530
|
-
console.error(chalk.red(`ā File not found: ${filePath}`));
|
|
531
|
-
} else if (error instanceof SyntaxError) {
|
|
532
|
-
console.error(chalk.red(`ā Invalid JSON: ${error.message}`));
|
|
533
|
-
} else {
|
|
534
|
-
console.error(chalk.red(`ā Validation failed: ${error.message}`));
|
|
535
|
-
}
|
|
536
|
-
process.exit(1);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Display configuration summary
|
|
542
|
-
*
|
|
543
|
-
* @param {object} config - Configuration object
|
|
544
|
-
*/
|
|
545
|
-
function displayConfigSummary(config) {
|
|
546
|
-
console.log(chalk.cyan("\nš Configuration Summary:\n"));
|
|
547
|
-
|
|
548
|
-
// Project metadata
|
|
549
|
-
if (config.metadata) {
|
|
550
|
-
console.log(chalk.bold(" Project:"));
|
|
551
|
-
console.log(` Name: ${config.metadata.name || "Unnamed"}`);
|
|
552
|
-
console.log(
|
|
553
|
-
` Environment: ${config.metadata.environment || "development"}`,
|
|
554
|
-
);
|
|
555
|
-
if (config.metadata.description) {
|
|
556
|
-
console.log(` Description: ${config.metadata.description}`);
|
|
557
|
-
}
|
|
558
|
-
console.log();
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
// Plugins
|
|
562
|
-
if (config.plugins) {
|
|
563
|
-
console.log(chalk.bold(" Plugins:"));
|
|
564
|
-
for (const [type, plugins] of Object.entries(config.plugins)) {
|
|
565
|
-
const pluginNames = Object.keys(plugins);
|
|
566
|
-
if (pluginNames.length > 0) {
|
|
567
|
-
console.log(` ${type}: ${pluginNames.join(", ")}`);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
console.log();
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// Pipeline
|
|
574
|
-
if (config.pipeline) {
|
|
575
|
-
console.log(chalk.bold(" Pipeline:"));
|
|
576
|
-
if (config.pipeline.stages) {
|
|
577
|
-
console.log(` Stages: ${config.pipeline.stages.join(" ā ")}`);
|
|
578
|
-
}
|
|
579
|
-
if (config.pipeline.retries?.enabled) {
|
|
580
|
-
console.log(
|
|
581
|
-
` Retries: ${config.pipeline.retries.maxAttempts} attempts (${config.pipeline.retries.backoff})`,
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
console.log();
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// Performance
|
|
588
|
-
if (config.performance) {
|
|
589
|
-
const features = [];
|
|
590
|
-
if (config.performance.caching?.enabled) features.push("caching");
|
|
591
|
-
if (config.performance.parallel?.enabled)
|
|
592
|
-
features.push("parallel processing");
|
|
593
|
-
if (config.performance.streaming?.enabled) features.push("streaming");
|
|
594
|
-
|
|
595
|
-
if (features.length > 0) {
|
|
596
|
-
console.log(chalk.bold(" Performance:"));
|
|
597
|
-
features.forEach((feature) => console.log(` ⢠${feature}`));
|
|
598
|
-
console.log();
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// Observability
|
|
603
|
-
if (config.observability) {
|
|
604
|
-
const features = [];
|
|
605
|
-
if (config.observability.logging)
|
|
606
|
-
features.push(`logging (${config.observability.logging.level})`);
|
|
607
|
-
if (config.observability.tracing?.enabled) features.push("tracing");
|
|
608
|
-
if (config.observability.metrics?.enabled) features.push("metrics");
|
|
609
|
-
|
|
610
|
-
if (features.length > 0) {
|
|
611
|
-
console.log(chalk.bold(" Observability:"));
|
|
612
|
-
features.forEach((feature) => console.log(` ⢠${feature}`));
|
|
613
|
-
console.log();
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* Export command and utilities
|
|
620
|
-
*/
|
|
621
|
-
module.exports = {
|
|
622
|
-
createWizardCommand,
|
|
623
|
-
TEMPLATES,
|
|
624
|
-
useTemplate,
|
|
625
|
-
validateConfiguration,
|
|
626
|
-
displayConfigSummary,
|
|
627
|
-
};
|