Skip to content

Commit

Permalink
feat(TaskProcessing): Add more task types
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jul 4, 2024
1 parent eed6216 commit d9cf6e6
Show file tree
Hide file tree
Showing 7 changed files with 389 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,11 @@
'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\\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',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextHeadline' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextHeadline.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextReformulation' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextReformulation.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextSimplification' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextSimplification.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextSummary' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTopics' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php',
'OCP\\Teams\\ITeamManager' => $baseDir . '/lib/public/Teams/ITeamManager.php',
Expand Down
4 changes: 4 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,11 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'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\\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',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextHeadline' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextHeadline.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextReformulation' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextReformulation.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextSimplification' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextSimplification.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextSummary' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextSummary.php',
'OCP\\TaskProcessing\\TaskTypes\\TextToTextTopics' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/TextToTextTopics.php',
'OCP\\Teams\\ITeamManager' => __DIR__ . '/../../..' . '/lib/public/Teams/ITeamManager.php',
Expand Down
3 changes: 3 additions & 0 deletions lib/private/TaskProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ private function _getTaskTypes(): array {
\OCP\TaskProcessing\TaskTypes\TextToTextTopics::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextTopics::class),
\OCP\TaskProcessing\TaskTypes\TextToTextHeadline::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextHeadline::class),
\OCP\TaskProcessing\TaskTypes\TextToTextSummary::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextSummary::class),
\OCP\TaskProcessing\TaskTypes\TextToTextFormalization::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextFormalization::class),
\OCP\TaskProcessing\TaskTypes\TextToTextSimplification::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextSimplification::class),
\OCP\TaskProcessing\TaskTypes\TextToTextChat::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextChat::class),
\OCP\TaskProcessing\TaskTypes\TextToImage::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),
Expand Down
102 changes: 102 additions & 0 deletions lib/public/TaskProcessing/TaskTypes/TextToTextChat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?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 text chat
* @since 30.0.0
*/
class TextToTextChat implements ITaskType {
/**
* @since 30.0.0
*/
public const ID = 'core:text2text:chat';

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('Chat');
}

/**
* @inheritDoc
* @since 30.0.0
*/
public function getDescription(): string {
return $this->l->t('Chat with the assistant');
}

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

/**
* @return ShapeDescriptor[]
* @since 30.0.0
*/
public function getInputShape(): array {
return [
'system_prompt' => new ShapeDescriptor(
$this->l->t('System prompt'),
$this->l->t('Define rules and assumptions that the assistant should follow during the conversation.'),
EShapeType::Text
),
'input' => new ShapeDescriptor(
$this->l->t('Chat message'),
$this->l->t('Describe a task that you want the assistant to do or ask a question'),
EShapeType::Text
),
'history' => new ShapeDescriptor(
$this->l->t('Chat history'),
$this->l->t('The history of chat messages before the current message, starting with a message by the user'),
EShapeType::ListOfTexts
)
];
}

/**
* @return ShapeDescriptor[]
* @since 30.0.0
*/
public function getOutputShape(): array {
return [
'output' => new ShapeDescriptor(
$this->l->t('Response message'),
$this->l->t('The generated response as part of the conversation'),
EShapeType::Text
),
];
}
}
92 changes: 92 additions & 0 deletions lib/public/TaskProcessing/TaskTypes/TextToTextFormalization.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 text formalization
* @since 30.0.0
*/
class TextToTextFormalization implements ITaskType {
/**
* @since 30.0.0
*/
public const ID = 'core:text2text:formalization';

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('Formalize text');
}

/**
* @inheritDoc
* @since 30.0.0
*/
public function getDescription(): string {
return $this->l->t('Takes a text and makes it sound more formal');
}

/**
* @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('Input text'),
$this->l->t('Write a text that you want the assistant to formalize'),
EShapeType::Text
),
];
}

/**
* @return ShapeDescriptor[]
* @since 30.0.0
*/
public function getOutputShape(): array {
return [
'output' => new ShapeDescriptor(
$this->l->t('Formalized text'),
$this->l->t('The formalized text'),
EShapeType::Text
),
];
}
}
92 changes: 92 additions & 0 deletions lib/public/TaskProcessing/TaskTypes/TextToTextReformulation.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 text reformulation
* @since 30.0.0
*/
class TextToTextReformulation implements ITaskType {
/**
* @since 30.0.0
*/
public const ID = 'core:text2text:reformulation';

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('Reformulate text');
}

/**
* @inheritDoc
* @since 30.0.0
*/
public function getDescription(): string {
return $this->l->t('Takes a text and reformulates it');
}

/**
* @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('Input text'),
$this->l->t('Write a text that you want the assistant to reformulate'),
EShapeType::Text
),
];
}

/**
* @return ShapeDescriptor[]
* @since 30.0.0
*/
public function getOutputShape(): array {
return [
'output' => new ShapeDescriptor(
$this->l->t('Reformulated text'),
$this->l->t('The reformulated text, written by the assistant'),
EShapeType::Text
),
];
}
}
Loading

0 comments on commit d9cf6e6

Please sign in to comment.