diff options
author | Marcel Klehr <mklehr@gmx.net> | 2023-07-21 11:20:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-21 11:20:31 +0200 |
commit | 7c80d66ee5cbbc4e40dfa1a7e0ef115b62980942 (patch) | |
tree | 37053a55e2329bf05f6a166342096d8616b83ecc /lib/public | |
parent | e9b8a34cce59c7bd6ef6bec6b9c4846c062e4a7b (diff) | |
parent | 6d568b0d32d1255f76608e9d6b4b154dc57e5fea (diff) | |
download | nextcloud-server-7c80d66ee5cbbc4e40dfa1a7e0ef115b62980942.tar.gz nextcloud-server-7c80d66ee5cbbc4e40dfa1a7e0ef115b62980942.zip |
Merge pull request #38854 from nextcloud/enh/llm-api
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/AppFramework/Bootstrap/IRegistrationContext.php | 11 | ||||
-rw-r--r-- | lib/public/Common/Exception/NotFoundException.php | 41 | ||||
-rw-r--r-- | lib/public/TextProcessing/Events/AbstractTextProcessingEvent.php | 51 | ||||
-rw-r--r-- | lib/public/TextProcessing/Events/TaskFailedEvent.php | 30 | ||||
-rw-r--r-- | lib/public/TextProcessing/Events/TaskSuccessfulEvent.php | 9 | ||||
-rw-r--r-- | lib/public/TextProcessing/FreePromptTaskType.php | 62 | ||||
-rw-r--r-- | lib/public/TextProcessing/HeadlineTaskType.php | 62 | ||||
-rw-r--r-- | lib/public/TextProcessing/IManager.php | 77 | ||||
-rw-r--r-- | lib/public/TextProcessing/IProvider.php | 62 | ||||
-rw-r--r-- | lib/public/TextProcessing/ITaskType.php | 49 | ||||
-rw-r--r-- | lib/public/TextProcessing/SummaryTaskType.php | 62 | ||||
-rw-r--r-- | lib/public/TextProcessing/Task.php | 221 | ||||
-rw-r--r-- | lib/public/TextProcessing/TopicsTaskType.php | 62 |
13 files changed, 799 insertions, 0 deletions
diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index 66cf1ef2306..720803a78d1 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -37,6 +37,7 @@ use OCP\Collaboration\Reference\IReferenceProvider; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Template\ICustomTemplateProvider; use OCP\IContainer; +use OCP\TextProcessing\IProvider as ITextProcessingProvider; use OCP\Notification\INotifier; use OCP\Preview\IProviderV2; use OCP\SpeechToText\ISpeechToTextProvider; @@ -220,6 +221,16 @@ interface IRegistrationContext { public function registerSpeechToTextProvider(string $providerClass): void; /** + * Register a custom text processing provider class that provides a promptable language model + * through the OCP\TextProcessing APIs + * + * @param string $providerClass + * @psalm-param class-string<ITextProcessingProvider> $providerClass + * @since 27.1.0 + */ + public function registerTextProcessingProvider(string $providerClass): void; + + /** * Register a custom template provider class that is able to inject custom templates * in addition to the user defined ones * diff --git a/lib/public/Common/Exception/NotFoundException.php b/lib/public/Common/Exception/NotFoundException.php new file mode 100644 index 00000000000..a30e1c42b8b --- /dev/null +++ b/lib/public/Common/Exception/NotFoundException.php @@ -0,0 +1,41 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCP\Common\Exception; + +/** + * This is thrown whenever something was expected to exist but doesn't + * + * @since 27.1.0 + */ +class NotFoundException extends \Exception { + /** + * Constructor + * @param string $msg the error message + * @since 27.1.0 + */ + public function __construct(string $msg) { + parent::__construct($msg); + } +} diff --git a/lib/public/TextProcessing/Events/AbstractTextProcessingEvent.php b/lib/public/TextProcessing/Events/AbstractTextProcessingEvent.php new file mode 100644 index 00000000000..329889e61f0 --- /dev/null +++ b/lib/public/TextProcessing/Events/AbstractTextProcessingEvent.php @@ -0,0 +1,51 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCP\TextProcessing\Events; + +use OCP\EventDispatcher\Event; +use OCP\TextProcessing\Task; + +/** + * @since 27.1.0 + */ +abstract class AbstractTextProcessingEvent extends Event { + /** + * @since 27.1.0 + */ + public function __construct( + private Task $task + ) { + parent::__construct(); + } + + /** + * @return Task + * @since 27.1.0 + */ + public function getTask(): Task { + return $this->task; + } +} diff --git a/lib/public/TextProcessing/Events/TaskFailedEvent.php b/lib/public/TextProcessing/Events/TaskFailedEvent.php new file mode 100644 index 00000000000..f9765e362dc --- /dev/null +++ b/lib/public/TextProcessing/Events/TaskFailedEvent.php @@ -0,0 +1,30 @@ +<?php + +namespace OCP\TextProcessing\Events; + +use OCP\TextProcessing\Task; + +/** + * @since 27.1.0 + */ +class TaskFailedEvent extends AbstractTextProcessingEvent { + /** + * @param Task $task + * @param string $errorMessage + * @since 27.1.0 + */ + public function __construct( + Task $task, + private string $errorMessage, + ) { + parent::__construct($task); + } + + /** + * @return string + * @since 27.1.0 + */ + public function getErrorMessage(): string { + return $this->errorMessage; + } +} diff --git a/lib/public/TextProcessing/Events/TaskSuccessfulEvent.php b/lib/public/TextProcessing/Events/TaskSuccessfulEvent.php new file mode 100644 index 00000000000..df4d2ba6227 --- /dev/null +++ b/lib/public/TextProcessing/Events/TaskSuccessfulEvent.php @@ -0,0 +1,9 @@ +<?php + +namespace OCP\TextProcessing\Events; + +/** + * @since 27.1.0 + */ +class TaskSuccessfulEvent extends AbstractTextProcessingEvent { +} diff --git a/lib/public/TextProcessing/FreePromptTaskType.php b/lib/public/TextProcessing/FreePromptTaskType.php new file mode 100644 index 00000000000..dcc27df77c9 --- /dev/null +++ b/lib/public/TextProcessing/FreePromptTaskType.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\TextProcessing; + +use OCP\IL10N; + +/** + * This is the text processing task type for free prompting + * @since 27.1.0 + */ +class FreePromptTaskType implements ITaskType { + /** + * Constructor for FreePromptTaskType + * + * @param IL10N $l + * @since 27.1.0 + */ + public function __construct( + private IL10N $l, + ) { + } + + + /** + * @inheritDoc + * @since 27.1.0 + */ + public function getName(): string { + return $this->l->t('Free prompt'); + } + + /** + * @inheritDoc + * @since 27.1.0 + */ + public function getDescription(): string { + return $this->l->t('Runs an arbitrary prompt through the built-in language model.'); + } +} diff --git a/lib/public/TextProcessing/HeadlineTaskType.php b/lib/public/TextProcessing/HeadlineTaskType.php new file mode 100644 index 00000000000..ad38848ea87 --- /dev/null +++ b/lib/public/TextProcessing/HeadlineTaskType.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\TextProcessing; + +use OCP\IL10N; + +/** + * This is the text processing task type for creating headline + * @since 27.1.0 + */ +class HeadlineTaskType implements ITaskType { + /** + * Constructor for HeadlineTaskType + * + * @param IL10N $l + * @since 27.1.0 + */ + public function __construct( + private IL10N $l, + ) { + } + + + /** + * @inheritDoc + * @since 27.1.0 + */ + public function getName(): string { + return $this->l->t('Generate headline'); + } + + /** + * @inheritDoc + * @since 27.1.0 + */ + public function getDescription(): string { + return $this->l->t('Generates a possible headline for a text'); + } +} diff --git a/lib/public/TextProcessing/IManager.php b/lib/public/TextProcessing/IManager.php new file mode 100644 index 00000000000..90e25894d4f --- /dev/null +++ b/lib/public/TextProcessing/IManager.php @@ -0,0 +1,77 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +namespace OCP\TextProcessing; + +use OCP\Common\Exception\NotFoundException; +use OCP\PreConditionNotMetException; +use RuntimeException; + +/** + * API surface for apps interacting with and making use of LanguageModel providers + * without known which providers are installed + * @since 27.1.0 + */ +interface IManager { + /** + * @since 27.1.0 + */ + public function hasProviders(): bool; + + /** + * @return class-string<ITaskType>[] + * @since 27.1.0 + */ + public function getAvailableTaskTypes(): array; + + /** + * @param Task $task The task to run + * @throws PreConditionNotMetException If no or not the requested provider was registered but this method was still called + * @throws RuntimeException If something else failed + * @since 27.1.0 + */ + public function runTask(Task $task): string; + + /** + * Will schedule an LLM inference process in the background. The result will become available + * with the \OCP\LanguageModel\Events\TaskSuccessfulEvent + * If inference fails a \OCP\LanguageModel\Events\TaskFailedEvent will be dispatched instead + * + * @param Task $task The task to schedule + * @throws PreConditionNotMetException If no or not the requested provider was registered but this method was still called + * @since 27.1.0 + */ + public function scheduleTask(Task $task) : void; + + /** + * @param int $id The id of the task + * @return Task + * @throws RuntimeException If the query failed + * @throws NotFoundException If the task could not be found + * @since 27.1.0 + */ + public function getTask(int $id): Task; +} diff --git a/lib/public/TextProcessing/IProvider.php b/lib/public/TextProcessing/IProvider.php new file mode 100644 index 00000000000..6132e60b493 --- /dev/null +++ b/lib/public/TextProcessing/IProvider.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +namespace OCP\TextProcessing; + +use RuntimeException; + +/** + * This is the interface that is implemented by apps that + * implement a text processing provider + * @template T of ITaskType + * @since 27.1.0 + */ +interface IProvider { + /** + * The localized name of this provider + * @since 27.1.0 + */ + public function getName(): string; + + /** + * Processes a text + * + * @param string $prompt The input text + * @return string the output text + * @since 27.1.0 + * @throws RuntimeException If the text could not be processed + */ + public function process(string $prompt): string; + + /** + * Returns the task type class string of the task type, that this + * provider handles + * + * @since 27.1.0 + * @return class-string<T> + */ + public function getTaskType(): string; +} diff --git a/lib/public/TextProcessing/ITaskType.php b/lib/public/TextProcessing/ITaskType.php new file mode 100644 index 00000000000..d08da3f7ac7 --- /dev/null +++ b/lib/public/TextProcessing/ITaskType.php @@ -0,0 +1,49 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\TextProcessing; + +/** + * This is a task type interface that is implemented by text processing + * task types + * @since 27.1.0 + */ +interface ITaskType { + /** + * Returns the localized name of this task type + * + * @since 27.1.0 + * @return string + */ + public function getName(): string; + + /** + * Returns the localized description of this task type + * + * @since 27.1.0 + * @return string + */ + public function getDescription(): string; +} diff --git a/lib/public/TextProcessing/SummaryTaskType.php b/lib/public/TextProcessing/SummaryTaskType.php new file mode 100644 index 00000000000..3d80cee47f8 --- /dev/null +++ b/lib/public/TextProcessing/SummaryTaskType.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\TextProcessing; + +use OCP\IL10N; + +/** + * This is the text processing task type for summaries + * @since 27.1.0 + */ +class SummaryTaskType implements ITaskType { + /** + * Constructor for SummaryTaskType + * + * @param IL10N $l + * @since 27.1.0 + */ + public function __construct( + private IL10N $l, + ) { + } + + + /** + * @inheritDoc + * @since 27.1.0 + */ + public function getName(): string { + return $this->l->t('Summarize'); + } + + /** + * @inheritDoc + * @since 27.1.0 + */ + public function getDescription(): string { + return $this->l->t('Summarizes text by reducing its length without losing key information.'); + } +} diff --git a/lib/public/TextProcessing/Task.php b/lib/public/TextProcessing/Task.php new file mode 100644 index 00000000000..446e414cb04 --- /dev/null +++ b/lib/public/TextProcessing/Task.php @@ -0,0 +1,221 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\TextProcessing; + +/** + * This is a text processing task + * @since 27.1.0 + * @psalm-template T of ITaskType + * @psalm-template S as class-string<T> + * @psalm-template P as IProvider<T> + */ +final class Task implements \JsonSerializable { + protected ?int $id = null; + protected ?string $output = null; + + /** + * @since 27.1.0 + */ + public const TYPES = [ + FreePromptTaskType::class, + SummaryTaskType::class, + HeadlineTaskType::class, + TopicsTaskType::class, + ]; + + /** + * @since 27.1.0 + */ + public const STATUS_FAILED = 4; + /** + * @since 27.1.0 + */ + public const STATUS_SUCCESSFUL = 3; + /** + * @since 27.1.0 + */ + public const STATUS_RUNNING = 2; + /** + * @since 27.1.0 + */ + public const STATUS_SCHEDULED = 1; + /** + * @since 27.1.0 + */ + public const STATUS_UNKNOWN = 0; + + /** + * @psalm-var self::STATUS_* + */ + protected int $status = self::STATUS_UNKNOWN; + + /** + * @psalm-param S $type + * @param string $type + * @param string $input + * @param string $appId + * @param string|null $userId + * @param string $identifier An arbitrary identifier for this task. max length: 255 chars + * @since 27.1.0 + */ + final public function __construct( + protected string $type, + protected string $input, + protected string $appId, + protected ?string $userId, + protected string $identifier = '', + ) { + } + + /** + * @psalm-param P $provider + * @param IProvider $provider + * @return string + * @since 27.1.0 + */ + public function visitProvider(IProvider $provider): string { + if ($this->canUseProvider($provider)) { + return $provider->process($this->getInput()); + } else { + throw new \RuntimeException('Task of type ' . $this->getType() . ' cannot visit provider with task type ' . $provider->getTaskType()); + } + } + + /** + * @psalm-param P $provider + * @param IProvider $provider + * @return bool + * @since 27.1.0 + */ + public function canUseProvider(IProvider $provider): bool { + return $provider->getTaskType() === $this->getType(); + } + + /** + * @psalm-return S + * @since 27.1.0 + */ + final public function getType(): string { + return $this->type; + } + + /** + * @return string|null + * @since 27.1.0 + */ + final public function getOutput(): ?string { + return $this->output; + } + + /** + * @param string|null $output + * @since 27.1.0 + */ + final public function setOutput(?string $output): void { + $this->output = $output; + } + + /** + * @psalm-return self::STATUS_* + * @since 27.1.0 + */ + final public function getStatus(): int { + return $this->status; + } + + /** + * @psalm-param self::STATUS_* $status + * @since 27.1.0 + */ + final public function setStatus(int $status): void { + $this->status = $status; + } + + /** + * @return int|null + * @since 27.1.0 + */ + final public function getId(): ?int { + return $this->id; + } + + /** + * @param int|null $id + * @since 27.1.0 + */ + final public function setId(?int $id): void { + $this->id = $id; + } + + /** + * @return string + * @since 27.1.0 + */ + final public function getInput(): string { + return $this->input; + } + + /** + * @return string + * @since 27.1.0 + */ + final public function getAppId(): string { + return $this->appId; + } + + /** + * @return string + * @since 27.1.0 + */ + final public function getIdentifier(): string { + return $this->identifier; + } + + /** + * @return string|null + * @since 27.1.0 + */ + final public function getUserId(): ?string { + return $this->userId; + } + + /** + * @psalm-return array{id: ?int, type: S, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, output: ?string, identifier: string} + * @since 27.1.0 + */ + public function jsonSerialize(): array { + return [ + 'id' => $this->getId(), + 'type' => $this->getType(), + 'status' => $this->getStatus(), + 'userId' => $this->getUserId(), + 'appId' => $this->getAppId(), + 'input' => $this->getInput(), + 'output' => $this->getOutput(), + 'identifier' => $this->getIdentifier(), + ]; + } +} diff --git a/lib/public/TextProcessing/TopicsTaskType.php b/lib/public/TextProcessing/TopicsTaskType.php new file mode 100644 index 00000000000..6162b9a13e9 --- /dev/null +++ b/lib/public/TextProcessing/TopicsTaskType.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net> + * + * @author Marcel Klehr <mklehr@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\TextProcessing; + +use OCP\IL10N; + +/** + * This is the text processing task type for topics extraction + * @since 27.1.0 + */ +class TopicsTaskType implements ITaskType { + /** + * Constructor for TopicsTaskType + * + * @param IL10N $l + * @since 27.1.0 + */ + public function __construct( + private IL10N $l, + ) { + } + + + /** + * @inheritDoc + * @since 27.1.0 + */ + public function getName(): string { + return $this->l->t('Extract topics'); + } + + /** + * @inheritDoc + * @since 27.1.0 + */ + public function getDescription(): string { + return $this->l->t('Extracts topics from a text and outputs them separated by commas.'); + } +} |