@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,297 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin Selection Step
|
|
3
|
-
* Handles plugin selection, custom plugin configuration, and plugin settings
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Select plugins for each type
|
|
8
|
-
* @param {object} config - Current wizard configuration state
|
|
9
|
-
* @param {object} inquirer - Inquirer instance for prompting
|
|
10
|
-
* @param {object} context - Wizard context with registry and helper methods
|
|
11
|
-
* @param {object|null} context.registry - Plugin registry data
|
|
12
|
-
* @param {Function} context.getAvailablePlugins - Function to get available plugins for a type
|
|
13
|
-
* @param {Function} context.getPluginInfo - Function to get plugin info
|
|
14
|
-
* @param {Function} context.loadRegistry - Function to load plugin registry
|
|
15
|
-
* @returns {Promise<object>} Updated configuration state
|
|
16
|
-
*/
|
|
17
|
-
async function selectPlugins(config, inquirer, context) {
|
|
18
|
-
console.log("🔌 Plugin Selection\n");
|
|
19
|
-
// eslint-disable-line no-console
|
|
20
|
-
|
|
21
|
-
// Load registry for plugin suggestions
|
|
22
|
-
try {
|
|
23
|
-
context.registry = await context.loadRegistry();
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.warn(
|
|
26
|
-
"⚠️ Could not load plugin registry. Using built-in _options.",
|
|
27
|
-
);
|
|
28
|
-
// eslint-disable-line no-console
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const pluginTypes = [
|
|
32
|
-
{ key: "loader", name: "Document Loader", required: true },
|
|
33
|
-
{ key: "embedder", name: "Text Embedder", required: true },
|
|
34
|
-
{ key: "retriever", name: "Vector Retriever", required: true },
|
|
35
|
-
{ key: "llm", name: "Language Model", required: true },
|
|
36
|
-
{ key: "reranker", name: "Result Reranker", required: false },
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
for (const pluginType of pluginTypes) {
|
|
40
|
-
await selectPluginForType(config, inquirer, context, pluginType);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log("✅ Plugin selection complete\n");
|
|
44
|
-
// eslint-disable-line no-console
|
|
45
|
-
|
|
46
|
-
return config;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Select plugin for a specific type
|
|
51
|
-
* @param {object} config - Current wizard configuration state
|
|
52
|
-
* @param {object} inquirer - Inquirer instance for prompting
|
|
53
|
-
* @param {object} context - Wizard context with helper methods
|
|
54
|
-
* @param {object} pluginType - Plugin type configuration
|
|
55
|
-
* @returns {Promise<void>}
|
|
56
|
-
*/
|
|
57
|
-
async function selectPluginForType(config, inquirer, context, pluginType) {
|
|
58
|
-
const availablePlugins = context.getAvailablePlugins(pluginType.key);
|
|
59
|
-
|
|
60
|
-
if (availablePlugins.length === 0 && pluginType.required) {
|
|
61
|
-
console.log(
|
|
62
|
-
`⚠️ No ${pluginType.name} plugins available. You'll need to configure this manually.`,
|
|
63
|
-
);
|
|
64
|
-
// eslint-disable-line no-console
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const choices = [
|
|
69
|
-
...availablePlugins.map((plugin) => ({
|
|
70
|
-
name: `${plugin.name} - ${plugin.description}`,
|
|
71
|
-
value: plugin.name,
|
|
72
|
-
short: plugin.name,
|
|
73
|
-
})),
|
|
74
|
-
{ name: "Skip (configure later)", value: null },
|
|
75
|
-
{ name: "Custom plugin", value: "custom" },
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
const answer = await inquirer.prompt([
|
|
79
|
-
{
|
|
80
|
-
_type: "list",
|
|
81
|
-
name: "plugin",
|
|
82
|
-
message: `Select ${pluginType.name}:`,
|
|
83
|
-
choices,
|
|
84
|
-
when: () => !pluginType.required || availablePlugins.length > 0,
|
|
85
|
-
},
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
if (!answer.plugin) {
|
|
89
|
-
return; // Skip
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (answer.plugin === "custom") {
|
|
93
|
-
await configureCustomPlugin(config, inquirer, pluginType.key);
|
|
94
|
-
} else {
|
|
95
|
-
await configureSelectedPlugin(
|
|
96
|
-
config,
|
|
97
|
-
inquirer,
|
|
98
|
-
context,
|
|
99
|
-
pluginType.key,
|
|
100
|
-
answer.plugin,
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Configure a custom plugin
|
|
107
|
-
* @param {object} config - Current wizard configuration state
|
|
108
|
-
* @param {object} inquirer - Inquirer instance for prompting
|
|
109
|
-
* @param {string} pluginType - Plugin type key
|
|
110
|
-
* @returns {Promise<void>}
|
|
111
|
-
*/
|
|
112
|
-
async function configureCustomPlugin(config, inquirer, pluginType) {
|
|
113
|
-
const answers = await inquirer.prompt([
|
|
114
|
-
{
|
|
115
|
-
_type: "input",
|
|
116
|
-
name: "name",
|
|
117
|
-
message: "Plugin name:",
|
|
118
|
-
validate: (input) => input.length > 0 || "Plugin name is required",
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
_type: "list",
|
|
122
|
-
name: "source",
|
|
123
|
-
message: "Plugin source:",
|
|
124
|
-
choices: [
|
|
125
|
-
{ name: "Registry", value: "registry" },
|
|
126
|
-
{ name: "Local file", value: "local" },
|
|
127
|
-
{ name: "Git repository", value: "git" },
|
|
128
|
-
{ name: "NPM package", value: "npm" },
|
|
129
|
-
],
|
|
130
|
-
default: "registry",
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
_type: "input",
|
|
134
|
-
name: "version",
|
|
135
|
-
message: "Version:",
|
|
136
|
-
default: "latest",
|
|
137
|
-
when: (answers) =>
|
|
138
|
-
answers.source === "registry" || answers.source === "npm",
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
_type: "input",
|
|
142
|
-
name: "path",
|
|
143
|
-
message: "Local path:",
|
|
144
|
-
when: (answers) => answers.source === "local",
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
_type: "input",
|
|
148
|
-
name: "url",
|
|
149
|
-
message: "Repository URL:",
|
|
150
|
-
when: (answers) => answers.source === "git",
|
|
151
|
-
},
|
|
152
|
-
]);
|
|
153
|
-
|
|
154
|
-
const pluginSpec = {
|
|
155
|
-
name: answers.name,
|
|
156
|
-
source: answers.source,
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
if (answers.version) pluginSpec.version = answers.version;
|
|
160
|
-
if (answers.path) pluginSpec.path = answers.path;
|
|
161
|
-
if (answers.url) pluginSpec.url = answers.url;
|
|
162
|
-
|
|
163
|
-
config.plugins[pluginType][answers.name] = pluginSpec;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Configure a selected plugin from registry
|
|
168
|
-
* @param {object} config - Current wizard configuration state
|
|
169
|
-
* @param {object} inquirer - Inquirer instance for prompting
|
|
170
|
-
* @param {object} context - Wizard context with helper methods
|
|
171
|
-
* @param {string} pluginType - Plugin type key
|
|
172
|
-
* @param {string} pluginName - Plugin name
|
|
173
|
-
* @returns {Promise<void>}
|
|
174
|
-
*/
|
|
175
|
-
async function configureSelectedPlugin(
|
|
176
|
-
config,
|
|
177
|
-
inquirer,
|
|
178
|
-
context,
|
|
179
|
-
pluginType,
|
|
180
|
-
pluginName,
|
|
181
|
-
) {
|
|
182
|
-
const plugin = context.getPluginInfo(pluginType, pluginName);
|
|
183
|
-
|
|
184
|
-
if (!plugin) {
|
|
185
|
-
config.plugins[pluginType][pluginName] = "latest";
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const versions = Object.keys(plugin.versions || {}).slice(0, 5);
|
|
190
|
-
const versionChoices = [
|
|
191
|
-
{ name: "Latest stable", value: "latest" },
|
|
192
|
-
{ name: "Latest beta", value: "beta" },
|
|
193
|
-
...versions.map((v) => ({ name: v, value: v })),
|
|
194
|
-
{ name: "Custom version", value: "custom" },
|
|
195
|
-
];
|
|
196
|
-
|
|
197
|
-
const versionAnswer = await inquirer.prompt([
|
|
198
|
-
{
|
|
199
|
-
_type: "list",
|
|
200
|
-
name: "version",
|
|
201
|
-
message: `Select version for ${pluginName}:`,
|
|
202
|
-
choices: versionChoices,
|
|
203
|
-
default: "latest",
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
_type: "input",
|
|
207
|
-
name: "customVersion",
|
|
208
|
-
message: "Enter version:",
|
|
209
|
-
when: (answers) => answers.version === "custom",
|
|
210
|
-
},
|
|
211
|
-
]);
|
|
212
|
-
|
|
213
|
-
const version = versionAnswer.customVersion || versionAnswer.version;
|
|
214
|
-
|
|
215
|
-
// Check if plugin needs configuration
|
|
216
|
-
const needsConfig =
|
|
217
|
-
plugin.metadata?._config &&
|
|
218
|
-
Object.keys(plugin.metadata._config.properties || {}).length > 0;
|
|
219
|
-
|
|
220
|
-
if (needsConfig) {
|
|
221
|
-
const configAnswer = await inquirer.prompt([
|
|
222
|
-
{
|
|
223
|
-
_type: "confirm",
|
|
224
|
-
name: "configure",
|
|
225
|
-
message: `Configure ${pluginName} settings?`,
|
|
226
|
-
default: false,
|
|
227
|
-
},
|
|
228
|
-
]);
|
|
229
|
-
|
|
230
|
-
if (configAnswer.configure) {
|
|
231
|
-
const pluginConfig = await configurePluginSettings(plugin, inquirer);
|
|
232
|
-
config.plugins[pluginType][pluginName] = {
|
|
233
|
-
name: pluginName,
|
|
234
|
-
version,
|
|
235
|
-
_config: pluginConfig,
|
|
236
|
-
};
|
|
237
|
-
} else {
|
|
238
|
-
config.plugins[pluginType][pluginName] = {
|
|
239
|
-
name: pluginName,
|
|
240
|
-
version,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
} else {
|
|
244
|
-
config.plugins[pluginType][pluginName] = version;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Configure plugin-specific settings
|
|
250
|
-
* @param {object} plugin - Plugin information
|
|
251
|
-
* @param {object} inquirer - Inquirer instance for prompting
|
|
252
|
-
* @returns {Promise<object>} Plugin configuration
|
|
253
|
-
*/
|
|
254
|
-
async function configurePluginSettings(plugin, inquirer) {
|
|
255
|
-
const _config = {};
|
|
256
|
-
const schema = plugin.metadata?._config?.properties || {};
|
|
257
|
-
|
|
258
|
-
console.log(`\n⚙️ Configuring ${plugin.metadata.name}...\n`);
|
|
259
|
-
// eslint-disable-line no-console
|
|
260
|
-
|
|
261
|
-
for (const [key, property] of Object.entries(schema)) {
|
|
262
|
-
const question = {
|
|
263
|
-
name: key,
|
|
264
|
-
message: `${key}${property.description ? ` (${property.description})` : ""}:`,
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
if (property._type === "boolean") {
|
|
268
|
-
question._type = "confirm";
|
|
269
|
-
question.default = property.default || false;
|
|
270
|
-
} else if (property.enum) {
|
|
271
|
-
question._type = "list";
|
|
272
|
-
question.choices = property.enum;
|
|
273
|
-
question.default = property.default;
|
|
274
|
-
} else if (property._type === "number") {
|
|
275
|
-
question._type = "number";
|
|
276
|
-
question.default = property.default;
|
|
277
|
-
} else {
|
|
278
|
-
question._type = "input";
|
|
279
|
-
question.default = property.default || "";
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const answer = await inquirer.prompt([question]);
|
|
283
|
-
if (answer[key] !== "" && answer[key] !== undefined) {
|
|
284
|
-
_config[key] = answer[key];
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return _config;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
module.exports = {
|
|
292
|
-
selectPlugins,
|
|
293
|
-
selectPluginForType,
|
|
294
|
-
configureCustomPlugin,
|
|
295
|
-
configureSelectedPlugin,
|
|
296
|
-
configurePluginSettings,
|
|
297
|
-
};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Preview and Save Step
|
|
3
|
-
* Handles configuration preview, validation, saving, and testing
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const fs = require("fs/promises");
|
|
7
|
-
const {
|
|
8
|
-
validateRagrc,
|
|
9
|
-
extractPluginDependencies,
|
|
10
|
-
} = require("../../config/enhanced-ragrc-schema.js");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Preview configuration and save
|
|
14
|
-
* @param {object} config - Current wizard configuration state
|
|
15
|
-
* @param {object} inquirer - Inquirer instance for prompting
|
|
16
|
-
* @param {object} options - Wizard options (outputPath, etc.)
|
|
17
|
-
* @returns {Promise<object>} Updated configuration state (possibly normalized)
|
|
18
|
-
*/
|
|
19
|
-
async function previewAndSave(config, inquirer, options) {
|
|
20
|
-
console.log("👀 Configuration Preview\n");
|
|
21
|
-
// eslint-disable-line no-console
|
|
22
|
-
|
|
23
|
-
// Show configuration summary
|
|
24
|
-
showConfigSummary(config);
|
|
25
|
-
|
|
26
|
-
const answers = await inquirer.prompt([
|
|
27
|
-
{
|
|
28
|
-
_type: "confirm",
|
|
29
|
-
name: "save",
|
|
30
|
-
message: "Save this configuration?",
|
|
31
|
-
default: true,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
_type: "input",
|
|
35
|
-
name: "filename",
|
|
36
|
-
message: "Configuration filename:",
|
|
37
|
-
default: options.outputPath,
|
|
38
|
-
when: (answers) => answers.save,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
_type: "confirm",
|
|
42
|
-
name: "testRun",
|
|
43
|
-
message: "Run a test to validate the configuration?",
|
|
44
|
-
default: false,
|
|
45
|
-
when: (answers) => answers.save,
|
|
46
|
-
},
|
|
47
|
-
]);
|
|
48
|
-
|
|
49
|
-
if (!answers.save) {
|
|
50
|
-
console.log("Configuration not saved."); // eslint-disable-line no-console
|
|
51
|
-
return config;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Validate and normalize configuration
|
|
55
|
-
const validation = validateRagrc(config);
|
|
56
|
-
if (!validation.valid) {
|
|
57
|
-
console.error("❌ Configuration validation failed:"); // eslint-disable-line no-console
|
|
58
|
-
validation.errors?.forEach((error) => {
|
|
59
|
-
console.error(` ${error.instancePath}: ${error.message}`); // eslint-disable-line no-console
|
|
60
|
-
});
|
|
61
|
-
throw new Error("Invalid configuration generated");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Use normalized configuration
|
|
65
|
-
const normalizedConfig = validation.normalized;
|
|
66
|
-
|
|
67
|
-
// Save configuration
|
|
68
|
-
await fs.writeFile(
|
|
69
|
-
answers.filename,
|
|
70
|
-
JSON.stringify(normalizedConfig, null, 2),
|
|
71
|
-
"utf-8",
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
options.outputPath = answers.filename;
|
|
75
|
-
|
|
76
|
-
if (answers.testRun) {
|
|
77
|
-
await runConfigurationTest(normalizedConfig);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return normalizedConfig;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Show configuration summary
|
|
85
|
-
* @param {object} config - Configuration to summarize
|
|
86
|
-
*/
|
|
87
|
-
function showConfigSummary(config) {
|
|
88
|
-
console.log("📋 Configuration Summary:");
|
|
89
|
-
// eslint-disable-line no-console
|
|
90
|
-
console.log(` Project: ${config.metadata?.name || "Unnamed"}`);
|
|
91
|
-
// eslint-disable-line no-console
|
|
92
|
-
console.log(
|
|
93
|
-
` Environment: ${config.metadata?.environment || "development"}`,
|
|
94
|
-
);
|
|
95
|
-
// eslint-disable-line no-console
|
|
96
|
-
|
|
97
|
-
console.log("\n🔌 Plugins:");
|
|
98
|
-
// eslint-disable-line no-console
|
|
99
|
-
for (const [_type, plugins] of Object.entries(config.plugins)) {
|
|
100
|
-
if (Object.keys(plugins).length > 0) {
|
|
101
|
-
console.log(` ${_type}: ${Object.keys(plugins).join(", ")}`);
|
|
102
|
-
// eslint-disable-line no-console
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
console.log("\n🔄 Pipeline:");
|
|
107
|
-
// eslint-disable-line no-console
|
|
108
|
-
console.log(
|
|
109
|
-
` Stages: ${config.pipeline?.stages?.join(" → ") || "default"}`,
|
|
110
|
-
);
|
|
111
|
-
// eslint-disable-line no-console
|
|
112
|
-
|
|
113
|
-
if (config.performance?.parallel?.enabled) {
|
|
114
|
-
console.log("\n⚡ Performance:");
|
|
115
|
-
// eslint-disable-line no-console
|
|
116
|
-
console.log(
|
|
117
|
-
` Parallel processing: ${config.performance.parallel.maxConcurrency} concurrent`,
|
|
118
|
-
);
|
|
119
|
-
// eslint-disable-line no-console
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
config.observability?.tracing?.enabled ||
|
|
124
|
-
config.observability?.metrics?.enabled
|
|
125
|
-
) {
|
|
126
|
-
console.log("\n📊 Observability:");
|
|
127
|
-
// eslint-disable-line no-console
|
|
128
|
-
if (config.observability.tracing?.enabled)
|
|
129
|
-
console.log(" Tracing: enabled");
|
|
130
|
-
// eslint-disable-line no-console
|
|
131
|
-
if (config.observability.metrics?.enabled)
|
|
132
|
-
console.log(" Metrics: enabled");
|
|
133
|
-
// eslint-disable-line no-console
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
console.log("");
|
|
137
|
-
// eslint-disable-line no-console
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Run configuration test
|
|
142
|
-
* @param {object} config - Configuration to test
|
|
143
|
-
*/
|
|
144
|
-
async function runConfigurationTest(config) {
|
|
145
|
-
console.log("🧪 Running configuration test...\n");
|
|
146
|
-
// eslint-disable-line no-console
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
// Simulate pipeline creation and basic validation
|
|
150
|
-
console.log("✅ Configuration syntax: valid");
|
|
151
|
-
// eslint-disable-line no-console
|
|
152
|
-
console.log("✅ Plugin dependencies: resolved");
|
|
153
|
-
// eslint-disable-line no-console
|
|
154
|
-
console.log("✅ Pipeline stages: configured");
|
|
155
|
-
// eslint-disable-line no-console
|
|
156
|
-
|
|
157
|
-
// Check for potential issues
|
|
158
|
-
const dependencies = extractPluginDependencies(config);
|
|
159
|
-
if (dependencies.length === 0) {
|
|
160
|
-
console.warn("⚠️ No plugins configured - pipeline will not function");
|
|
161
|
-
// eslint-disable-line no-console
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
console.log("\n🎉 Configuration test passed!");
|
|
165
|
-
// eslint-disable-line no-console
|
|
166
|
-
} catch (error) {
|
|
167
|
-
console.error("❌ Configuration test failed:", error.message);
|
|
168
|
-
// eslint-disable-line no-console
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
module.exports = { previewAndSave, showConfigSummary, runConfigurationTest };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project Setup Step
|
|
3
|
-
* Handles project metadata configuration in the interactive wizard
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const path = require("path");
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Run the project setup step
|
|
10
|
-
* @param {object} config - Current wizard configuration state
|
|
11
|
-
* @param {object} inquirer - Inquirer instance for prompting
|
|
12
|
-
* @returns {Promise<object>} Updated configuration state
|
|
13
|
-
*/
|
|
14
|
-
async function setupProject(config, inquirer) {
|
|
15
|
-
console.log("📋 Project Setup\n");
|
|
16
|
-
// eslint-disable-line no-console
|
|
17
|
-
|
|
18
|
-
const answers = await inquirer.prompt([
|
|
19
|
-
{
|
|
20
|
-
_type: "input",
|
|
21
|
-
name: "name",
|
|
22
|
-
message: "Project name:",
|
|
23
|
-
default: path.basename(process.cwd()),
|
|
24
|
-
validate: (input) => input.length > 0 || "Project name is required",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
_type: "input",
|
|
28
|
-
name: "description",
|
|
29
|
-
message: "Project description:",
|
|
30
|
-
default: "A RAG pipeline project",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
_type: "input",
|
|
34
|
-
name: "author",
|
|
35
|
-
message: "Author:",
|
|
36
|
-
default: "Unknown",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
_type: "list",
|
|
40
|
-
name: "environment",
|
|
41
|
-
message: "Target environment:",
|
|
42
|
-
choices: [
|
|
43
|
-
{ name: "Development", value: "development" },
|
|
44
|
-
{ name: "Production", value: "production" },
|
|
45
|
-
{ name: "Testing", value: "testing" },
|
|
46
|
-
],
|
|
47
|
-
default: "development",
|
|
48
|
-
},
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
config.metadata = {
|
|
52
|
-
name: answers.name,
|
|
53
|
-
version: "1.0.0",
|
|
54
|
-
description: answers.description,
|
|
55
|
-
author: answers.author,
|
|
56
|
-
environment: answers.environment,
|
|
57
|
-
createdAt: new Date().toISOString(),
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
console.log(`\n✅ Project "${answers.name}" configured\n`);
|
|
61
|
-
// eslint-disable-line no-console
|
|
62
|
-
|
|
63
|
-
return config;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = { setupProject };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
async function createPipeline({
|
|
4
|
-
loader,
|
|
5
|
-
embedder,
|
|
6
|
-
retriever,
|
|
7
|
-
reranker,
|
|
8
|
-
llm,
|
|
9
|
-
evaluator,
|
|
10
|
-
} = {}) {
|
|
11
|
-
// Required components check
|
|
12
|
-
const required = ['loader', 'embedder', 'retriever', 'llm'];
|
|
13
|
-
const missing = required.filter(
|
|
14
|
-
(name) => !arguments[0] || !arguments[0][name],
|
|
15
|
-
);
|
|
16
|
-
if (missing.length > 0) {
|
|
17
|
-
throw new Error(`Required components missing: ${missing.join(', ')}`);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
async run(input, { signal } = {}) {
|
|
22
|
-
// Check if signal is already aborted
|
|
23
|
-
if (signal && signal.aborted) {
|
|
24
|
-
throw new Error('Aborted');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Execute pipeline in order
|
|
28
|
-
const docs = await loader.load(input, { signal });
|
|
29
|
-
const embeddings = await embedder.embed(docs, { signal });
|
|
30
|
-
const candidates = await retriever.retrieve(embeddings, { signal });
|
|
31
|
-
|
|
32
|
-
let ranked = candidates;
|
|
33
|
-
if (reranker && typeof reranker.rerank === 'function') {
|
|
34
|
-
ranked = await reranker.rerank(input, candidates, { signal });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const answer = await llm.generate(input, ranked, { signal });
|
|
38
|
-
|
|
39
|
-
let evaluation = null;
|
|
40
|
-
if (evaluator && typeof evaluator.evaluate === 'function') {
|
|
41
|
-
evaluation = await evaluator.evaluate(input, answer, ranked);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
docs,
|
|
46
|
-
embeddings,
|
|
47
|
-
candidates,
|
|
48
|
-
ranked,
|
|
49
|
-
answer,
|
|
50
|
-
evaluation,
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// CJS+ESM interop pattern
|
|
57
|
-
module.exports = createPipeline;
|
|
58
|
-
module.exports.createPipeline = createPipeline;
|
|
59
|
-
module.exports.createRagPipeline = createPipeline; // Alias for backward compatibility
|