forked from Yara724/api
Added AI damage estimation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
IsBooleanString,
|
||||
IsEnum,
|
||||
IsInt,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsPositive,
|
||||
@@ -121,4 +122,23 @@ export class EnvironmentVariables {
|
||||
@Min(1000)
|
||||
@Max(600000)
|
||||
AI_DAMAGE_TIMEOUT_MS?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsBooleanString()
|
||||
OPENAI_PRICE_ESTIMATION_ENABLED?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
OPENAI_PRICE_ESTIMATION_API_KEY?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
OPENAI_PRICE_ESTIMATION_MODEL?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1000)
|
||||
@Max(600000)
|
||||
OPENAI_PRICE_ESTIMATION_TIMEOUT_MS?: number;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,15 @@ export function validate(config: Record<string, unknown>) {
|
||||
skipMissingProperties: false,
|
||||
});
|
||||
|
||||
if (
|
||||
validatedConfig.OPENAI_PRICE_ESTIMATION_ENABLED === "true" &&
|
||||
!validatedConfig.OPENAI_PRICE_ESTIMATION_API_KEY?.trim()
|
||||
) {
|
||||
throw new Error(
|
||||
"OPENAI_PRICE_ESTIMATION_API_KEY is required when OPENAI_PRICE_ESTIMATION_ENABLED=true",
|
||||
);
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
const messages = errors
|
||||
.flatMap((error) => Object.values(error.constraints ?? {}))
|
||||
|
||||
Reference in New Issue
Block a user