**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.
This commit is contained in:
parent
71b5e09462
commit
126fe08379
1 changed files with 7 additions and 10 deletions
|
|
@ -11,7 +11,7 @@ dotenv.config();
|
||||||
export async function initializeBrainy(): Promise<BrainyData> {
|
export async function initializeBrainy(): Promise<BrainyData> {
|
||||||
// Get storage configuration from environment variables
|
// Get storage configuration from environment variables
|
||||||
const storageType = process.env.STORAGE_TYPE || 'filesystem';
|
const storageType = process.env.STORAGE_TYPE || 'filesystem';
|
||||||
|
|
||||||
// Create configuration object
|
// Create configuration object
|
||||||
const config: any = {
|
const config: any = {
|
||||||
storage: {}
|
storage: {}
|
||||||
|
|
@ -29,27 +29,24 @@ export async function initializeBrainy(): Promise<BrainyData> {
|
||||||
endpoint: process.env.S3_ENDPOINT // Optional for custom S3-compatible services
|
endpoint: process.env.S3_ENDPOINT // Optional for custom S3-compatible services
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'filesystem':
|
case 'filesystem':
|
||||||
// Configure filesystem storage
|
// Configure filesystem storage
|
||||||
config.storage.rootDirectory = process.env.STORAGE_ROOT_DIR || './data';
|
config.storage.rootDirectory = process.env.STORAGE_ROOT_DIR || './data';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'memory':
|
case 'memory':
|
||||||
// No additional configuration needed for memory storage
|
// No additional configuration needed for memory storage
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Default to filesystem storage
|
// Default to filesystem storage
|
||||||
config.storage.rootDirectory = process.env.STORAGE_ROOT_DIR || './data';
|
config.storage.rootDirectory = process.env.STORAGE_ROOT_DIR || './data';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure embedding options
|
// Note: Universal Sentence Encoder is now the only embedding option
|
||||||
if (process.env.USE_SIMPLE_EMBEDDING === 'true') {
|
// TensorFlow.js is required for embedding to work
|
||||||
// Use simple embedding (faster but less accurate)
|
|
||||||
config.useSimpleEmbedding = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure HNSW index parameters if provided
|
// Configure HNSW index parameters if provided
|
||||||
if (process.env.HNSW_M) {
|
if (process.env.HNSW_M) {
|
||||||
|
|
@ -67,7 +64,7 @@ export async function initializeBrainy(): Promise<BrainyData> {
|
||||||
// Create and initialize the Brainy instance
|
// Create and initialize the Brainy instance
|
||||||
const brainy = new BrainyData(config);
|
const brainy = new BrainyData(config);
|
||||||
await brainy.init();
|
await brainy.init();
|
||||||
|
|
||||||
return brainy;
|
return brainy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue