11<?php
22
33/**
4- * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
4+ * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
55 * SPDX-License-Identifier: AGPL-3.0-or-later
66 */
77
@@ -233,6 +233,44 @@ public function isAudioChatAvailable(): bool {
233233 && array_key_exists (TextToTextChat::ID , $ availableTaskTypes );
234234 }
235235
236+ /**
237+ * Get category information for a task type
238+ *
239+ * @param string $typeId The task type ID
240+ * @return array{id: string, name: string}
241+ */
242+ private function getCategory (string $ typeId ): array {
243+ $ categoryId = 'other ' ;
244+ $ categoryName = $ this ->l10n ->t ('Other ' );
245+ if (str_starts_with ($ typeId , 'chatty ' )) {
246+ $ categoryId = 'chat ' ;
247+ $ categoryName = $ this ->l10n ->t ('Chat with AI ' );
248+ } elseif (str_starts_with ($ typeId , 'context_chat ' )) {
249+ $ categoryId = 'context ' ;
250+ $ categoryName = $ this ->l10n ->t ('Context Chat ' );
251+ } elseif (str_contains ($ typeId , 'translate ' )) {
252+ $ categoryId = 'translate ' ;
253+ $ categoryName = $ this ->l10n ->t ('Translate ' );
254+ } elseif (str_starts_with ($ typeId , 'richdocuments ' )) {
255+ $ categoryId = 'generate ' ;
256+ $ categoryName = $ this ->l10n ->t ('Generate file ' );
257+ } elseif (str_contains ($ typeId , 'image ' ) || str_contains ($ typeId , 'sticker ' )) {
258+ $ categoryId = 'image ' ;
259+ $ categoryName = $ this ->l10n ->t ('Work with images ' );
260+ } elseif (str_contains ($ typeId , 'audio ' ) || str_contains ($ typeId , 'speech ' )) {
261+ $ categoryId = 'audio ' ;
262+ $ categoryName = $ this ->l10n ->t ('Work with audio ' );
263+ } elseif (str_contains ($ typeId , 'text ' )) {
264+ $ categoryId = 'text ' ;
265+ $ categoryName = $ this ->l10n ->t ('Work with text ' );
266+ }
267+
268+ return [
269+ 'id ' => $ categoryId ,
270+ 'name ' => $ categoryName ,
271+ ];
272+ }
273+
236274 /**
237275 * @return array<AssistantTaskProcessingTaskType>
238276 */
@@ -246,6 +284,7 @@ public function getAvailableTaskTypes(): array {
246284 'description ' => 'plop ' ,
247285 'id ' => 'core:inputList ' ,
248286 'priority ' => 0 ,
287+ 'category ' => $ this ->getCategory ('core:inputList ' ),
249288 'inputShape ' => [
250289 'textList ' => new ShapeDescriptor (
251290 'Input text list ' ,
@@ -334,6 +373,7 @@ public function getAvailableTaskTypes(): array {
334373 'id ' => 'chatty-llm ' ,
335374 'name ' => $ this ->l10n ->t ('Chat with AI ' ),
336375 'description ' => $ this ->l10n ->t ('Chat with an AI model. ' ),
376+ 'category ' => $ this ->getCategory ('chatty-llm ' ),
337377 'inputShape ' => [],
338378 'inputShapeEnumValues ' => [],
339379 'inputShapeDefaults ' => [],
@@ -351,6 +391,7 @@ public function getAvailableTaskTypes(): array {
351391 }
352392 $ taskTypeArray ['id ' ] = $ typeId ;
353393 $ taskTypeArray ['priority ' ] = self ::TASK_TYPE_PRIORITIES [$ typeId ] ?? 1000 ;
394+ $ taskTypeArray ['category ' ] = $ this ->getCategory ($ typeId );
354395
355396 if ($ typeId === TextToText::ID ) {
356397 $ taskTypeArray ['name ' ] = $ this ->l10n ->t ('Generate text ' );
0 commit comments