feat: add AI_EMBEDDING_SUPPORTS_MRL env var to decouple pgvector dimensions from model API (#2079)

Some embedding models don't accept a `dimensions` parameter. This adds
an optional env var that controls whether the dimension is sent to the
model API, while always using it for pgvector indexing. Preset models
have this handled automatically; the env var allows explicit override
for custom models.
This commit is contained in:
Philip Okugbe
2026-03-31 19:39:49 +01:00
committed by GitHub
parent fd91b11c6c
commit 9aaa6c731c
4 changed files with 14 additions and 2 deletions
@@ -259,6 +259,12 @@ export class EnvironmentService {
);
}
getAiEmbeddingSupportsMrl(): boolean | undefined {
const val = this.configService.get<string>('AI_EMBEDDING_SUPPORTS_MRL');
if (val === undefined || val === null || val === '') return undefined;
return val === 'true';
}
getOpenAiApiKey(): string {
return this.configService.get<string>('OPENAI_API_KEY');
}
@@ -117,6 +117,12 @@ export class EnvironmentVariables {
@IsString()
AI_EMBEDDING_DIMENSION: string;
@IsOptional()
@ValidateIf((obj) => obj.AI_EMBEDDING_SUPPORTS_MRL)
@IsIn(['true', 'false'])
@IsString()
AI_EMBEDDING_SUPPORTS_MRL: string;
@ValidateIf((obj) => obj.AI_DRIVER)
@IsString()
@IsNotEmpty()