@soulcraft/brainy 0.51.2 → 0.52.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/dist/augmentations/intelligentVerbScoring.d.ts +158 -0
- package/dist/augmentations/intelligentVerbScoring.js +377 -0
- package/dist/augmentations/intelligentVerbScoring.js.map +1 -0
- package/dist/brainyData.d.ts +77 -0
- package/dist/brainyData.js +84 -1
- package/dist/brainyData.js.map +1 -1
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +24 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +125 -3
- package/dist/storage/adapters/s3CompatibleStorage.js.map +1 -1
- package/package.json +2 -8
package/dist/brainyData.js
CHANGED
|
@@ -12,6 +12,7 @@ import { matchesMetadataFilter } from './utils/metadataFilter.js';
|
|
|
12
12
|
import { MetadataIndexManager } from './utils/metadataIndex.js';
|
|
13
13
|
import { NounType, VerbType } from './types/graphTypes.js';
|
|
14
14
|
import { createServerSearchAugmentations } from './augmentations/serverSearchAugmentations.js';
|
|
15
|
+
import { IntelligentVerbScoring } from './augmentations/intelligentVerbScoring.js';
|
|
15
16
|
import { augmentationPipeline } from './augmentationPipeline.js';
|
|
16
17
|
import { prepareJsonForVectorization, extractFieldFromJson } from './utils/jsonProcessing.js';
|
|
17
18
|
import { DistributedConfigManager, HashPartitioner, OperationalModeFactory, DomainDetector, HealthMonitor } from './distributed/index.js';
|
|
@@ -69,6 +70,7 @@ export class BrainyData {
|
|
|
69
70
|
this.remoteServerConfig = null;
|
|
70
71
|
this.serverSearchConduit = null;
|
|
71
72
|
this.serverConnection = null;
|
|
73
|
+
this.intelligentVerbScoring = null;
|
|
72
74
|
// Distributed mode properties
|
|
73
75
|
this.distributedConfig = null;
|
|
74
76
|
this.configManager = null;
|
|
@@ -198,6 +200,11 @@ export class BrainyData {
|
|
|
198
200
|
}
|
|
199
201
|
// Initialize search cache with final configuration
|
|
200
202
|
this.searchCache = new SearchCache(finalSearchCacheConfig);
|
|
203
|
+
// Initialize intelligent verb scoring if enabled
|
|
204
|
+
if (config.intelligentVerbScoring?.enabled) {
|
|
205
|
+
this.intelligentVerbScoring = new IntelligentVerbScoring(config.intelligentVerbScoring);
|
|
206
|
+
this.intelligentVerbScoring.enabled = true;
|
|
207
|
+
}
|
|
201
208
|
}
|
|
202
209
|
/**
|
|
203
210
|
* Check if the database is in read-only mode and throw an error if it is
|
|
@@ -542,6 +549,48 @@ export class BrainyData {
|
|
|
542
549
|
throw error;
|
|
543
550
|
}
|
|
544
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Provide feedback to the intelligent verb scoring system for learning
|
|
554
|
+
* This allows the system to learn from user corrections or validation
|
|
555
|
+
*
|
|
556
|
+
* @param sourceId - Source entity ID
|
|
557
|
+
* @param targetId - Target entity ID
|
|
558
|
+
* @param verbType - Relationship type
|
|
559
|
+
* @param feedbackWeight - The corrected/validated weight (0-1)
|
|
560
|
+
* @param feedbackConfidence - The corrected/validated confidence (0-1)
|
|
561
|
+
* @param feedbackType - Type of feedback ('correction', 'validation', 'enhancement')
|
|
562
|
+
*/
|
|
563
|
+
async provideFeedbackForVerbScoring(sourceId, targetId, verbType, feedbackWeight, feedbackConfidence, feedbackType = 'correction') {
|
|
564
|
+
if (this.intelligentVerbScoring?.enabled) {
|
|
565
|
+
await this.intelligentVerbScoring.provideFeedback(sourceId, targetId, verbType, feedbackWeight, feedbackConfidence, feedbackType);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Get learning statistics from the intelligent verb scoring system
|
|
570
|
+
*/
|
|
571
|
+
getVerbScoringStats() {
|
|
572
|
+
if (this.intelligentVerbScoring?.enabled) {
|
|
573
|
+
return this.intelligentVerbScoring.getLearningStats();
|
|
574
|
+
}
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Export learning data from the intelligent verb scoring system
|
|
579
|
+
*/
|
|
580
|
+
exportVerbScoringLearningData() {
|
|
581
|
+
if (this.intelligentVerbScoring?.enabled) {
|
|
582
|
+
return this.intelligentVerbScoring.exportLearningData();
|
|
583
|
+
}
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Import learning data into the intelligent verb scoring system
|
|
588
|
+
*/
|
|
589
|
+
importVerbScoringLearningData(jsonData) {
|
|
590
|
+
if (this.intelligentVerbScoring?.enabled) {
|
|
591
|
+
this.intelligentVerbScoring.importLearningData(jsonData);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
545
594
|
/**
|
|
546
595
|
* Get the current augmentation name if available
|
|
547
596
|
* This is used to auto-detect the service performing data operations
|
|
@@ -765,6 +814,13 @@ export class BrainyData {
|
|
|
765
814
|
}
|
|
766
815
|
}
|
|
767
816
|
}
|
|
817
|
+
// Initialize intelligent verb scoring augmentation if enabled
|
|
818
|
+
if (this.intelligentVerbScoring) {
|
|
819
|
+
await this.intelligentVerbScoring.initialize();
|
|
820
|
+
this.intelligentVerbScoring.setBrainyInstance(this);
|
|
821
|
+
// Register with augmentation pipeline
|
|
822
|
+
augmentationPipeline.register(this.intelligentVerbScoring);
|
|
823
|
+
}
|
|
768
824
|
this.isInitialized = true;
|
|
769
825
|
this.isInitializing = false;
|
|
770
826
|
// Start real-time updates if enabled
|
|
@@ -2540,6 +2596,28 @@ export class BrainyData {
|
|
|
2540
2596
|
vector: verbVector,
|
|
2541
2597
|
connections: new Map()
|
|
2542
2598
|
};
|
|
2599
|
+
// Apply intelligent verb scoring if enabled and weight/confidence not provided
|
|
2600
|
+
let finalWeight = options.weight;
|
|
2601
|
+
let finalConfidence;
|
|
2602
|
+
let scoringReasoning = [];
|
|
2603
|
+
if (this.intelligentVerbScoring?.enabled && (!options.weight || options.weight === 0.5)) {
|
|
2604
|
+
try {
|
|
2605
|
+
const scores = await this.intelligentVerbScoring.computeVerbScores(sourceId, targetId, verbType, options.weight, options.metadata);
|
|
2606
|
+
finalWeight = scores.weight;
|
|
2607
|
+
finalConfidence = scores.confidence;
|
|
2608
|
+
scoringReasoning = scores.reasoning;
|
|
2609
|
+
if (this.loggingConfig?.verbose && scoringReasoning.length > 0) {
|
|
2610
|
+
console.log(`Intelligent verb scoring for ${sourceId}-${verbType}-${targetId}:`, scoringReasoning);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
catch (error) {
|
|
2614
|
+
if (this.loggingConfig?.verbose) {
|
|
2615
|
+
console.warn('Error in intelligent verb scoring:', error);
|
|
2616
|
+
}
|
|
2617
|
+
// Fall back to original weight
|
|
2618
|
+
finalWeight = options.weight;
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2543
2621
|
// Create complete verb metadata separately
|
|
2544
2622
|
const verbMetadata = {
|
|
2545
2623
|
sourceId: sourceId,
|
|
@@ -2548,7 +2626,12 @@ export class BrainyData {
|
|
|
2548
2626
|
target: targetId,
|
|
2549
2627
|
verb: verbType,
|
|
2550
2628
|
type: verbType, // Set the type property to match the verb type
|
|
2551
|
-
weight:
|
|
2629
|
+
weight: finalWeight,
|
|
2630
|
+
confidence: finalConfidence, // Add confidence to metadata
|
|
2631
|
+
intelligentScoring: scoringReasoning.length > 0 ? {
|
|
2632
|
+
reasoning: scoringReasoning,
|
|
2633
|
+
computedAt: new Date().toISOString()
|
|
2634
|
+
} : undefined,
|
|
2552
2635
|
createdAt: timestamp,
|
|
2553
2636
|
updatedAt: timestamp,
|
|
2554
2637
|
createdBy: getAugmentationVersion(service),
|