mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-02 01:02:05 +08:00
64f70a41c1
* feat(vectordb): add OceanBase HNSW quantization (HNSW_SQ/HNSW_BQ) (#6348) Support OceanBase vector index quantization via VECTOR_VQ_LEVEL: - 32 (default): hnsw + inner_product - 8: hnsw_sq + inner_product (2-3x memory savings) - 1: hnsw_bq + cosine (~15x memory savings) HNSW_BQ requires cosine distance per OceanBase docs. Tested on OceanBase 4.3.5.5 (BP5). Closes #6202 * feat: add test inclusion for vectorDB tests in vitest configuration (#6358) * feat: add test inclusion for vectorDB tests in vitest configuration * refactor: update vectorDB README and setup for environment configuration - Enhanced README to clarify the use of factory pattern for vectorDB integration tests. - Updated instructions for setting up environment variables from a local file. - Removed obsolete PG integration test file and adjusted test execution instructions. - Improved structure explanation for shared test data and factory functions. * perf: integrationTest * feat: vector integration --------- Co-authored-by: ZHANG Yixin <hi.yixinz@gmail.com> Co-authored-by: Jingchao <alswlx@gmail.com>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { existsSync, readFileSync } from 'fs';
|
|
import { resolve } from 'path';
|
|
|
|
type LoadVectorEnvOptions = {
|
|
envFileNames?: string[];
|
|
};
|
|
|
|
const parseEnvFile = (filePath: string) => {
|
|
const content = readFileSync(filePath, 'utf-8');
|
|
const lines = content.split('\n');
|
|
|
|
for (const rawLine of lines) {
|
|
const line = rawLine.trim();
|
|
if (!line || line.startsWith('#')) continue;
|
|
|
|
const separatorIndex = line.indexOf('=');
|
|
if (separatorIndex === -1) continue;
|
|
|
|
const key = line.slice(0, separatorIndex).trim();
|
|
const value = line.slice(separatorIndex + 1).trim();
|
|
|
|
if (!key || process.env[key]) continue;
|
|
process.env[key] = value;
|
|
}
|
|
};
|
|
|
|
export const loadVectorDBEnv = (options: LoadVectorEnvOptions = {}) => {
|
|
const envFileNames = options.envFileNames ?? ['.env.test.local'];
|
|
const baseDir = resolve(__dirname);
|
|
|
|
for (const envFileName of envFileNames) {
|
|
const filePath = resolve(baseDir, envFileName);
|
|
if (existsSync(filePath)) {
|
|
parseEnvFile(filePath);
|
|
}
|
|
}
|
|
};
|