@astermind/cybernetic-chatbot-client 2.2.21 → 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.
@@ -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, ' ')