feat: complete VFS with Knowledge Layer integration
- Add importFile() method for single file imports - Implement entity helper methods (linkEntities, findEntityOccurrences) - Fix critical embedding tokenizer bug (char.charCodeAt error) - Fix removeRelationship to actually remove using brain.unrelate() - Add setMetadata/getMetadata methods - Fix GitBridge to query real relationships and events - Enable background Knowledge Layer processing - Rewrite README to emphasize knowledge over files - Add comprehensive VFS documentation (core, knowledge layer, examples) - Add complete test suite covering all VFS methods This completes the VFS implementation with full Knowledge Layer support, enabling files as living knowledge that understand themselves, evolve over time, and connect to everything related.
This commit is contained in:
parent
b3c4f348ab
commit
581f9906fd
17 changed files with 2441 additions and 352 deletions
|
|
@ -187,7 +187,7 @@ export class EmbeddingManager {
|
|||
async embed(text: string | string[]): Promise<Vector> {
|
||||
// Check for unit test environment - use mocks to prevent ONNX conflicts
|
||||
const isTestMode = process.env.BRAINY_UNIT_TEST === 'true' || (globalThis as any).__BRAINY_UNIT_TEST__
|
||||
|
||||
|
||||
if (isTestMode) {
|
||||
// Production safeguard
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
|
|
@ -195,16 +195,26 @@ export class EmbeddingManager {
|
|||
}
|
||||
return this.getMockEmbedding(text)
|
||||
}
|
||||
|
||||
|
||||
// Ensure initialized
|
||||
await this.init()
|
||||
|
||||
|
||||
if (!this.model) {
|
||||
throw new Error('Model not initialized')
|
||||
}
|
||||
|
||||
// Handle array input
|
||||
const input = Array.isArray(text) ? text.join(' ') : text
|
||||
|
||||
// CRITICAL FIX: Ensure input is always a string
|
||||
let input: string
|
||||
if (Array.isArray(text)) {
|
||||
// Join array elements, converting each to string first
|
||||
input = text.map(t => typeof t === 'string' ? t : String(t)).join(' ')
|
||||
} else if (typeof text === 'string') {
|
||||
input = text
|
||||
} else {
|
||||
// This shouldn't happen but let's be defensive
|
||||
console.warn('EmbeddingManager.embed received non-string input:', typeof text)
|
||||
input = String(text)
|
||||
}
|
||||
|
||||
// Generate embedding
|
||||
const output = await this.model(input, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue