Skip to content

Commit

Permalink
feat: added TextToImageSingle TaskType the to TaskProcessing API
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Aug 12, 2024
1 parent b34edf2 commit f6a4589
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@
'OCP\\TaskProcessing\\TaskTypes\\ContextWrite' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ContextWrite.php',
'OCP\\TaskProcessing\\TaskTypes\\GenerateEmoji' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToImage' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToImage.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToImageSingle' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToImageSingle.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToText' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToText.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextChat' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextChat.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextFormalization' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextFormalization.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\TaskProcessing\\TaskTypes\\ContextWrite' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ContextWrite.php',
'OCP\\TaskProcessing\\TaskTypes\\GenerateEmoji' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToImage' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToImage.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToImageSingle' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToImageSingle.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToText' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToText.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextChat' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextChat.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextFormalization' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextFormalization.php',
Expand Down
1 change: 1 addition & 0 deletions lib/private/TaskProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ private function _getTaskTypes(): array {
\OCP\TaskProcessing\TaskTypes\TextToTextTranslate::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextTranslate::class),
\OCP\TaskProcessing\TaskTypes\TextToTextReformulation::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextReformulation::class),
\OCP\TaskProcessing\TaskTypes\TextToImage::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToImage::class),
\OCP\TaskProcessing\TaskTypes\TextToImageSingle::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToImage::class),
\OCP\TaskProcessing\TaskTypes\AudioToText::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\AudioToText::class),
\OCP\TaskProcessing\TaskTypes\ContextWrite::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\ContextWrite::class),
\OCP\TaskProcessing\TaskTypes\GenerateEmoji::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\GenerateEmoji::class),
Expand Down
92 changes: 92 additions & 0 deletions lib/public/TaskProcessing/TaskTypes/TextToImageSingle.php
Original file line number Diff line number Diff line change
@@ -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 image generation
* @since 30.0.0
*/
class TextToImageSingle implements ITaskType {
/**
* @since 30.0.0
*/
public const ID = 'core:text2image:single';

private IL10N $l;

/**
* @param IFactory $l10nFactory
* @since 30.0.0
*/
public function __construct(
IFactory $l10nFactory,
) {
$this->l = $l10nFactory->get('core');
}


/**
* @inheritDoc
* @since 30.0.0
*/
public function getName(): string {
return $this->l->t('Generate image');
}

/**
* @inheritDoc
* @since 30.0.0
*/
public function getDescription(): string {
return $this->l->t('Generate an image from a text prompt');
}

/**
* @return string
* @since 30.0.0
*/
public function getId(): string {
return self::ID;
}

/**
* @return ShapeDescriptor[]
* @since 30.0.0
*/
public function getInputShape(): array {
return [
'input' => new ShapeDescriptor(
$this->l->t('Prompt'),
$this->l->t('Describe the image you want to generate'),
EShapeType::Text
)
];
}

/**
* @return ShapeDescriptor[]
* @since 30.0.0
*/
public function getOutputShape(): array {
return [
'images' => new ShapeDescriptor(
$this->l->t('Output image'),
$this->l->t('The generated image'),
EShapeType::Image
),
];
}
}

0 comments on commit f6a4589

Please sign in to comment.