mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
feat(TaskProcessing): Add more task types
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
eed6216d55
commit
d9cf6e61c8
7 changed files with 389 additions and 0 deletions
|
|
@ -733,7 +733,11 @@ return array(
|
|||
'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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -393,6 +393,9 @@ class Manager implements IManager {
|
|||
\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),
|
||||
|
|
|
|||
102
lib/public/TaskProcessing/TaskTypes/TextToTextChat.php
Normal file
102
lib/public/TaskProcessing/TaskTypes/TextToTextChat.php
Normal file
|
|
@ -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
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -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 simplification
|
||||
* @since 30.0.0
|
||||
*/
|
||||
class TextToTextSimplification implements ITaskType {
|
||||
/**
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public const ID = 'core:text2text:simplification';
|
||||
|
||||
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('Simplify text');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public function getDescription(): string {
|
||||
return $this->l->t('Takes a text and simplifies 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 simplify'),
|
||||
EShapeType::Text
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShapeDescriptor[]
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public function getOutputShape(): array {
|
||||
return [
|
||||
'output' => new ShapeDescriptor(
|
||||
$this->l->t('Simplified text'),
|
||||
$this->l->t('The simplified text'),
|
||||
EShapeType::Text
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue