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
This commit is contained in:
parent
f65455fb22
commit
8ff382ca3b
895 changed files with 143654 additions and 28268 deletions
108
.recovery-workspace/dist-backup-20250910-141917/utils/embedding.d.ts
vendored
Normal file
108
.recovery-workspace/dist-backup-20250910-141917/utils/embedding.d.ts
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* Embedding functions for converting data to vectors using Transformers.js
|
||||
* Complete rewrite to eliminate TensorFlow.js and use ONNX-based models
|
||||
*/
|
||||
import { EmbeddingFunction, EmbeddingModel, Vector } from '../coreTypes.js';
|
||||
/**
|
||||
* Detect the best available GPU device for the current environment
|
||||
*/
|
||||
export declare function detectBestDevice(): Promise<'cpu' | 'webgpu' | 'cuda'>;
|
||||
/**
|
||||
* Resolve device string to actual device configuration
|
||||
*/
|
||||
export declare function resolveDevice(device?: string): Promise<string>;
|
||||
/**
|
||||
* Transformers.js Sentence Encoder embedding model
|
||||
* Uses ONNX Runtime for fast, offline embeddings with smaller models
|
||||
* Default model: all-MiniLM-L6-v2 (384 dimensions, ~90MB)
|
||||
*/
|
||||
export interface TransformerEmbeddingOptions {
|
||||
/** Model name/path to use - defaults to all-MiniLM-L6-v2 */
|
||||
model?: string;
|
||||
/** Whether to enable verbose logging */
|
||||
verbose?: boolean;
|
||||
/** Custom cache directory for models */
|
||||
cacheDir?: string;
|
||||
/** Force local files only (no downloads) */
|
||||
localFilesOnly?: boolean;
|
||||
/** Model precision: 'q8' = 75% smaller quantized model, 'fp32' = full precision (default) */
|
||||
precision?: 'fp32' | 'q8';
|
||||
/** Device to run inference on - 'auto' detects best available */
|
||||
device?: 'auto' | 'cpu' | 'webgpu' | 'cuda' | 'gpu';
|
||||
}
|
||||
export declare class TransformerEmbedding implements EmbeddingModel {
|
||||
private extractor;
|
||||
private initialized;
|
||||
private verbose;
|
||||
private options;
|
||||
/**
|
||||
* Create a new TransformerEmbedding instance
|
||||
*/
|
||||
constructor(options?: TransformerEmbeddingOptions);
|
||||
/**
|
||||
* Get the default cache directory for models
|
||||
*/
|
||||
private getDefaultCacheDir;
|
||||
/**
|
||||
* Check if we're running in a test environment
|
||||
*/
|
||||
private isTestEnvironment;
|
||||
/**
|
||||
* Log message only if verbose mode is enabled
|
||||
*/
|
||||
private logger;
|
||||
/**
|
||||
* Generate mock embeddings for unit tests
|
||||
*/
|
||||
private getMockEmbedding;
|
||||
/**
|
||||
* Initialize the embedding model
|
||||
*/
|
||||
init(): Promise<void>;
|
||||
/**
|
||||
* Generate embeddings for text data
|
||||
*/
|
||||
embed(data: string | string[]): Promise<Vector>;
|
||||
/**
|
||||
* Dispose of the model and free resources
|
||||
*/
|
||||
dispose(): Promise<void>;
|
||||
/**
|
||||
* Get the dimension of embeddings produced by this model
|
||||
*/
|
||||
getDimension(): number;
|
||||
/**
|
||||
* Check if the model is initialized
|
||||
*/
|
||||
isInitialized(): boolean;
|
||||
}
|
||||
export declare const UniversalSentenceEncoder: typeof TransformerEmbedding;
|
||||
/**
|
||||
* Create a new embedding model instance
|
||||
*/
|
||||
export declare function createEmbeddingModel(options?: TransformerEmbeddingOptions): EmbeddingModel;
|
||||
/**
|
||||
* Default embedding function using the unified EmbeddingManager
|
||||
* Simple, clean, reliable - no more layers of indirection
|
||||
*/
|
||||
export declare const defaultEmbeddingFunction: EmbeddingFunction;
|
||||
/**
|
||||
* Create an embedding function with custom options
|
||||
* NOTE: Options are validated but the singleton EmbeddingManager is always used
|
||||
*/
|
||||
export declare function createEmbeddingFunction(options?: TransformerEmbeddingOptions): EmbeddingFunction;
|
||||
/**
|
||||
* Batch embedding function for processing multiple texts efficiently
|
||||
*/
|
||||
export declare function batchEmbed(texts: string[], options?: TransformerEmbeddingOptions): Promise<Vector[]>;
|
||||
/**
|
||||
* Embedding functions for specific model types
|
||||
*/
|
||||
export declare const embeddingFunctions: {
|
||||
/** Default lightweight model (all-MiniLM-L6-v2, 384 dimensions) */
|
||||
default: EmbeddingFunction;
|
||||
/** Create custom embedding function */
|
||||
create: typeof createEmbeddingFunction;
|
||||
/** Batch processing */
|
||||
batch: typeof batchEmbed;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue