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