@astermind/cybernetic-chatbot-client 2.2.18 → 2.2.30
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/dist/CyberneticLocalRAG.d.ts.map +1 -1
- package/dist/agentic/CyberneticIntentClassifier.d.ts +4 -0
- package/dist/agentic/CyberneticIntentClassifier.d.ts.map +1 -1
- package/dist/cybernetic-chatbot-client-full.esm.js +25 -5
- package/dist/cybernetic-chatbot-client-full.esm.js.map +1 -1
- package/dist/cybernetic-chatbot-client-full.min.js +1 -1
- package/dist/cybernetic-chatbot-client-full.min.js.map +1 -1
- package/dist/cybernetic-chatbot-client-full.umd.js +25 -5
- package/dist/cybernetic-chatbot-client-full.umd.js.map +1 -1
- package/dist/cybernetic-chatbot-client.esm.js +25 -5
- package/dist/cybernetic-chatbot-client.esm.js.map +1 -1
- package/dist/cybernetic-chatbot-client.min.js +1 -1
- package/dist/cybernetic-chatbot-client.min.js.map +1 -1
- package/dist/cybernetic-chatbot-client.umd.js +25 -5
- package/dist/cybernetic-chatbot-client.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -643,6 +643,10 @@
|
|
|
643
643
|
// Tokenize and build document frequency
|
|
644
644
|
const docFreq = new Map();
|
|
645
645
|
for (const doc of documents) {
|
|
646
|
+
// Skip documents without content
|
|
647
|
+
if (!doc.content) {
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
646
650
|
const tokens = this.tokenize(doc.content);
|
|
647
651
|
const uniqueTokens = new Set(tokens);
|
|
648
652
|
// Count document frequency
|
|
@@ -793,6 +797,9 @@
|
|
|
793
797
|
* Tokenize text into words
|
|
794
798
|
*/
|
|
795
799
|
tokenize(text) {
|
|
800
|
+
if (!text || typeof text !== 'string') {
|
|
801
|
+
return [];
|
|
802
|
+
}
|
|
796
803
|
return text
|
|
797
804
|
.toLowerCase()
|
|
798
805
|
.replace(/[^\w\s]/g, ' ')
|
|
@@ -3546,22 +3553,35 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
3546
3553
|
}
|
|
3547
3554
|
return '';
|
|
3548
3555
|
}
|
|
3556
|
+
/**
|
|
3557
|
+
* Strip common articles and filler words for better matching
|
|
3558
|
+
*/
|
|
3559
|
+
stripArticles(text) {
|
|
3560
|
+
return text
|
|
3561
|
+
.replace(/^(the|a|an|my|our|your|this|that)\s+/gi, '')
|
|
3562
|
+
.replace(/\s+(page|section|screen|view)$/gi, '')
|
|
3563
|
+
.trim();
|
|
3564
|
+
}
|
|
3549
3565
|
/**
|
|
3550
3566
|
* Find site map match for target string
|
|
3551
3567
|
*/
|
|
3552
3568
|
findSiteMapMatch(target) {
|
|
3553
3569
|
const normalizedTarget = target.toLowerCase().replace(/[^a-z0-9\s]/g, '');
|
|
3554
|
-
|
|
3555
|
-
|
|
3570
|
+
const strippedTarget = this.stripArticles(normalizedTarget);
|
|
3571
|
+
// Exact match (try both with and without articles)
|
|
3572
|
+
const exact = this.siteMapIndex.get(normalizedTarget) || this.siteMapIndex.get(strippedTarget);
|
|
3556
3573
|
if (exact) {
|
|
3557
3574
|
return { entry: exact, similarity: 1.0 };
|
|
3558
3575
|
}
|
|
3559
|
-
// Fuzzy match
|
|
3576
|
+
// Fuzzy match using stripped version for better accuracy
|
|
3560
3577
|
let bestMatch = null;
|
|
3561
3578
|
let bestScore = 0;
|
|
3562
3579
|
for (const [key, entry] of this.siteMapIndex) {
|
|
3563
|
-
|
|
3564
|
-
|
|
3580
|
+
// Compare both original and stripped versions, take the better score
|
|
3581
|
+
const score1 = this.calculateSimilarity(normalizedTarget, key);
|
|
3582
|
+
const score2 = this.calculateSimilarity(strippedTarget, key);
|
|
3583
|
+
const score = Math.max(score1, score2);
|
|
3584
|
+
if (score > bestScore && score > 0.5) {
|
|
3565
3585
|
bestScore = score;
|
|
3566
3586
|
bestMatch = entry;
|
|
3567
3587
|
}
|