brainy/.recovery-workspace/dist-backup-20250910-141917/utils/hybridModelManager.js
David Snelling 8ff382ca3b chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
2025-09-10 15:18:04 -07:00

95 lines
No EOL
3.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Hybrid Model Manager - BEST OF BOTH WORLDS
*
* NOW A WRAPPER AROUND SingletonModelManager
* Maintained for backward compatibility
*
* Previously combined:
* 1. Multi-source downloading strategy (GitHub → CDN → Hugging Face)
* 2. Singleton pattern preventing multiple ONNX model loads
* 3. Environment-specific optimizations
* 4. Graceful fallbacks and error handling
*
* Now delegates all operations to SingletonModelManager for true unification
*/
import { singletonModelManager, getUnifiedEmbeddingFunction } from '../embeddings/SingletonModelManager.js';
/**
* HybridModelManager - Now a wrapper around SingletonModelManager
* Maintained for backward compatibility
*/
class HybridModelManager {
constructor() {
console.log('🔄 HybridModelManager now delegates to SingletonModelManager');
}
static getInstance() {
if (!HybridModelManager.instance) {
HybridModelManager.instance = new HybridModelManager();
}
return HybridModelManager.instance;
}
/**
* Get the primary embedding model - delegates to SingletonModelManager
*/
async getPrimaryModel() {
// Delegate to SingletonModelManager
return await singletonModelManager.getModel();
}
/**
* Get embedding function - delegates to SingletonModelManager
*/
async getEmbeddingFunction() {
return await getUnifiedEmbeddingFunction();
}
/**
* Check if model is ready - delegates to SingletonModelManager
*/
isModelReady() {
return singletonModelManager.isInitialized();
}
/**
* Force model reload - not supported with SingletonModelManager
*/
async reloadModel() {
console.warn('⚠️ Model reload not supported with SingletonModelManager');
console.log(' Singleton model persists for consistency');
// Just ensure model is initialized
await this.getPrimaryModel();
}
/**
* Get model status - delegates to SingletonModelManager
*/
getModelStatus() {
const isReady = singletonModelManager.isInitialized();
return {
loaded: isReady,
ready: isReady,
modelType: 'SingletonModelManager (Unified model instance)'
};
}
}
HybridModelManager.instance = null;
// Export singleton instance
export const hybridModelManager = HybridModelManager.getInstance();
/**
* Get the hybrid singleton embedding function - Now delegates to SingletonModelManager
* Maintained for backward compatibility
*/
export async function getHybridEmbeddingFunction() {
return await getUnifiedEmbeddingFunction();
}
/**
* Hybrid embedding function - Now delegates to SingletonModelManager
* Maintained for backward compatibility
*/
export const hybridEmbeddingFunction = async (data) => {
return await singletonModelManager.embed(data);
};
/**
* Preload model for tests or production - Now delegates to SingletonModelManager
*/
export async function preloadHybridModel() {
console.log('🚀 Preloading model via SingletonModelManager...');
await singletonModelManager.getModel();
console.log('✅ Singleton model preloaded and ready!');
}
//# sourceMappingURL=hybridModelManager.js.map