mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 18:50:47 -04:00
fix(TextToImage): Refactor scheduling mechanism
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
7d9c274dcb
commit
af1fd5e0c7
2 changed files with 12 additions and 0 deletions
|
|
@ -93,6 +93,12 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -83,6 +83,12 @@ final class Task implements \JsonSerializable {
|
|||
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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue