latestOpenAPI 3.0.02026-08-10525163.8 KB
327b3674db26
/ai/module/
description: "Access Token is incorrect.", type: ApiError, })
status: HttpStatus.PAYMENT_REQUIRED,
description: "An active subscription required to access this endpoint.",
type: ApiError,
})
description: "A conflict error occured.",
type: ApiError,
})
description: "The training request has been successfully sent.",
type: AiModuleDto,
})
description: "A validation error occured.",
type: ApiError,
}) async trainModule(
): Promise<AiModuleDto> { const user: User = req.user;
if (!aiTrainingRequest)
throw new HttpException("Incorrect body.", HttpStatus.BAD_REQUEST);
if (
!GenerationModelAccessRightsData[aiTrainingRequest.model].canTrainModules
)
throw new HttpException(
"Specified model does not support module training.",
HttpStatus.BAD_REQUEST,
);
if (!user.hasSubscription()) throw new HttpException( "Incorrect subscription.", HttpStatus.PAYMENT_REQUIRED, ); if (aiTrainingRequest.steps < 50) throw new HttpException( "Training steps amount is too low.", HttpStatus.CONFLICT, );
if (
user.availableModuleTrainingSteps + user.purchasedModuleTrainingSteps <
aiTrainingRequest.steps
)
throw new HttpException(
"You have an insufficent amount of available training steps.",
HttpStatus.CONFLICT,
);
if (process.env.NODE_ENV === "production") {
const modules = (
await this.aiModuleService.getAllUserModules(user)
).filter((item) => item.status == "pending" || item.status == "training");
if (modules.length >= MAX_SIMULTANEOUS_TRAINING_MODULES)
throw new HttpException(
"You have reached the limit of concurrently training modules.",
HttpStatus.CONFLICT,
);
}
return await this.aiModuleService.trainModule(user, aiTrainingRequest);
}
get/ai/module/all