@juspay/neurolink 7.36.0 → 7.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 +6 -0
- package/dist/config/taskClassificationConfig.d.ts +51 -0
- package/dist/config/taskClassificationConfig.js +148 -0
- package/dist/lib/config/taskClassificationConfig.d.ts +51 -0
- package/dist/lib/config/taskClassificationConfig.js +148 -0
- package/dist/lib/neurolink.d.ts +20 -0
- package/dist/lib/neurolink.js +268 -5
- package/dist/lib/types/index.d.ts +2 -0
- package/dist/lib/types/index.js +2 -0
- package/dist/lib/types/taskClassificationTypes.d.ts +52 -0
- package/dist/lib/types/taskClassificationTypes.js +5 -0
- package/dist/lib/utils/modelRouter.d.ts +107 -0
- package/dist/lib/utils/modelRouter.js +292 -0
- package/dist/lib/utils/promptRedaction.d.ts +29 -0
- package/dist/lib/utils/promptRedaction.js +62 -0
- package/dist/lib/utils/taskClassificationUtils.d.ts +55 -0
- package/dist/lib/utils/taskClassificationUtils.js +149 -0
- package/dist/lib/utils/taskClassifier.d.ts +23 -0
- package/dist/lib/utils/taskClassifier.js +94 -0
- package/dist/neurolink.d.ts +20 -0
- package/dist/neurolink.js +268 -5
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/taskClassificationTypes.d.ts +52 -0
- package/dist/types/taskClassificationTypes.js +5 -0
- package/dist/utils/modelRouter.d.ts +107 -0
- package/dist/utils/modelRouter.js +292 -0
- package/dist/utils/promptRedaction.d.ts +29 -0
- package/dist/utils/promptRedaction.js +62 -0
- package/dist/utils/taskClassificationUtils.d.ts +55 -0
- package/dist/utils/taskClassificationUtils.js +149 -0
- package/dist/utils/taskClassifier.d.ts +23 -0
- package/dist/utils/taskClassifier.js +94 -0
- package/package.json +1 -1
@@ -0,0 +1,94 @@
|
|
1
|
+
/**
|
2
|
+
* Binary Task Classifier for NeuroLink Orchestration
|
3
|
+
* Classifies tasks as either 'fast' (quick responses) or 'reasoning' (complex analysis)
|
4
|
+
*/
|
5
|
+
import { logger } from "./logger.js";
|
6
|
+
import { CLASSIFICATION_THRESHOLDS } from "../config/taskClassificationConfig.js";
|
7
|
+
import { analyzePrompt, calculateConfidence, determineTaskType, } from "./taskClassificationUtils.js";
|
8
|
+
import { redactForClassification } from "./promptRedaction.js";
|
9
|
+
/**
|
10
|
+
* Binary Task Classifier
|
11
|
+
* Determines if a task requires fast response or deeper reasoning
|
12
|
+
*/
|
13
|
+
export class BinaryTaskClassifier {
|
14
|
+
/**
|
15
|
+
* Classify a prompt as either fast or reasoning task
|
16
|
+
*/
|
17
|
+
static classify(prompt) {
|
18
|
+
const startTime = Date.now();
|
19
|
+
// Analyze the prompt using utility functions
|
20
|
+
const scores = analyzePrompt(prompt);
|
21
|
+
const { fastScore, reasoningScore, reasons } = scores;
|
22
|
+
// Determine final classification
|
23
|
+
const totalScore = fastScore + reasoningScore;
|
24
|
+
let type;
|
25
|
+
let confidence;
|
26
|
+
if (totalScore === 0) {
|
27
|
+
// Default to fast for ambiguous cases
|
28
|
+
type = "fast";
|
29
|
+
confidence = CLASSIFICATION_THRESHOLDS.DEFAULT_CONFIDENCE;
|
30
|
+
reasons.push("default fallback");
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
type = determineTaskType(fastScore, reasoningScore);
|
34
|
+
confidence = calculateConfidence(fastScore, reasoningScore);
|
35
|
+
}
|
36
|
+
const classification = {
|
37
|
+
type,
|
38
|
+
confidence,
|
39
|
+
reasoning: reasons.join(", "),
|
40
|
+
};
|
41
|
+
const classificationTime = Date.now() - startTime;
|
42
|
+
logger.debug("Task classified", {
|
43
|
+
prompt: redactForClassification(prompt),
|
44
|
+
classification: type,
|
45
|
+
confidence: confidence.toFixed(2),
|
46
|
+
fastScore,
|
47
|
+
reasoningScore,
|
48
|
+
reasons: reasons.join(", "),
|
49
|
+
classificationTime: `${classificationTime}ms`,
|
50
|
+
});
|
51
|
+
return classification;
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Get classification statistics for multiple prompts
|
55
|
+
*/
|
56
|
+
static getClassificationStats(prompts) {
|
57
|
+
// Guard against empty array to prevent divide-by-zero
|
58
|
+
if (prompts.length === 0) {
|
59
|
+
const stats = {
|
60
|
+
total: 0,
|
61
|
+
fast: 0,
|
62
|
+
reasoning: 0,
|
63
|
+
averageConfidence: 0,
|
64
|
+
};
|
65
|
+
logger.debug("Classification stats", stats);
|
66
|
+
return stats;
|
67
|
+
}
|
68
|
+
const classifications = prompts.map((prompt) => this.classify(prompt));
|
69
|
+
const stats = {
|
70
|
+
total: classifications.length,
|
71
|
+
fast: classifications.filter((c) => c.type === "fast").length,
|
72
|
+
reasoning: classifications.filter((c) => c.type === "reasoning").length,
|
73
|
+
averageConfidence: classifications.reduce((sum, c) => sum + c.confidence, 0) /
|
74
|
+
classifications.length,
|
75
|
+
};
|
76
|
+
logger.debug("Classification stats", stats);
|
77
|
+
return stats;
|
78
|
+
}
|
79
|
+
/**
|
80
|
+
* Validate classification accuracy (for testing/tuning)
|
81
|
+
*/
|
82
|
+
static validateClassification(prompt, expectedType) {
|
83
|
+
const classification = this.classify(prompt);
|
84
|
+
const correct = classification.type === expectedType;
|
85
|
+
logger.debug("Classification validation", {
|
86
|
+
prompt: redactForClassification(prompt),
|
87
|
+
expected: expectedType,
|
88
|
+
actual: classification.type,
|
89
|
+
correct,
|
90
|
+
confidence: classification.confidence,
|
91
|
+
});
|
92
|
+
return { correct, classification };
|
93
|
+
}
|
94
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@juspay/neurolink",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.37.0",
|
4
4
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
|
5
5
|
"author": {
|
6
6
|
"name": "Juspay Technologies",
|