diff options
Diffstat (limited to 'lib/public/TaskProcessing')
20 files changed, 181 insertions, 21 deletions
diff --git a/lib/public/TaskProcessing/EShapeType.php b/lib/public/TaskProcessing/EShapeType.php index cd8d6d837da..f6cfab6b38f 100644 --- a/lib/public/TaskProcessing/EShapeType.php +++ b/lib/public/TaskProcessing/EShapeType.php @@ -154,19 +154,19 @@ enum EShapeType: int { if ($this === EShapeType::ListOfImages && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) { throw new ValidationException('Non-image list item provided for ListOfImages slot'); } - if ($this === EShapeType::Audio && !is_string($value)) { + if ($this === EShapeType::Audio && !is_numeric($value)) { throw new ValidationException('Non-audio item provided for Audio slot'); } if ($this === EShapeType::ListOfAudios && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) { throw new ValidationException('Non-audio list item provided for ListOfAudio slot'); } - if ($this === EShapeType::Video && !is_string($value)) { + if ($this === EShapeType::Video && !is_numeric($value)) { throw new ValidationException('Non-video item provided for Video slot'); } if ($this === EShapeType::ListOfVideos && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) { throw new ValidationException('Non-video list item provided for ListOfTexts slot'); } - if ($this === EShapeType::File && !is_string($value)) { + if ($this === EShapeType::File && !is_numeric($value)) { throw new ValidationException('Non-file item provided for File slot'); } if ($this === EShapeType::ListOfFiles && (!is_array($value) || count(array_filter($value, fn ($item) => !is_numeric($item))) > 0)) { diff --git a/lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php b/lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php new file mode 100644 index 00000000000..10c94d20406 --- /dev/null +++ b/lib/public/TaskProcessing/Events/GetTaskProcessingProvidersEvent.php @@ -0,0 +1,68 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\TaskProcessing\Events; + +use OCP\EventDispatcher\Event; +use OCP\TaskProcessing\IProvider; +use OCP\TaskProcessing\ITaskType; + +/** + * Event dispatched by the server to collect Task Processing Providers + * and custom Task Types from listeners (like AppAPI). + * + * Listeners should add their providers and task types using the + * addProvider() and addTaskType() methods. + * + * @since 32.0.0 + */ +class GetTaskProcessingProvidersEvent extends Event { + /** @var IProvider[] */ + private array $providers = []; + + /** @var ITaskType[] */ + private array $taskTypes = []; + + /** + * Add a Task Processing Provider. + * + * @param IProvider $provider The provider instance to add. + * @since 32.0.0 + */ + public function addProvider(IProvider $provider): void { + $this->providers[] = $provider; + } + + /** + * Get all collected Task Processing Providers. + * + * @return IProvider[] + * @since 32.0.0 + */ + public function getProviders(): array { + return $this->providers; + } + + /** + * Add a custom Task Processing Task Type. + * + * @param ITaskType $taskType The task type instance to add. + * @since 32.0.0 + */ + public function addTaskType(ITaskType $taskType): void { + $this->taskTypes[] = $taskType; + } + + /** + * Get all collected custom Task Processing Task Types. + * + * @return ITaskType[] + * @since 32.0.0 + */ + public function getTaskTypes(): array { + return $this->taskTypes; + } +} diff --git a/lib/public/TaskProcessing/TaskTypes/AudioToText.php b/lib/public/TaskProcessing/TaskTypes/AudioToText.php index 3f23d00d41b..1982d4c9d28 100644 --- a/lib/public/TaskProcessing/TaskTypes/AudioToText.php +++ b/lib/public/TaskProcessing/TaskTypes/AudioToText.php @@ -34,7 +34,7 @@ class AudioToText implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/ContextAgentInteraction.php b/lib/public/TaskProcessing/TaskTypes/ContextAgentInteraction.php index f5bef6b48e3..cd08d6f4e3d 100644 --- a/lib/public/TaskProcessing/TaskTypes/ContextAgentInteraction.php +++ b/lib/public/TaskProcessing/TaskTypes/ContextAgentInteraction.php @@ -31,7 +31,7 @@ class ContextAgentInteraction implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } /** @@ -39,7 +39,7 @@ class ContextAgentInteraction implements ITaskType { * @since 31.0.0 */ public function getName(): string { - return $this->l->t('ContextAgent'); + return 'ContextAgent'; // We do not translate this } /** diff --git a/lib/public/TaskProcessing/TaskTypes/ContextWrite.php b/lib/public/TaskProcessing/TaskTypes/ContextWrite.php index 36ee8f24d3f..fd5c6a8f58b 100644 --- a/lib/public/TaskProcessing/TaskTypes/ContextWrite.php +++ b/lib/public/TaskProcessing/TaskTypes/ContextWrite.php @@ -34,7 +34,7 @@ class ContextWrite implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php b/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php index 89ddfa58072..2cb22b3b455 100644 --- a/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php +++ b/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php @@ -34,7 +34,7 @@ class GenerateEmoji implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToImage.php b/lib/public/TaskProcessing/TaskTypes/TextToImage.php index a4b8070e8bb..ed956d244a1 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToImage.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToImage.php @@ -34,7 +34,7 @@ class TextToImage implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToSpeech.php b/lib/public/TaskProcessing/TaskTypes/TextToSpeech.php new file mode 100644 index 00000000000..ce35be32a6f --- /dev/null +++ b/lib/public/TaskProcessing/TaskTypes/TextToSpeech.php @@ -0,0 +1,92 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\TaskProcessing\TaskTypes; + +use OCP\IL10N; +use OCP\L10N\IFactory; +use OCP\TaskProcessing\EShapeType; +use OCP\TaskProcessing\ITaskType; +use OCP\TaskProcessing\ShapeDescriptor; + +/** + * This is the task processing task type for speech generation + * @since 32.0.0 + */ +class TextToSpeech implements ITaskType { + /** + * @since 32.0.0 + */ + public const ID = 'core:text2speech'; + + private IL10N $l; + + /** + * @param IFactory $l10nFactory + * @since 32.0.0 + */ + public function __construct( + IFactory $l10nFactory, + ) { + $this->l = $l10nFactory->get('lib'); + } + + + /** + * @inheritDoc + * @since 32.0.0 + */ + public function getName(): string { + return $this->l->t('Generate speech'); + } + + /** + * @inheritDoc + * @since 32.0.0 + */ + public function getDescription(): string { + return $this->l->t('Generate speech from a transcript'); + } + + /** + * @return string + * @since 32.0.0 + */ + public function getId(): string { + return self::ID; + } + + /** + * @return ShapeDescriptor[] + * @since 32.0.0 + */ + public function getInputShape(): array { + return [ + 'input' => new ShapeDescriptor( + $this->l->t('Prompt'), + $this->l->t('Write transcript that you want the assistant to generate speech from'), + EShapeType::Text + ), + ]; + } + + /** + * @return ShapeDescriptor[] + * @since 32.0.0 + */ + public function getOutputShape(): array { + return [ + 'speech' => new ShapeDescriptor( + $this->l->t('Output speech'), + $this->l->t('The generated speech'), + EShapeType::Audio + ), + ]; + } +} diff --git a/lib/public/TaskProcessing/TaskTypes/TextToText.php b/lib/public/TaskProcessing/TaskTypes/TextToText.php index 92eaf5629e8..c39d435688a 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToText.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToText.php @@ -34,7 +34,7 @@ class TextToText implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextChangeTone.php b/lib/public/TaskProcessing/TaskTypes/TextToTextChangeTone.php index bab60976454..0ea4575a187 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextChangeTone.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextChangeTone.php @@ -31,7 +31,7 @@ class TextToTextChangeTone implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } /** diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextChat.php b/lib/public/TaskProcessing/TaskTypes/TextToTextChat.php index e9169f64837..9cf1e7ef3ce 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextChat.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextChat.php @@ -34,7 +34,7 @@ class TextToTextChat implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextChatWithTools.php b/lib/public/TaskProcessing/TaskTypes/TextToTextChatWithTools.php index e09211e940b..ebc660a3af9 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextChatWithTools.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextChatWithTools.php @@ -31,7 +31,7 @@ class TextToTextChatWithTools implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } /** diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextFormalization.php b/lib/public/TaskProcessing/TaskTypes/TextToTextFormalization.php index 81eff28f3e9..70e38f78c0b 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextFormalization.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextFormalization.php @@ -34,7 +34,7 @@ class TextToTextFormalization implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextHeadline.php b/lib/public/TaskProcessing/TaskTypes/TextToTextHeadline.php index 9907a3605b2..dde4ea03042 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextHeadline.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextHeadline.php @@ -34,7 +34,7 @@ class TextToTextHeadline implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextProofread.php b/lib/public/TaskProcessing/TaskTypes/TextToTextProofread.php index 09f2111e22e..508794490be 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextProofread.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextProofread.php @@ -33,7 +33,7 @@ class TextToTextProofread implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextReformulation.php b/lib/public/TaskProcessing/TaskTypes/TextToTextReformulation.php index 44c1fddc73c..120f5316aee 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextReformulation.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextReformulation.php @@ -34,7 +34,7 @@ class TextToTextReformulation implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextSimplification.php b/lib/public/TaskProcessing/TaskTypes/TextToTextSimplification.php index 580b9d92755..d107e584e3a 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextSimplification.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextSimplification.php @@ -34,7 +34,7 @@ class TextToTextSimplification implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php b/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php index 8b00c64f915..601b478c0bd 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php @@ -33,7 +33,7 @@ class TextToTextSummary implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php b/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php index a08ec6d2c0f..943cc2e2fd4 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php @@ -34,7 +34,7 @@ class TextToTextTopics implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } diff --git a/lib/public/TaskProcessing/TaskTypes/TextToTextTranslate.php b/lib/public/TaskProcessing/TaskTypes/TextToTextTranslate.php index 11b71ec3eb2..a02550226ee 100644 --- a/lib/public/TaskProcessing/TaskTypes/TextToTextTranslate.php +++ b/lib/public/TaskProcessing/TaskTypes/TextToTextTranslate.php @@ -34,7 +34,7 @@ class TextToTextTranslate implements ITaskType { public function __construct( IFactory $l10nFactory, ) { - $this->l = $l10nFactory->get('core'); + $this->l = $l10nFactory->get('lib'); } |