Skip to content

Commit 8fc9a5d

Browse files
authored
Merge pull request #53763 from nextcloud/feat/task/analyze-image
feat(TaskProcessing): Add AnalyzeImage TaskType
2 parents b1e58ba + 4731ecf commit 8fc9a5d

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@
842842
'OCP\\TaskProcessing\\ShapeDescriptor' => $baseDir . '/lib/public/TaskProcessing/ShapeDescriptor.php',
843843
'OCP\\TaskProcessing\\ShapeEnumValue' => $baseDir . '/lib/public/TaskProcessing/ShapeEnumValue.php',
844844
'OCP\\TaskProcessing\\Task' => $baseDir . '/lib/public/TaskProcessing/Task.php',
845+
'OCP\\TaskProcessing\\TaskTypes\\AnalyzeImages' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/AnalyzeImages.php',
845846
'OCP\\TaskProcessing\\TaskTypes\\AudioToAudioChat' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/AudioToAudioChat.php',
846847
'OCP\\TaskProcessing\\TaskTypes\\AudioToText' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/AudioToText.php',
847848
'OCP\\TaskProcessing\\TaskTypes\\ContextAgentAudioInteraction' => $baseDir . '/lib/public/TaskProcessing/TaskTypes/ContextAgentAudioInteraction.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
883883
'OCP\\TaskProcessing\\ShapeDescriptor' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/ShapeDescriptor.php',
884884
'OCP\\TaskProcessing\\ShapeEnumValue' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/ShapeEnumValue.php',
885885
'OCP\\TaskProcessing\\Task' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/Task.php',
886+
'OCP\\TaskProcessing\\TaskTypes\\AnalyzeImages' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/AnalyzeImages.php',
886887
'OCP\\TaskProcessing\\TaskTypes\\AudioToAudioChat' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/AudioToAudioChat.php',
887888
'OCP\\TaskProcessing\\TaskTypes\\AudioToText' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/AudioToText.php',
888889
'OCP\\TaskProcessing\\TaskTypes\\ContextAgentAudioInteraction' => __DIR__ . '/../../..' . '/lib/public/TaskProcessing/TaskTypes/ContextAgentAudioInteraction.php',

lib/private/TaskProcessing/Manager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ private function _getTaskTypes(): array {
591591
\OCP\TaskProcessing\TaskTypes\TextToSpeech::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToSpeech::class),
592592
\OCP\TaskProcessing\TaskTypes\AudioToAudioChat::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\AudioToAudioChat::class),
593593
\OCP\TaskProcessing\TaskTypes\ContextAgentAudioInteraction::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\ContextAgentAudioInteraction::class),
594+
\OCP\TaskProcessing\TaskTypes\AnalyzeImages::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\AnalyzeImages::class),
594595
];
595596

596597
foreach ($context->getTaskProcessingTaskTypes() as $providerServiceRegistration) {
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 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 to ask a question about the images
20+
* @since 32.0.0
21+
*/
22+
class AnalyzeImages implements ITaskType {
23+
/**
24+
* @since 32.0.0
25+
*/
26+
public const ID = 'core:analyze-images';
27+
28+
private IL10N $l;
29+
30+
/**
31+
* @param IFactory $l10nFactory
32+
* @since 32.0.0
33+
*/
34+
public function __construct(
35+
IFactory $l10nFactory,
36+
) {
37+
$this->l = $l10nFactory->get('lib');
38+
}
39+
40+
/**
41+
* @inheritDoc
42+
* @since 32.0.0
43+
*/
44+
public function getName(): string {
45+
return $this->l->t('Analyze images');
46+
}
47+
48+
/**
49+
* @inheritDoc
50+
* @since 32.0.0
51+
*/
52+
public function getDescription(): string {
53+
return $this->l->t('Ask a question about the given images.');
54+
}
55+
56+
/**
57+
* @return string
58+
* @since 32.0.0
59+
*/
60+
public function getId(): string {
61+
return self::ID;
62+
}
63+
64+
/**
65+
* @return ShapeDescriptor[]
66+
* @since 32.0.0
67+
*/
68+
public function getInputShape(): array {
69+
return [
70+
'images' => new ShapeDescriptor(
71+
$this->l->t('Images'),
72+
$this->l->t('Images to ask a question about'),
73+
EShapeType::ListOfImages,
74+
),
75+
'input' => new ShapeDescriptor(
76+
$this->l->t('Question'),
77+
$this->l->t('What to ask about the images.'),
78+
EShapeType::Text,
79+
),
80+
];
81+
}
82+
83+
/**
84+
* @return ShapeDescriptor[]
85+
* @since 32.0.0
86+
*/
87+
public function getOutputShape(): array {
88+
return [
89+
'output' => new ShapeDescriptor(
90+
$this->l->t('Generated response'),
91+
$this->l->t('The answer to the question'),
92+
EShapeType::Text
93+
),
94+
];
95+
}
96+
}

0 commit comments

Comments
 (0)