@juspay/neurolink 9.36.0 → 9.37.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/CHANGELOG.md +12 -0
- package/dist/auth/errors.d.ts +1 -1
- package/dist/auth/middleware/AuthMiddleware.d.ts +1 -1
- package/dist/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/browser/neurolink.min.js +921 -423
- package/dist/cli/commands/evaluate.d.ts +48 -0
- package/dist/cli/commands/evaluate.js +955 -0
- package/dist/cli/commands/proxy.js +6 -6
- package/dist/cli/parser.js +4 -1
- package/dist/evaluation/BatchEvaluator.d.ts +163 -0
- package/dist/evaluation/BatchEvaluator.js +267 -0
- package/dist/evaluation/EvaluationAggregator.d.ts +272 -0
- package/dist/evaluation/EvaluationAggregator.js +377 -0
- package/dist/evaluation/EvaluatorFactory.d.ts +113 -0
- package/dist/evaluation/EvaluatorFactory.js +280 -0
- package/dist/evaluation/EvaluatorRegistry.d.ts +160 -0
- package/dist/evaluation/EvaluatorRegistry.js +184 -0
- package/dist/evaluation/errors/EvaluationError.d.ts +189 -0
- package/dist/evaluation/errors/EvaluationError.js +206 -0
- package/dist/evaluation/errors/index.d.ts +4 -0
- package/dist/evaluation/errors/index.js +4 -0
- package/dist/evaluation/hooks/index.d.ts +6 -0
- package/dist/evaluation/hooks/index.js +6 -0
- package/dist/evaluation/hooks/langfuseAdapter.d.ts +99 -0
- package/dist/evaluation/hooks/langfuseAdapter.js +172 -0
- package/dist/evaluation/hooks/observabilityHooks.d.ts +129 -0
- package/dist/evaluation/hooks/observabilityHooks.js +181 -0
- package/dist/evaluation/index.d.ts +11 -2
- package/dist/evaluation/index.js +15 -0
- package/dist/evaluation/pipeline/evaluationPipeline.d.ts +114 -0
- package/dist/evaluation/pipeline/evaluationPipeline.js +381 -0
- package/dist/evaluation/pipeline/index.d.ts +8 -0
- package/dist/evaluation/pipeline/index.js +8 -0
- package/dist/evaluation/pipeline/pipelineBuilder.d.ts +126 -0
- package/dist/evaluation/pipeline/pipelineBuilder.js +260 -0
- package/dist/evaluation/pipeline/presets.d.ts +66 -0
- package/dist/evaluation/pipeline/presets.js +224 -0
- package/dist/evaluation/pipeline/strategies/batchStrategy.d.ts +99 -0
- package/dist/evaluation/pipeline/strategies/batchStrategy.js +238 -0
- package/dist/evaluation/pipeline/strategies/index.d.ts +6 -0
- package/dist/evaluation/pipeline/strategies/index.js +6 -0
- package/dist/evaluation/pipeline/strategies/samplingStrategy.d.ts +76 -0
- package/dist/evaluation/pipeline/strategies/samplingStrategy.js +238 -0
- package/dist/evaluation/reporting/index.d.ts +6 -0
- package/dist/evaluation/reporting/index.js +6 -0
- package/dist/evaluation/reporting/metricsCollector.d.ts +147 -0
- package/dist/evaluation/reporting/metricsCollector.js +285 -0
- package/dist/evaluation/reporting/reportGenerator.d.ts +90 -0
- package/dist/evaluation/reporting/reportGenerator.js +374 -0
- package/dist/evaluation/scorers/baseScorer.d.ts +83 -0
- package/dist/evaluation/scorers/baseScorer.js +232 -0
- package/dist/evaluation/scorers/customScorerUtils.d.ts +95 -0
- package/dist/evaluation/scorers/customScorerUtils.js +381 -0
- package/dist/evaluation/scorers/index.d.ts +10 -0
- package/dist/evaluation/scorers/index.js +16 -0
- package/dist/evaluation/scorers/llm/answerRelevancyScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/answerRelevancyScorer.js +99 -0
- package/dist/evaluation/scorers/llm/baseLLMScorer.d.ts +71 -0
- package/dist/evaluation/scorers/llm/baseLLMScorer.js +281 -0
- package/dist/evaluation/scorers/llm/biasDetectionScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/biasDetectionScorer.js +127 -0
- package/dist/evaluation/scorers/llm/contextPrecisionScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/contextPrecisionScorer.js +92 -0
- package/dist/evaluation/scorers/llm/contextRelevancyScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/contextRelevancyScorer.js +107 -0
- package/dist/evaluation/scorers/llm/faithfulnessScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/faithfulnessScorer.js +121 -0
- package/dist/evaluation/scorers/llm/hallucinationScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/hallucinationScorer.js +140 -0
- package/dist/evaluation/scorers/llm/index.d.ts +15 -0
- package/dist/evaluation/scorers/llm/index.js +16 -0
- package/dist/evaluation/scorers/llm/promptAlignmentScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/promptAlignmentScorer.js +106 -0
- package/dist/evaluation/scorers/llm/summarizationScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/summarizationScorer.js +114 -0
- package/dist/evaluation/scorers/llm/toneConsistencyScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/toneConsistencyScorer.js +106 -0
- package/dist/evaluation/scorers/llm/toxicityScorer.d.ts +12 -0
- package/dist/evaluation/scorers/llm/toxicityScorer.js +121 -0
- package/dist/evaluation/scorers/rule/baseRuleScorer.d.ts +77 -0
- package/dist/evaluation/scorers/rule/baseRuleScorer.js +233 -0
- package/dist/evaluation/scorers/rule/contentSimilarityScorer.d.ts +108 -0
- package/dist/evaluation/scorers/rule/contentSimilarityScorer.js +350 -0
- package/dist/evaluation/scorers/rule/formatScorer.d.ts +147 -0
- package/dist/evaluation/scorers/rule/formatScorer.js +470 -0
- package/dist/evaluation/scorers/rule/index.d.ts +9 -0
- package/dist/evaluation/scorers/rule/index.js +10 -0
- package/dist/evaluation/scorers/rule/keywordCoverageScorer.d.ts +83 -0
- package/dist/evaluation/scorers/rule/keywordCoverageScorer.js +347 -0
- package/dist/evaluation/scorers/rule/lengthScorer.d.ts +105 -0
- package/dist/evaluation/scorers/rule/lengthScorer.js +351 -0
- package/dist/evaluation/scorers/scorerBuilder.d.ts +161 -0
- package/dist/evaluation/scorers/scorerBuilder.js +420 -0
- package/dist/evaluation/scorers/scorerRegistry.d.ts +62 -0
- package/dist/evaluation/scorers/scorerRegistry.js +467 -0
- package/dist/index.d.ts +37 -25
- package/dist/index.js +65 -26
- package/dist/lib/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/lib/evaluation/BatchEvaluator.d.ts +163 -0
- package/dist/lib/evaluation/BatchEvaluator.js +268 -0
- package/dist/lib/evaluation/EvaluationAggregator.d.ts +272 -0
- package/dist/lib/evaluation/EvaluationAggregator.js +378 -0
- package/dist/lib/evaluation/EvaluatorFactory.d.ts +113 -0
- package/dist/lib/evaluation/EvaluatorFactory.js +281 -0
- package/dist/lib/evaluation/EvaluatorRegistry.d.ts +160 -0
- package/dist/lib/evaluation/EvaluatorRegistry.js +185 -0
- package/dist/lib/evaluation/errors/EvaluationError.d.ts +189 -0
- package/dist/lib/evaluation/errors/EvaluationError.js +207 -0
- package/dist/lib/evaluation/errors/index.d.ts +4 -0
- package/dist/lib/evaluation/errors/index.js +5 -0
- package/dist/lib/evaluation/hooks/index.d.ts +6 -0
- package/dist/lib/evaluation/hooks/index.js +7 -0
- package/dist/lib/evaluation/hooks/langfuseAdapter.d.ts +99 -0
- package/dist/lib/evaluation/hooks/langfuseAdapter.js +173 -0
- package/dist/lib/evaluation/hooks/observabilityHooks.d.ts +129 -0
- package/dist/lib/evaluation/hooks/observabilityHooks.js +182 -0
- package/dist/lib/evaluation/index.d.ts +11 -2
- package/dist/lib/evaluation/index.js +15 -0
- package/dist/lib/evaluation/pipeline/evaluationPipeline.d.ts +114 -0
- package/dist/lib/evaluation/pipeline/evaluationPipeline.js +382 -0
- package/dist/lib/evaluation/pipeline/index.d.ts +8 -0
- package/dist/lib/evaluation/pipeline/index.js +9 -0
- package/dist/lib/evaluation/pipeline/pipelineBuilder.d.ts +126 -0
- package/dist/lib/evaluation/pipeline/pipelineBuilder.js +261 -0
- package/dist/lib/evaluation/pipeline/presets.d.ts +66 -0
- package/dist/lib/evaluation/pipeline/presets.js +225 -0
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.d.ts +99 -0
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +239 -0
- package/dist/lib/evaluation/pipeline/strategies/index.d.ts +6 -0
- package/dist/lib/evaluation/pipeline/strategies/index.js +7 -0
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.d.ts +76 -0
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.js +239 -0
- package/dist/lib/evaluation/reporting/index.d.ts +6 -0
- package/dist/lib/evaluation/reporting/index.js +7 -0
- package/dist/lib/evaluation/reporting/metricsCollector.d.ts +147 -0
- package/dist/lib/evaluation/reporting/metricsCollector.js +286 -0
- package/dist/lib/evaluation/reporting/reportGenerator.d.ts +90 -0
- package/dist/lib/evaluation/reporting/reportGenerator.js +375 -0
- package/dist/lib/evaluation/scorers/baseScorer.d.ts +83 -0
- package/dist/lib/evaluation/scorers/baseScorer.js +233 -0
- package/dist/lib/evaluation/scorers/customScorerUtils.d.ts +95 -0
- package/dist/lib/evaluation/scorers/customScorerUtils.js +382 -0
- package/dist/lib/evaluation/scorers/index.d.ts +10 -0
- package/dist/lib/evaluation/scorers/index.js +17 -0
- package/dist/lib/evaluation/scorers/llm/answerRelevancyScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/answerRelevancyScorer.js +100 -0
- package/dist/lib/evaluation/scorers/llm/baseLLMScorer.d.ts +71 -0
- package/dist/lib/evaluation/scorers/llm/baseLLMScorer.js +282 -0
- package/dist/lib/evaluation/scorers/llm/biasDetectionScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/biasDetectionScorer.js +128 -0
- package/dist/lib/evaluation/scorers/llm/contextPrecisionScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/contextPrecisionScorer.js +93 -0
- package/dist/lib/evaluation/scorers/llm/contextRelevancyScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/contextRelevancyScorer.js +108 -0
- package/dist/lib/evaluation/scorers/llm/faithfulnessScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/faithfulnessScorer.js +122 -0
- package/dist/lib/evaluation/scorers/llm/hallucinationScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/hallucinationScorer.js +141 -0
- package/dist/lib/evaluation/scorers/llm/index.d.ts +15 -0
- package/dist/lib/evaluation/scorers/llm/index.js +17 -0
- package/dist/lib/evaluation/scorers/llm/promptAlignmentScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/promptAlignmentScorer.js +107 -0
- package/dist/lib/evaluation/scorers/llm/summarizationScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/summarizationScorer.js +115 -0
- package/dist/lib/evaluation/scorers/llm/toneConsistencyScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/toneConsistencyScorer.js +107 -0
- package/dist/lib/evaluation/scorers/llm/toxicityScorer.d.ts +12 -0
- package/dist/lib/evaluation/scorers/llm/toxicityScorer.js +122 -0
- package/dist/lib/evaluation/scorers/rule/baseRuleScorer.d.ts +77 -0
- package/dist/lib/evaluation/scorers/rule/baseRuleScorer.js +234 -0
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.d.ts +108 -0
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.js +351 -0
- package/dist/lib/evaluation/scorers/rule/formatScorer.d.ts +147 -0
- package/dist/lib/evaluation/scorers/rule/formatScorer.js +471 -0
- package/dist/lib/evaluation/scorers/rule/index.d.ts +9 -0
- package/dist/lib/evaluation/scorers/rule/index.js +11 -0
- package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.d.ts +83 -0
- package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.js +348 -0
- package/dist/lib/evaluation/scorers/rule/lengthScorer.d.ts +105 -0
- package/dist/lib/evaluation/scorers/rule/lengthScorer.js +352 -0
- package/dist/lib/evaluation/scorers/scorerBuilder.d.ts +161 -0
- package/dist/lib/evaluation/scorers/scorerBuilder.js +421 -0
- package/dist/lib/evaluation/scorers/scorerRegistry.d.ts +62 -0
- package/dist/lib/evaluation/scorers/scorerRegistry.js +468 -0
- package/dist/lib/index.d.ts +37 -25
- package/dist/lib/index.js +65 -26
- package/dist/lib/neurolink.d.ts +204 -0
- package/dist/lib/neurolink.js +296 -0
- package/dist/lib/types/index.d.ts +3 -1
- package/dist/lib/types/index.js +3 -2
- package/dist/lib/types/scorerTypes.d.ts +423 -0
- package/dist/lib/types/scorerTypes.js +6 -0
- package/dist/lib/utils/errorHandling.d.ts +20 -0
- package/dist/lib/utils/errorHandling.js +60 -0
- package/dist/neurolink.d.ts +204 -0
- package/dist/neurolink.js +296 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +3 -2
- package/dist/types/scorerTypes.d.ts +423 -0
- package/dist/types/scorerTypes.js +5 -0
- package/dist/utils/errorHandling.d.ts +20 -0
- package/dist/utils/errorHandling.js +60 -0
- package/package.json +1 -1
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Scorer registry for managing scorer registration and discovery
|
|
3
|
+
* Follows NeuroLink's factory + registry pattern with dynamic imports
|
|
4
|
+
*/
|
|
5
|
+
import { logger } from "../../utils/logger.js";
|
|
6
|
+
/**
|
|
7
|
+
* Central registry for all scorers
|
|
8
|
+
* Manages registration, discovery, and instantiation
|
|
9
|
+
*/
|
|
10
|
+
export class ScorerRegistry {
|
|
11
|
+
static scorers = new Map();
|
|
12
|
+
static initialized = false;
|
|
13
|
+
static initPromise = null;
|
|
14
|
+
/**
|
|
15
|
+
* Register a scorer with the registry
|
|
16
|
+
*/
|
|
17
|
+
static register(entry) {
|
|
18
|
+
const { metadata } = entry;
|
|
19
|
+
const normalizedId = metadata.id.toLowerCase();
|
|
20
|
+
if (ScorerRegistry.scorers.has(normalizedId)) {
|
|
21
|
+
logger.warn(`Scorer ${metadata.id} already registered, overwriting`);
|
|
22
|
+
}
|
|
23
|
+
ScorerRegistry.scorers.set(normalizedId, entry);
|
|
24
|
+
// Register aliases
|
|
25
|
+
if (entry.aliases) {
|
|
26
|
+
for (const alias of entry.aliases) {
|
|
27
|
+
ScorerRegistry.scorers.set(alias.toLowerCase(), entry);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
logger.debug(`Scorer registered: ${metadata.id}`, {
|
|
31
|
+
name: metadata.name,
|
|
32
|
+
type: metadata.type,
|
|
33
|
+
category: metadata.category,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Register a scorer using a simple configuration
|
|
38
|
+
*/
|
|
39
|
+
static registerScorer(metadata, factory, aliases = []) {
|
|
40
|
+
ScorerRegistry.register({
|
|
41
|
+
metadata,
|
|
42
|
+
factory,
|
|
43
|
+
defaultConfig: metadata.defaultConfig,
|
|
44
|
+
aliases,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Register built-in scorers using dynamic imports
|
|
49
|
+
*/
|
|
50
|
+
static async registerBuiltInScorers() {
|
|
51
|
+
if (ScorerRegistry.initialized) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (ScorerRegistry.initPromise) {
|
|
55
|
+
return ScorerRegistry.initPromise;
|
|
56
|
+
}
|
|
57
|
+
ScorerRegistry.initPromise = (async () => {
|
|
58
|
+
try {
|
|
59
|
+
// Register LLM-based scorers with dynamic imports
|
|
60
|
+
ScorerRegistry.registerScorer({
|
|
61
|
+
id: "hallucination",
|
|
62
|
+
name: "Hallucination Detection",
|
|
63
|
+
description: "Detects factual errors, fabrications, and unsupported claims in responses",
|
|
64
|
+
type: "llm",
|
|
65
|
+
category: "accuracy",
|
|
66
|
+
version: "1.0.0",
|
|
67
|
+
defaultConfig: {
|
|
68
|
+
enabled: true,
|
|
69
|
+
threshold: 0.8,
|
|
70
|
+
weight: 1.5,
|
|
71
|
+
timeout: 30000,
|
|
72
|
+
retries: 2,
|
|
73
|
+
},
|
|
74
|
+
requiredInputs: ["query", "response"],
|
|
75
|
+
optionalInputs: ["context", "groundTruth"],
|
|
76
|
+
}, async (config) => {
|
|
77
|
+
const { HallucinationScorer } = await import("./llm/hallucinationScorer.js");
|
|
78
|
+
return new HallucinationScorer(config);
|
|
79
|
+
}, ["hallucination-detection", "hallucinations"]);
|
|
80
|
+
ScorerRegistry.registerScorer({
|
|
81
|
+
id: "toxicity",
|
|
82
|
+
name: "Toxicity Analysis",
|
|
83
|
+
description: "Detects harmful, offensive, or inappropriate content in responses",
|
|
84
|
+
type: "llm",
|
|
85
|
+
category: "safety",
|
|
86
|
+
version: "1.0.0",
|
|
87
|
+
defaultConfig: {
|
|
88
|
+
enabled: true,
|
|
89
|
+
threshold: 0.9,
|
|
90
|
+
weight: 2.0,
|
|
91
|
+
timeout: 20000,
|
|
92
|
+
retries: 1,
|
|
93
|
+
},
|
|
94
|
+
requiredInputs: ["response"],
|
|
95
|
+
optionalInputs: ["query"],
|
|
96
|
+
}, async (config) => {
|
|
97
|
+
const { ToxicityScorer } = await import("./llm/toxicityScorer.js");
|
|
98
|
+
return new ToxicityScorer(config);
|
|
99
|
+
}, ["toxic", "safety"]);
|
|
100
|
+
ScorerRegistry.registerScorer({
|
|
101
|
+
id: "faithfulness",
|
|
102
|
+
name: "Faithfulness",
|
|
103
|
+
description: "Evaluates if the response is faithfully grounded in provided context",
|
|
104
|
+
type: "llm",
|
|
105
|
+
category: "faithfulness",
|
|
106
|
+
version: "1.0.0",
|
|
107
|
+
defaultConfig: {
|
|
108
|
+
enabled: true,
|
|
109
|
+
threshold: 0.7,
|
|
110
|
+
weight: 1.2,
|
|
111
|
+
timeout: 30000,
|
|
112
|
+
retries: 2,
|
|
113
|
+
},
|
|
114
|
+
requiredInputs: ["response", "context"],
|
|
115
|
+
optionalInputs: ["query"],
|
|
116
|
+
}, async (config) => {
|
|
117
|
+
const { FaithfulnessScorer } = await import("./llm/faithfulnessScorer.js");
|
|
118
|
+
return new FaithfulnessScorer(config);
|
|
119
|
+
}, ["faithful", "grounding"]);
|
|
120
|
+
ScorerRegistry.registerScorer({
|
|
121
|
+
id: "context-relevancy",
|
|
122
|
+
name: "Context Relevancy",
|
|
123
|
+
description: "Evaluates how relevant the retrieved context is to the user query",
|
|
124
|
+
type: "llm",
|
|
125
|
+
category: "relevancy",
|
|
126
|
+
version: "1.0.0",
|
|
127
|
+
defaultConfig: {
|
|
128
|
+
enabled: true,
|
|
129
|
+
threshold: 0.6,
|
|
130
|
+
weight: 1.0,
|
|
131
|
+
timeout: 25000,
|
|
132
|
+
retries: 2,
|
|
133
|
+
},
|
|
134
|
+
requiredInputs: ["query", "context"],
|
|
135
|
+
optionalInputs: ["response"],
|
|
136
|
+
}, async (config) => {
|
|
137
|
+
const { ContextRelevancyScorer } = await import("./llm/contextRelevancyScorer.js");
|
|
138
|
+
return new ContextRelevancyScorer(config);
|
|
139
|
+
}, ["context-relevance"]);
|
|
140
|
+
ScorerRegistry.registerScorer({
|
|
141
|
+
id: "answer-relevancy",
|
|
142
|
+
name: "Answer Relevancy",
|
|
143
|
+
description: "Evaluates how relevant the AI response is to the user query",
|
|
144
|
+
type: "llm",
|
|
145
|
+
category: "relevancy",
|
|
146
|
+
version: "1.0.0",
|
|
147
|
+
defaultConfig: {
|
|
148
|
+
enabled: true,
|
|
149
|
+
threshold: 0.7,
|
|
150
|
+
weight: 1.0,
|
|
151
|
+
timeout: 25000,
|
|
152
|
+
retries: 2,
|
|
153
|
+
},
|
|
154
|
+
requiredInputs: ["query", "response"],
|
|
155
|
+
optionalInputs: ["context"],
|
|
156
|
+
}, async (config) => {
|
|
157
|
+
const { AnswerRelevancyScorer } = await import("./llm/answerRelevancyScorer.js");
|
|
158
|
+
return new AnswerRelevancyScorer(config);
|
|
159
|
+
}, ["response-relevancy", "relevancy"]);
|
|
160
|
+
ScorerRegistry.registerScorer({
|
|
161
|
+
id: "context-precision",
|
|
162
|
+
name: "Context Precision",
|
|
163
|
+
description: "Measures the precision of retrieved context - whether relevant chunks are ranked higher",
|
|
164
|
+
type: "llm",
|
|
165
|
+
category: "relevancy",
|
|
166
|
+
version: "1.0.0",
|
|
167
|
+
defaultConfig: {
|
|
168
|
+
enabled: true,
|
|
169
|
+
threshold: 0.6,
|
|
170
|
+
weight: 0.8,
|
|
171
|
+
timeout: 25000,
|
|
172
|
+
retries: 2,
|
|
173
|
+
},
|
|
174
|
+
requiredInputs: ["query", "context"],
|
|
175
|
+
optionalInputs: ["groundTruth"],
|
|
176
|
+
}, async (config) => {
|
|
177
|
+
const { ContextPrecisionScorer } = await import("./llm/contextPrecisionScorer.js");
|
|
178
|
+
return new ContextPrecisionScorer(config);
|
|
179
|
+
}, ["precision"]);
|
|
180
|
+
ScorerRegistry.registerScorer({
|
|
181
|
+
id: "bias-detection",
|
|
182
|
+
name: "Bias Detection",
|
|
183
|
+
description: "Identifies potential biases in AI responses",
|
|
184
|
+
type: "llm",
|
|
185
|
+
category: "safety",
|
|
186
|
+
version: "1.0.0",
|
|
187
|
+
defaultConfig: {
|
|
188
|
+
enabled: true,
|
|
189
|
+
threshold: 0.8,
|
|
190
|
+
weight: 1.0,
|
|
191
|
+
timeout: 25000,
|
|
192
|
+
retries: 2,
|
|
193
|
+
},
|
|
194
|
+
requiredInputs: ["response"],
|
|
195
|
+
optionalInputs: ["query", "context"],
|
|
196
|
+
}, async (config) => {
|
|
197
|
+
const { BiasDetectionScorer } = await import("./llm/biasDetectionScorer.js");
|
|
198
|
+
return new BiasDetectionScorer(config);
|
|
199
|
+
}, ["bias", "fairness"]);
|
|
200
|
+
ScorerRegistry.registerScorer({
|
|
201
|
+
id: "tone-consistency",
|
|
202
|
+
name: "Tone Consistency",
|
|
203
|
+
description: "Checks for consistent tone throughout the response",
|
|
204
|
+
type: "llm",
|
|
205
|
+
category: "quality",
|
|
206
|
+
version: "1.0.0",
|
|
207
|
+
defaultConfig: {
|
|
208
|
+
enabled: true,
|
|
209
|
+
threshold: 0.7,
|
|
210
|
+
weight: 0.8,
|
|
211
|
+
timeout: 20000,
|
|
212
|
+
retries: 1,
|
|
213
|
+
},
|
|
214
|
+
requiredInputs: ["response"],
|
|
215
|
+
optionalInputs: ["query"],
|
|
216
|
+
}, async (config) => {
|
|
217
|
+
const { ToneConsistencyScorer } = await import("./llm/toneConsistencyScorer.js");
|
|
218
|
+
return new ToneConsistencyScorer(config);
|
|
219
|
+
}, ["tone"]);
|
|
220
|
+
ScorerRegistry.registerScorer({
|
|
221
|
+
id: "prompt-alignment",
|
|
222
|
+
name: "Prompt Alignment",
|
|
223
|
+
description: "Measures how well the response aligns with prompt instructions",
|
|
224
|
+
type: "llm",
|
|
225
|
+
category: "quality",
|
|
226
|
+
version: "1.0.0",
|
|
227
|
+
defaultConfig: {
|
|
228
|
+
enabled: true,
|
|
229
|
+
threshold: 0.7,
|
|
230
|
+
weight: 1.0,
|
|
231
|
+
timeout: 25000,
|
|
232
|
+
retries: 2,
|
|
233
|
+
},
|
|
234
|
+
requiredInputs: ["query", "response"],
|
|
235
|
+
optionalInputs: [],
|
|
236
|
+
}, async (config) => {
|
|
237
|
+
const { PromptAlignmentScorer } = await import("./llm/promptAlignmentScorer.js");
|
|
238
|
+
return new PromptAlignmentScorer(config);
|
|
239
|
+
}, ["alignment", "instruction-following"]);
|
|
240
|
+
ScorerRegistry.registerScorer({
|
|
241
|
+
id: "summarization",
|
|
242
|
+
name: "Summarization Quality",
|
|
243
|
+
description: "Evaluates the quality of AI-generated summaries",
|
|
244
|
+
type: "llm",
|
|
245
|
+
category: "quality",
|
|
246
|
+
version: "1.0.0",
|
|
247
|
+
defaultConfig: {
|
|
248
|
+
enabled: true,
|
|
249
|
+
threshold: 0.7,
|
|
250
|
+
weight: 1.0,
|
|
251
|
+
timeout: 25000,
|
|
252
|
+
retries: 2,
|
|
253
|
+
},
|
|
254
|
+
requiredInputs: ["response", "context"],
|
|
255
|
+
optionalInputs: ["query"],
|
|
256
|
+
}, async (config) => {
|
|
257
|
+
const { SummarizationScorer } = await import("./llm/summarizationScorer.js");
|
|
258
|
+
return new SummarizationScorer(config);
|
|
259
|
+
}, ["summary"]);
|
|
260
|
+
// Register rule-based scorers
|
|
261
|
+
ScorerRegistry.registerScorer({
|
|
262
|
+
id: "keyword-coverage",
|
|
263
|
+
name: "Keyword Coverage",
|
|
264
|
+
description: "Checks if response covers expected keywords and concepts",
|
|
265
|
+
type: "rule",
|
|
266
|
+
category: "quality",
|
|
267
|
+
version: "1.0.0",
|
|
268
|
+
defaultConfig: {
|
|
269
|
+
enabled: true,
|
|
270
|
+
threshold: 0.6,
|
|
271
|
+
weight: 0.8,
|
|
272
|
+
timeout: 1000,
|
|
273
|
+
retries: 0,
|
|
274
|
+
},
|
|
275
|
+
requiredInputs: ["response"],
|
|
276
|
+
optionalInputs: ["query", "custom"],
|
|
277
|
+
}, async (config) => {
|
|
278
|
+
const { KeywordCoverageScorer } = await import("./rule/keywordCoverageScorer.js");
|
|
279
|
+
return new KeywordCoverageScorer(config);
|
|
280
|
+
}, ["keywords"]);
|
|
281
|
+
ScorerRegistry.registerScorer({
|
|
282
|
+
id: "content-similarity",
|
|
283
|
+
name: "Content Similarity",
|
|
284
|
+
description: "Measures text similarity between response and reference",
|
|
285
|
+
type: "rule",
|
|
286
|
+
category: "accuracy",
|
|
287
|
+
version: "1.0.0",
|
|
288
|
+
defaultConfig: {
|
|
289
|
+
enabled: true,
|
|
290
|
+
threshold: 0.5,
|
|
291
|
+
weight: 1.0,
|
|
292
|
+
timeout: 2000,
|
|
293
|
+
retries: 0,
|
|
294
|
+
},
|
|
295
|
+
requiredInputs: ["response", "groundTruth"],
|
|
296
|
+
optionalInputs: [],
|
|
297
|
+
}, async (config) => {
|
|
298
|
+
const { ContentSimilarityScorer } = await import("./rule/contentSimilarityScorer.js");
|
|
299
|
+
return new ContentSimilarityScorer(config);
|
|
300
|
+
}, ["similarity", "text-similarity"]);
|
|
301
|
+
ScorerRegistry.registerScorer({
|
|
302
|
+
id: "length",
|
|
303
|
+
name: "Response Length",
|
|
304
|
+
description: "Validates response length against configured bounds",
|
|
305
|
+
type: "rule",
|
|
306
|
+
category: "quality",
|
|
307
|
+
version: "1.0.0",
|
|
308
|
+
defaultConfig: {
|
|
309
|
+
enabled: true,
|
|
310
|
+
threshold: 0.8,
|
|
311
|
+
weight: 0.5,
|
|
312
|
+
timeout: 100,
|
|
313
|
+
retries: 0,
|
|
314
|
+
},
|
|
315
|
+
requiredInputs: ["response"],
|
|
316
|
+
optionalInputs: [],
|
|
317
|
+
}, async (config) => {
|
|
318
|
+
const { LengthScorer } = await import("./rule/lengthScorer.js");
|
|
319
|
+
return new LengthScorer(config);
|
|
320
|
+
}, ["response-length"]);
|
|
321
|
+
ScorerRegistry.registerScorer({
|
|
322
|
+
id: "format",
|
|
323
|
+
name: "Format Validation",
|
|
324
|
+
description: "Checks if response follows expected formatting requirements",
|
|
325
|
+
type: "rule",
|
|
326
|
+
category: "quality",
|
|
327
|
+
version: "1.0.0",
|
|
328
|
+
defaultConfig: {
|
|
329
|
+
enabled: true,
|
|
330
|
+
threshold: 0.8,
|
|
331
|
+
weight: 0.5,
|
|
332
|
+
timeout: 100,
|
|
333
|
+
retries: 0,
|
|
334
|
+
},
|
|
335
|
+
requiredInputs: ["response"],
|
|
336
|
+
optionalInputs: ["custom"],
|
|
337
|
+
}, async (config) => {
|
|
338
|
+
const { FormatScorer } = await import("./rule/formatScorer.js");
|
|
339
|
+
return new FormatScorer(config);
|
|
340
|
+
}, ["formatting"]);
|
|
341
|
+
ScorerRegistry.initialized = true;
|
|
342
|
+
logger.debug(`Registered ${ScorerRegistry.scorers.size} built-in scorers (including aliases)`);
|
|
343
|
+
}
|
|
344
|
+
finally {
|
|
345
|
+
// Keep initPromise for future callers to await
|
|
346
|
+
}
|
|
347
|
+
})();
|
|
348
|
+
return ScorerRegistry.initPromise;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Get a scorer instance by ID
|
|
352
|
+
*/
|
|
353
|
+
static async getScorer(scorerId, config) {
|
|
354
|
+
await ScorerRegistry.ensureInitialized();
|
|
355
|
+
const normalizedId = scorerId.toLowerCase();
|
|
356
|
+
const entry = ScorerRegistry.scorers.get(normalizedId);
|
|
357
|
+
if (!entry) {
|
|
358
|
+
logger.warn(`Scorer not found: ${scorerId}`);
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
// Merge configurations
|
|
362
|
+
const mergedConfig = {
|
|
363
|
+
...entry.defaultConfig,
|
|
364
|
+
...config,
|
|
365
|
+
};
|
|
366
|
+
return entry.factory(mergedConfig);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Get scorers by category
|
|
370
|
+
*/
|
|
371
|
+
static getScorersByCategory(category) {
|
|
372
|
+
const results = [];
|
|
373
|
+
const seen = new Set();
|
|
374
|
+
for (const entry of ScorerRegistry.scorers.values()) {
|
|
375
|
+
if (entry.metadata.category === category &&
|
|
376
|
+
!seen.has(entry.metadata.id)) {
|
|
377
|
+
results.push(entry);
|
|
378
|
+
seen.add(entry.metadata.id);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return results;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Get scorers by type
|
|
385
|
+
*/
|
|
386
|
+
static getScorersByType(type) {
|
|
387
|
+
const results = [];
|
|
388
|
+
const seen = new Set();
|
|
389
|
+
for (const entry of ScorerRegistry.scorers.values()) {
|
|
390
|
+
if (entry.metadata.type === type && !seen.has(entry.metadata.id)) {
|
|
391
|
+
results.push(entry);
|
|
392
|
+
seen.add(entry.metadata.id);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return results;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* List all registered scorer metadata
|
|
399
|
+
*/
|
|
400
|
+
static list() {
|
|
401
|
+
const results = [];
|
|
402
|
+
const seen = new Set();
|
|
403
|
+
for (const entry of ScorerRegistry.scorers.values()) {
|
|
404
|
+
if (!seen.has(entry.metadata.id)) {
|
|
405
|
+
results.push(entry.metadata);
|
|
406
|
+
seen.add(entry.metadata.id);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return results;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Check if a scorer is registered
|
|
413
|
+
*/
|
|
414
|
+
static has(scorerId) {
|
|
415
|
+
return ScorerRegistry.scorers.has(scorerId.toLowerCase());
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Unregister a scorer
|
|
419
|
+
*/
|
|
420
|
+
static unregister(scorerId) {
|
|
421
|
+
const normalizedId = scorerId.toLowerCase();
|
|
422
|
+
const entry = ScorerRegistry.scorers.get(normalizedId);
|
|
423
|
+
if (!entry) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
// Remove main entry
|
|
427
|
+
ScorerRegistry.scorers.delete(normalizedId);
|
|
428
|
+
// Remove aliases
|
|
429
|
+
if (entry.aliases) {
|
|
430
|
+
for (const alias of entry.aliases) {
|
|
431
|
+
ScorerRegistry.scorers.delete(alias.toLowerCase());
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
logger.debug(`Scorer unregistered: ${scorerId}`);
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Clear all registered scorers
|
|
439
|
+
*/
|
|
440
|
+
static clear() {
|
|
441
|
+
ScorerRegistry.scorers.clear();
|
|
442
|
+
ScorerRegistry.initialized = false;
|
|
443
|
+
ScorerRegistry.initPromise = null;
|
|
444
|
+
logger.debug("Scorer registry cleared");
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Ensure built-in scorers are initialized
|
|
448
|
+
*/
|
|
449
|
+
static async ensureInitialized() {
|
|
450
|
+
if (!ScorerRegistry.initialized) {
|
|
451
|
+
await ScorerRegistry.registerBuiltInScorers();
|
|
452
|
+
}
|
|
453
|
+
if (ScorerRegistry.initPromise) {
|
|
454
|
+
await ScorerRegistry.initPromise;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Get the number of registered scorers (excluding aliases)
|
|
459
|
+
*/
|
|
460
|
+
static get size() {
|
|
461
|
+
const seen = new Set();
|
|
462
|
+
for (const entry of ScorerRegistry.scorers.values()) {
|
|
463
|
+
seen.add(entry.metadata.id);
|
|
464
|
+
}
|
|
465
|
+
return seen.size;
|
|
466
|
+
}
|
|
467
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ import { AIProviderFactory } from "./core/factory.js";
|
|
|
35
35
|
export { AIProviderFactory };
|
|
36
36
|
export { GoogleTTSHandler } from "./adapters/tts/googleTTSHandler.js";
|
|
37
37
|
export { NeuroLinkConfigManager as ConfigManager } from "./config/configManager.js";
|
|
38
|
+
export { BaseFactory, BaseRegistry, NeuroLinkFeatureError, createErrorFactory, withRetry, TypedEventEmitter, } from "./core/infrastructure/index.js";
|
|
39
|
+
export type { ErrorCode, FactoryFunction, FactoryRegistration, RegistryEntry as CoreRegistryEntry, RetryOptions, } from "./core/infrastructure/index.js";
|
|
38
40
|
export { NeuroLinkClient, createClient, NeuroLinkApiError, NeuroLinkLanguageModel, NeuroLinkAIProvider, createNeuroLinkProvider, createNeuroLinkModel, createStreamingResponse, neurolink as neuroLinkAIInstance, createApiKeyAuthInterceptor, createBearerAuthInterceptor, createDynamicAuthInterceptor, createLoggingInterceptor, createRetryInterceptor, createRateLimitInterceptor, createRequestTransformInterceptor, createResponseTransformInterceptor, createCacheInterceptor, createTimeoutInterceptor, createErrorHandlerInterceptor, composeMiddleware, conditionalMiddleware, SSEClient, WebSocketStreamingClient, createStreamingClient, createAsyncStream, collectStream, OAuth2TokenManager, JWTTokenManager, createApiKeyMiddleware, createBearerTokenMiddleware, createTokenManagerMiddleware, createAuthWithRetryMiddleware, createMultiAuthMiddleware, OAuth2Error, OAuth2AuthError, TokenRefreshError, decodeJWTPayload, isJWTExpired, getJWTExpiry, getApiKeyFromEnv, ErrorCode as ClientErrorCode, NeuroLinkError as ClientNeuroLinkError, HttpError, ClientRateLimitError, ClientValidationError, ClientAuthenticationError, ClientAuthorizationError, NotFoundError, ClientNetworkError, ClientTimeoutError, ClientConnectionError, AbortError, ClientConfigurationError, StreamError, ClientProviderError, ContextLengthError, ContentFilterError, createErrorFromResponse, createErrorFromNative, mapStatusToErrorCode, isRetryableStatus, isRetryableError, isNeuroLinkError, isApiError, } from "./client/index.js";
|
|
39
41
|
export type { ClientConfig, RequestOptions, ApiResponse, ApiError, RetryConfig, Middleware as ClientMiddleware, MiddlewareRequest, MiddlewareResponse, MiddlewareContext as ClientMiddlewareContext, StreamCallbacks, StreamEvent, StreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo as ClientToolInfo, ProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler, NeuroLinkProviderOptions, ModelOptions, LanguageModel, LanguageModelCallOptions, LanguageModelResponse, LanguageModelStreamResponse, LoggingInterceptorOptions, RetryInterceptorOptions, RateLimiterOptions, CacheInterceptorOptions, TimeoutInterceptorOptions, ErrorHandlerOptions, SSEConnectionOptions, SSEConnectionState, StreamingRequestOptions, StreamingEventEmitter, StreamingClientConfig, SpeechRecognitionResult, SpeechSynthesisOptions, AuthConfig as ClientAuthConfig, OAuth2Config, TokenRefreshResult, ErrorCodeType, } from "./client/index.js";
|
|
40
42
|
export { AIProviderName, BedrockModels, OpenAIModels, VertexModels, } from "./constants/enums.js";
|
|
@@ -204,7 +206,7 @@ export declare function createBestAIProvider(requestedProvider?: string, modelNa
|
|
|
204
206
|
* ```
|
|
205
207
|
*/
|
|
206
208
|
export { CircuitBreakerManager, calculateExpiresAt, createMCPServer, createOAuthProviderFromConfig, DEFAULT_HTTP_RETRY_CONFIG, DEFAULT_RATE_LIMIT_CONFIG, executeMCP, FileTokenStorage, getMCPStats, getServerInfo, globalCircuitBreakerManager, globalRateLimiterManager, HTTPRateLimiter, InMemoryTokenStorage, initializeMCPEcosystem, isRetryableHTTPError, isRetryableStatusCode, isTokenExpired, listMCPs, CircuitBreakerOpenError, MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry, MCPToolRegistry, ExternalServerManager, MCPClientFactory, ToolRouter, createToolRouter, DEFAULT_ROUTER_CONFIG, ToolCache, createToolCache, DEFAULT_CACHE_CONFIG, ToolResultCache, createToolResultCache, RequestBatcher, ToolCallBatcher, createRequestBatcher, createToolCallBatcher, DEFAULT_BATCH_CONFIG, inferAnnotations, createAnnotatedTool, validateAnnotations, filterToolsByAnnotations, mergeAnnotations, getAnnotationSummary, requiresConfirmation, isSafeToRetry, getToolSafetyLevel, ElicitationManager, globalElicitationManager, EnhancedToolDiscovery, MCPRegistryClient, globalMCPRegistryClient, getWellKnownServer, getAllWellKnownServers, MCPServerBase, MultiServerManager, globalMultiServerManager, AgentExposureManager, exposeAgentAsTool, exposeAgentsAsTools, exposeWorkflowAsTool, exposeWorkflowsAsTools, globalAgentExposureManager, ServerCapabilitiesManager, createTextResource, createJsonResource, createPrompt, neuroLinkToolToMCP, mcpToolToNeuroLink, batchConvertToMCP, batchConvertToNeuroLink, sanitizeToolName, validateToolName, createToolFromFunction, mcpProtocolToolToServerTool, serverToolToMCPProtocol, TOOL_COMPATIBILITY, ToolIntegrationManager, globalToolIntegrationManager, wrapToolWithElicitation, wrapToolsWithElicitation, createElicitationContext, confirmationMiddleware, validationMiddleware, loggingMiddleware, createRetryMiddleware, createTimeoutMiddleware, createToolMiddlewareChain, ElicitationProtocolAdapter, globalElicitationProtocol, isElicitationProtocolMessage, protocolMessageToElicitation, elicitationResponseToProtocol, createElicitationRequest, createElicitationResponse, createElicitationCancel, createTextInputRequest, createSelectRequest, createConfirmationRequest, createFormRequest, } from "./mcp/index.js";
|
|
207
|
-
export type { RoutingStrategy, ToolRouterConfig, RoutingDecision, MCPTool, ToolRouterEvents, AffinityRule, CategoryMapping, RouterServerWeight, CacheStrategy, CacheConfig as MCPCacheConfig, CacheStats, CacheEvents, BatchConfig, BatchResult, BatchExecutor, BatcherEvents, MCPToolAnnotations, MCPServerTool, ToolConverterOptions, MCPProtocolTool, NeuroLinkTool, ToolMiddleware, EnhancedExecutionContext, ToolWrapperOptions, ExposableAgent, ExposableWorkflow, ExposureOptions, ExposureResult, MCPResource, MCPPrompt, ServerCapabilitiesConfig, PromptGenerator, PromptMessage, PromptResult, RegisteredPrompt, RegisteredResource, ResourceContent, ResourceReader, ResourceSubscriptionCallback, RegistryEntry, RegistrySearchOptions, RegistrySearchResult, RegistrySourceType, RegistryConfig, MCPRegistryClientConfig, LoadBalancingStrategy, ServerGroup, UnifiedTool, MultiServerManagerConfig, ServerWeight, MCPServerBaseConfig, MCPServerEvents, EnhancedToolInfo, ToolSearchCriteria, ToolSearchResult, CompatibilityCheckResult, ElicitationType, Elicitation, ElicitationResponse, ElicitationHandler, ElicitationManagerConfig, ElicitationRequest, ElicitationContext, TextElicitation, SelectElicitation, SelectOption, MultiSelectElicitation, ConfirmationElicitation, FileElicitation, SecretElicitation, FormElicitation, FormField, ElicitationProtocolMessage, ElicitationProtocolMessageType, ElicitationProtocolPayload, ElicitationProtocolHandler, ElicitationProtocolAdapterConfig, ElicitationRequestMessage, ElicitationRequestParams, ElicitationResponseMessage, ElicitationResponseParams, ElicitationCancelMessage, ElicitationCancelParams, } from "./mcp/index.js";
|
|
209
|
+
export type { RoutingStrategy, ToolRouterConfig, RoutingDecision, MCPTool, ToolRouterEvents, AffinityRule, CategoryMapping, RouterServerWeight, CacheStrategy, CacheConfig as MCPCacheConfig, CacheStats, CacheEvents, BatchConfig, BatchResult, BatchExecutor, BatcherEvents, MCPToolAnnotations, MCPServerTool, ToolConverterOptions, MCPProtocolTool, NeuroLinkTool, ToolMiddleware, EnhancedExecutionContext, ToolWrapperOptions, ExposableAgent, ExposableWorkflow, ExposureOptions, ExposureResult, MCPResource, MCPPrompt, ServerCapabilitiesConfig, PromptGenerator, PromptMessage, PromptResult, RegisteredPrompt, RegisteredResource, ResourceContent, ResourceReader, ResourceSubscriptionCallback, RegistryEntry, RegistryEntry as MCPRegistryEntry, RegistrySearchOptions, RegistrySearchResult, RegistrySourceType, RegistryConfig, MCPRegistryClientConfig, LoadBalancingStrategy, ServerGroup, UnifiedTool, MultiServerManagerConfig, ServerWeight, MCPServerBaseConfig, MCPServerEvents, EnhancedToolInfo, ToolSearchCriteria, ToolSearchResult, CompatibilityCheckResult, ElicitationType, Elicitation, ElicitationResponse, ElicitationHandler, ElicitationManagerConfig, ElicitationRequest, ElicitationContext, TextElicitation, SelectElicitation, SelectOption, MultiSelectElicitation, ConfirmationElicitation, FileElicitation, SecretElicitation, FormElicitation, FormField, ElicitationProtocolMessage, ElicitationProtocolMessageType, ElicitationProtocolPayload, ElicitationProtocolHandler, ElicitationProtocolAdapterConfig, ElicitationRequestMessage, ElicitationRequestParams, ElicitationResponseMessage, ElicitationResponseParams, ElicitationCancelMessage, ElicitationCancelParams, } from "./mcp/index.js";
|
|
208
210
|
export type { AuthorizationUrlResult, DiscoveredMcp, HTTPRetryConfig, MCPOAuthConfig, McpMetadata, OAuthClientInformation, OAuthTokens as McpOAuthTokens, RateLimitConfig, TokenExchangeRequest, TokenStorage, } from "./types/mcpTypes.js";
|
|
209
211
|
export type { ExecutionContext, ToolExecutionResult, ToolInfo, } from "./types/tools.js";
|
|
210
212
|
export type { LogLevel } from "./types/utilities.js";
|
|
@@ -218,6 +220,40 @@ export declare function getTelemetryStatus(): Promise<{
|
|
|
218
220
|
service?: string;
|
|
219
221
|
version?: string;
|
|
220
222
|
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Evaluation System Exports
|
|
225
|
+
*
|
|
226
|
+
* A comprehensive evaluation framework for assessing AI response quality,
|
|
227
|
+
* with support for RAGAS-style metrics, custom scorers, and pipeline-based evaluation.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* import {
|
|
232
|
+
* Evaluator,
|
|
233
|
+
* ScorerRegistry,
|
|
234
|
+
* EvaluationPipeline,
|
|
235
|
+
* createFaithfulnessScorer,
|
|
236
|
+
* createAnswerRelevancyScorer,
|
|
237
|
+
* } from '@juspay/neurolink';
|
|
238
|
+
*
|
|
239
|
+
* // Create a pipeline with multiple scorers
|
|
240
|
+
* const pipeline = new EvaluationPipeline({
|
|
241
|
+
* scorers: [
|
|
242
|
+
* createFaithfulnessScorer({ model: 'gpt-4' }),
|
|
243
|
+
* createAnswerRelevancyScorer({ model: 'gpt-4' }),
|
|
244
|
+
* ],
|
|
245
|
+
* });
|
|
246
|
+
*
|
|
247
|
+
* // Run evaluation
|
|
248
|
+
* const result = await pipeline.evaluate({
|
|
249
|
+
* question: 'What is quantum computing?',
|
|
250
|
+
* answer: 'Quantum computing uses quantum mechanics...',
|
|
251
|
+
* context: ['Quantum computing is a type of computation...'],
|
|
252
|
+
* });
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
export { Evaluator, BatchEvaluator, EvaluationAggregator, EvaluatorFactory, getEvaluatorFactory, EvaluatorRegistry, getEvaluatorRegistry, EvaluationErrorCodes, evaluationErrors, isRetryableEvaluationError, isEvaluationError, createEvaluationFailedError, createParseError, createStrategyNotFoundError, createProviderError, createMaxRetriesExceededError, createBatchEvaluationError, createConfigurationError, contextToErrorContext, createLangfuseAdapter, createMockLangfuseClient, LangfuseAdapter, startLangfuseAdapter, createConsoleLoggerHook, createMetricsCollectorHook, ObservabilityHooks, observabilityHooks, pipelineToSpanAttributes, scorerToSpanAttributes, createAndInitializePipeline, createPipeline, EvaluationPipeline, PipelineBuilder, Pipelines, CODE_GENERATION_PIPELINE, COMPREHENSIVE_PIPELINE, CUSTOMER_SUPPORT_PIPELINE, getPreset, getPresetNames, MINIMAL_PIPELINE, PipelinePresets, QUALITY_PIPELINE, RAG_PIPELINE, SAFETY_PIPELINE, SUMMARIZATION_PIPELINE, BatchStrategy, createBatchStrategy, evaluateBatch, streamBatchEvaluation, createSamplingStrategy, DEFAULT_SAMPLING_CONFIG, SamplingStrategies, SamplingStrategy, createMetricsCollector, globalMetricsCollector, MetricsCollector, createReportGenerator, ReportGenerator, Reports, BaseScorer, DEFAULT_SCORE_SCALE as EVAL_DEFAULT_SCORE_SCALE, composeScorers, createConditionalScorer, createFunctionScorer, createInvertedScorer, createKeywordScorer, createRegexScorer, createScorerMetadata, createSimpleLengthScorer, AnswerRelevancyScorer, createAnswerRelevancyScorer, BaseLLMScorer, DEFAULT_LLM_SCORER_CONFIG, BiasDetectionScorer, createBiasDetectionScorer, ContextPrecisionScorer, createContextPrecisionScorer, ContextRelevancyScorer, createContextRelevancyScorer, createFaithfulnessScorer, FaithfulnessScorer, createHallucinationScorer, HallucinationScorer, createPromptAlignmentScorer, PromptAlignmentScorer, createSummarizationScorer, SummarizationScorer, createToneConsistencyScorer, ToneConsistencyScorer, createToxicityScorer, ToxicityScorer, BaseRuleScorer, DEFAULT_RULE_SCORER_CONFIG, ContentSimilarityScorer, createContentSimilarityScorer, createFormatScorer, FormatScorer, FormatScorerPresets, createKeywordCoverageScorer, KeywordCoverageScorer, createLengthScorer, LengthScorer, LengthScorerPresets, ScorerBuilder, Scorers, ScorerRegistry, } from "./evaluation/index.js";
|
|
256
|
+
export type { LangfuseAdapterConfig, LangfuseClient, EvaluationEvents, EventHandler, SpanAttributes as EvalSpanAttributes, PipelineExecutionOptions, PipelineResult, AggregatedMetrics, PipelineMetrics, ScorerMetrics, GeneratedReport, ReportData, BatchConfig as EvalBatchConfig, BatchItemResult, BatchProgress as PipelineBatchProgress, BatchResult as EvalBatchResult, ScorerFunction, ContentSimilarityConfig, SimilarityMetric, CodeLanguage, FormatScorerConfig, FormatType, KeywordCoverageConfig, LengthConstraintType, LengthScorerConfig, LengthUnit, BatchEvaluationConfig, BatchProgress, BatchEvaluationItem, BatchEvaluationItemResult, BatchEvaluationResult, ScoreStatistics, ScoreDistribution, TrendAnalysis, DimensionAnalysis, AlertSummary, AggregationResult, EvaluatorPreset, EvaluationStrategyFunction, EvaluationStrategyConfig, EvaluationStrategyMetadata, EvaluationErrorCode, EvaluationErrorContext, } from "./evaluation/index.js";
|
|
221
257
|
export type { AnalyticsData, EvaluationData, TextGenerationOptions, TextGenerationResult, } from "./types/index.js";
|
|
222
258
|
/**
|
|
223
259
|
* Legacy generateText function for backward compatibility.
|
|
@@ -350,28 +386,4 @@ export type { BaseChunkerConfig, BM25Result, CharacterChunkerConfig, Chunk, Chun
|
|
|
350
386
|
*/
|
|
351
387
|
export { assembleContext, batchRerank, CharacterChunker, ChunkerRegistry, CohereRelevanceScorer, CrossEncoderReranker, CSVLoader, chunkText, createChunker, createContextWindow, createHybridSearch, createRAGPipeline, createVectorQueryTool, executeWithCircuitBreaker, extractMetadata, formatContextWithCitations, GraphRAG, getAvailableStrategies, getCircuitBreaker, getDefaultChunkerConfig, getRecommendedStrategy, HTMLChunker, HTMLLoader, InMemoryBM25Index, InMemoryVectorStore, JSONChunker as RAGJSONChunker, JSONLoader, LaTeXChunker, LLMMetadataExtractor, linearCombination, loadDocument, loadDocuments, MarkdownChunker, MarkdownLoader, MDocument, PDFLoader, prepareRAGTool, processDocument, RAGCircuitBreaker, type RAGCircuitBreakerConfig, type RAGCircuitBreakerEvents, RAGCircuitBreakerManager, type RAGCircuitBreakerStats, RAGPipeline, RAGRetryHandler, RecursiveChunker, ragCircuitBreakerManager, reciprocalRankFusion, rerank, SemanticChunker, SentenceChunker, simpleRerank, summarizeContext, TextLoader, TokenChunker, WebLoader, } from "./rag/index.js";
|
|
352
388
|
export { ContextBuilder } from "./evaluation/contextBuilder.js";
|
|
353
|
-
/**
|
|
354
|
-
* Evaluation system for AI response quality assessment.
|
|
355
|
-
*
|
|
356
|
-
* Uses RAGAS-style model-based evaluation with a "judge" LLM to score
|
|
357
|
-
* responses on relevance, accuracy, completeness, and overall quality.
|
|
358
|
-
* Supports retry logic with progressive prompt improvement.
|
|
359
|
-
*
|
|
360
|
-
* @example
|
|
361
|
-
* ```typescript
|
|
362
|
-
* import { Evaluator, RAGASEvaluator, ContextBuilder, RetryManager } from '@juspay/neurolink';
|
|
363
|
-
*
|
|
364
|
-
* const evaluator = new Evaluator({
|
|
365
|
-
* evaluationModel: 'gemini-1.5-flash',
|
|
366
|
-
* provider: 'vertex',
|
|
367
|
-
* threshold: 7,
|
|
368
|
-
* });
|
|
369
|
-
* ```
|
|
370
|
-
*/
|
|
371
|
-
export { Evaluator } from "./evaluation/index.js";
|
|
372
|
-
export { PromptBuilder } from "./evaluation/prompts.js";
|
|
373
|
-
export { RAGASEvaluator } from "./evaluation/ragasEvaluator.js";
|
|
374
|
-
export { RetryManager } from "./evaluation/retryManager.js";
|
|
375
|
-
export { mapToEvaluationData } from "./evaluation/scoring.js";
|
|
376
|
-
export type { EnhancedConversationTurn, EnhancedEvaluationContext, EvaluationConfig, EvaluationResult, GetPromptFunction, QualityErrorDetails, QueryIntentAnalysis, } from "./types/evaluationTypes.js";
|
|
377
389
|
export { AuthProviderFactory, createAuthProvider, AuthProviderRegistry, AuthError as AuthErrorFactory, AuthErrorCodes, BaseAuthProvider, InMemorySessionStorage, AuthProviderError, createAuthMiddleware as createAuthProviderMiddleware, createRBACMiddleware, createProtectedMiddleware, createExpressAuthMiddleware, createRequestContext, extractToken, AuthMiddlewareError, AuthMiddlewareErrorCodes, type MiddlewareHandler as AuthMiddlewareHandler, type MiddlewareResult, type NextFunction, type ExpressMiddleware, UserRateLimiter, MemoryRateLimitStorage, RedisRateLimitStorage, createRateLimitByUserMiddleware, createAuthenticatedRateLimitMiddleware, createRateLimitStorage, type RateLimitConfig as AuthRateLimitConfig, type RateLimitResult, type RateLimitMiddlewareResult, type RateLimitStorage, SessionManager, MemorySessionStorage, RedisSessionStorage, createSessionStorage, type SessionStorageInterface, AuthContextHolder, globalAuthContext, getAuthContext, getCurrentUser, getCurrentSession, isAuthenticated, hasRole, hasAnyRole, hasPermission, hasAllPermissions, requireAuth, requireRole, requirePermission, requireUser, runWithAuthContext, createAuthenticatedContext, RequestContext, NEUROLINK_RESOURCE_ID_KEY, NEUROLINK_THREAD_ID_KEY, createAuthValidatorFromProvider, } from "./auth/index.js";
|