Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/Controller/TextToImageApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public function schedule(string $input, string $appId, string $identifier = '',
if (strlen($input) > 64_000) {
return new DataResponse(['message' => $this->l->t('Input text is too long')], Http::STATUS_PRECONDITION_FAILED);
}
if ($numberOfImages > 12) {
return new DataResponse(['message' => $this->l->t('Cannot generate more than 12 images')], Http::STATUS_PRECONDITION_FAILED);
}
if ($numberOfImages < 1) {
return new DataResponse(['message' => $this->l->t('Cannot generate less than 1 image')], Http::STATUS_PRECONDITION_FAILED);
}
$task = new Task($input, $appId, $numberOfImages, $this->userId, $identifier);
try {
try {
Expand Down
6 changes: 6 additions & 0 deletions lib/public/TextToImage/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ final public function __construct(
protected ?string $userId,
protected ?string $identifier = '',
) {
if ($this->numberOfImages > 12) {
throw new \ValueError('Cannot generate more than 12 images');
}
if ($this->numberOfImages < 1) {
throw new \ValueError('Cannot generate less than 1 image');
}
}

/**
Expand Down
Loading