From 126fe08379848ddf83d5dcc0f272e2b32c4250a9 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Thu, 19 Jun 2025 15:02:53 -0700 Subject: [PATCH] **refactor: streamline initializeBrainy embedding configuration and cleanup code style** ### Changes: - Removed conditional configuration for `USE_SIMPLE_EMBEDDING` as Universal Sentence Encoder is now the sole embedding option. - Updated comments to reflect the exclusive use of TensorFlow.js for embedding functionality. - Cleaned up unnecessary blank lines and whitespace for improved code readability. ### Purpose: Simplified the `initializeBrainy` function by consolidating embedding configuration and eliminating outdated options. This refinement aligns with the project's transition to TensorFlow-based embeddings and improves code clarity. --- cloud-wrapper/src/services/brainyService.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/cloud-wrapper/src/services/brainyService.ts b/cloud-wrapper/src/services/brainyService.ts index 9e6172ee..865f09e5 100644 --- a/cloud-wrapper/src/services/brainyService.ts +++ b/cloud-wrapper/src/services/brainyService.ts @@ -11,7 +11,7 @@ dotenv.config(); export async function initializeBrainy(): Promise { // Get storage configuration from environment variables const storageType = process.env.STORAGE_TYPE || 'filesystem'; - + // Create configuration object const config: any = { storage: {} @@ -29,27 +29,24 @@ export async function initializeBrainy(): Promise { endpoint: process.env.S3_ENDPOINT // Optional for custom S3-compatible services }; break; - + case 'filesystem': // Configure filesystem storage config.storage.rootDirectory = process.env.STORAGE_ROOT_DIR || './data'; break; - + case 'memory': // No additional configuration needed for memory storage break; - + default: // Default to filesystem storage config.storage.rootDirectory = process.env.STORAGE_ROOT_DIR || './data'; break; } - // Configure embedding options - if (process.env.USE_SIMPLE_EMBEDDING === 'true') { - // Use simple embedding (faster but less accurate) - config.useSimpleEmbedding = true; - } + // Note: Universal Sentence Encoder is now the only embedding option + // TensorFlow.js is required for embedding to work // Configure HNSW index parameters if provided if (process.env.HNSW_M) { @@ -67,7 +64,7 @@ export async function initializeBrainy(): Promise { // Create and initialize the Brainy instance const brainy = new BrainyData(config); await brainy.init(); - + return brainy; }