Merge pull request #56391 from nextcloud/backport/56350/stable29
Some checks failed
Integration sqlite / changes (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, --tags ~@large files_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, capabilities_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, collaboration_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, comments_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, dav_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, federation_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, filesdrop_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, ldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_numerical_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, remoteapi_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, setup_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharees_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharing_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, videoverification_features) (push) Has been cancelled
Integration sqlite / integration-sqlite-summary (push) Has been cancelled

[stable29] Add AI input limits
This commit is contained in:
Joas Schilling 2025-11-12 16:43:29 +01:00 committed by GitHub
commit bc84a7f8dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 0 deletions

View file

@ -117,6 +117,9 @@ class TextProcessingApiController extends \OCP\AppFramework\OCSController {
#[AnonRateLimit(limit: 5, period: 120)]
#[ApiRoute(verb: 'POST', url: '/schedule', root: '/textprocessing')]
public function schedule(string $input, string $type, string $appId, string $identifier = ''): DataResponse {
if (strlen($input) > 64_000) {
return new DataResponse(['message' => $this->l->t('Input text is too long')], Http::STATUS_BAD_REQUEST);
}
try {
$task = new Task($type, $input, $appId, $this->userId, $identifier);
} catch (InvalidArgumentException) {

View file

@ -93,6 +93,9 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
#[UserRateLimit(limit: 20, period: 120)]
#[ApiRoute(verb: 'POST', url: '/schedule', root: '/text2image')]
public function schedule(string $input, string $appId, string $identifier = '', int $numberOfImages = 8): DataResponse {
if (strlen($input) > 64_000) {
return new DataResponse(['message' => $this->l->t('Input text is too long')], Http::STATUS_PRECONDITION_FAILED);
}
$task = new Task($input, $appId, $numberOfImages, $this->userId, $identifier);
try {
try {

View file

@ -82,6 +82,9 @@ class TranslationApiController extends \OCP\AppFramework\OCSController {
*/
#[ApiRoute(verb: 'POST', url: '/translate', root: '/translation')]
public function translate(string $text, ?string $fromLanguage, string $toLanguage): DataResponse {
if (strlen($text) > 64_000) {
return new DataResponse(['message' => $this->l10n->t('Input text is too long')], Http::STATUS_BAD_REQUEST);
}
try {
$translation = $this->translationManager->translate($text, $fromLanguage, $toLanguage);