Skip to content

Commit 50e6f9f

Browse files
committed
feat: add edit image task
Signed-off-by: Lukas Schaefer <lukas@lschaefer.xyz>
1 parent 3bf5565 commit 50e6f9f

4 files changed

Lines changed: 105 additions & 0 deletions

File tree

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@
10381038
'OCP\\TaskProcessing\\TaskTypes\\ContextAgentInteraction' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ContextAgentInteraction.php',
10391039
'OCP\\TaskProcessing\\TaskTypes\\ContextWrite' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ContextWrite.php',
10401040
'OCP\\TaskProcessing\\TaskTypes\\GenerateEmoji' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php',
1041+
'OCP\\TaskProcessing\\TaskTypes\\ImageToImage' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ImageToImage.php',
10411042
'OCP\\TaskProcessing\\TaskTypes\\ImageToTextOpticalCharacterRecognition' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ImageToTextOpticalCharacterRecognition.php',
10421043
'OCP\\TaskProcessing\\TaskTypes\\MultimodalChatWithTools' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/MultimodalChatWithTools.php',
10431044
'OCP\\TaskProcessing\\TaskTypes\\MultimodalContextAgentInteraction' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/MultimodalContextAgentInteraction.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
10791079
'OCP\\TaskProcessing\\TaskTypes\\ContextAgentInteraction' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ContextAgentInteraction.php',
10801080
'OCP\\TaskProcessing\\TaskTypes\\ContextWrite' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ContextWrite.php',
10811081
'OCP\\TaskProcessing\\TaskTypes\\GenerateEmoji' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/GenerateEmoji.php',
1082+
'OCP\\TaskProcessing\\TaskTypes\\ImageToImage' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ImageToImage.php',
10821083
'OCP\\TaskProcessing\\TaskTypes\\ImageToTextOpticalCharacterRecognition' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ImageToTextOpticalCharacterRecognition.php',
10831084
'OCP\\TaskProcessing\\TaskTypes\\MultimodalChatWithTools' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/MultimodalChatWithTools.php',
10841085
'OCP\\TaskProcessing\\TaskTypes\\MultimodalContextAgentInteraction' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/MultimodalContextAgentInteraction.php',

lib/private/TaskProcessing/Manager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
use OCP\TaskProcessing\TaskTypes\ContextAgentInteraction;
8282
use OCP\TaskProcessing\TaskTypes\ContextWrite;
8383
use OCP\TaskProcessing\TaskTypes\GenerateEmoji;
84+
use OCP\TaskProcessing\TaskTypes\ImageToImage;
8485
use OCP\TaskProcessing\TaskTypes\ImageToTextOpticalCharacterRecognition;
8586
use OCP\TaskProcessing\TaskTypes\MultimodalChatWithTools;
8687
use OCP\TaskProcessing\TaskTypes\MultimodalContextAgentInteraction;
@@ -713,6 +714,7 @@ private function _getTaskTypes(): array {
713714
MultimodalContextAgentInteraction::ID => Server::get(MultimodalContextAgentInteraction::class),
714715
AnalyzeImages::ID => Server::get(AnalyzeImages::class),
715716
ImageToTextOpticalCharacterRecognition::ID => Server::get(ImageToTextOpticalCharacterRecognition::class),
717+
ImageToImage::ID => Server::get(ImageToImage::class),
716718
];
717719

718720
foreach ($context->getTaskProcessingTaskTypes() as $providerServiceRegistration) {
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCP\TaskProcessing\TaskTypes;
11+
12+
use OCP\IL10N;
13+
use OCP\L10N\IFactory;
14+
use OCP\TaskProcessing\EShapeType;
15+
use OCP\TaskProcessing\ITaskType;
16+
use OCP\TaskProcessing\ShapeDescriptor;
17+
18+
/**
19+
* This is the task processing task type for editing images
20+
* @since 36.0.0
21+
*/
22+
class ImageToImage implements ITaskType {
23+
/**
24+
* @since 36.0.0
25+
*/
26+
public const ID = 'core:image2image';
27+
28+
private IL10N $l;
29+
30+
/**
31+
* @param IFactory $l10nFactory
32+
* @since 36.0.0
33+
*/
34+
public function __construct(
35+
IFactory $l10nFactory,
36+
) {
37+
$this->l = $l10nFactory->get('lib');
38+
}
39+
40+
/**
41+
* @inheritDoc
42+
* @since 36.0.0
43+
*/
44+
#[\Override]
45+
public function getName(): string {
46+
return $this->l->t('Edit image');
47+
}
48+
49+
/**
50+
* @inheritDoc
51+
* @since 36.0.0
52+
*/
53+
#[\Override]
54+
public function getDescription(): string {
55+
return $this->l->t('Edit an image based on a text description of the changes');
56+
}
57+
58+
/**
59+
* @return string
60+
* @since 36.0.0
61+
*/
62+
#[\Override]
63+
public function getId(): string {
64+
return self::ID;
65+
}
66+
67+
/**
68+
* @return ShapeDescriptor[]
69+
* @since 36.0.0
70+
*/
71+
#[\Override]
72+
public function getInputShape(): array {
73+
return [
74+
'input' => new ShapeDescriptor(
75+
$this->l->t('Input images'),
76+
$this->l->t('The images to edit'),
77+
EShapeType::ListOfImages
78+
),
79+
'prompt' => new ShapeDescriptor(
80+
$this->l->t('Prompt'),
81+
$this->l->t('Describe the changes you want to make to the image'),
82+
EShapeType::Text
83+
),
84+
];
85+
}
86+
87+
/**
88+
* @return ShapeDescriptor[]
89+
* @since 36.0.0
90+
*/
91+
#[\Override]
92+
public function getOutputShape(): array {
93+
return [
94+
'output' => new ShapeDescriptor(
95+
$this->l->t('Output image'),
96+
$this->l->t('The edited image'),
97+
EShapeType::Image
98+
),
99+
];
100+
}
101+
}

0 commit comments

Comments
 (0)