From 54cebc213695ca07e7fdd830d2ba99e8526991b3 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Wed, 23 Oct 2024 16:40:34 +0200 Subject: [PATCH] fix(textprocessing): also list types that are available in task processing Signed-off-by: Julien Veyssier --- lib/private/TextProcessing/Manager.php | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/private/TextProcessing/Manager.php b/lib/private/TextProcessing/Manager.php index 8d34b5fba0113..db759cf224c66 100644 --- a/lib/private/TextProcessing/Manager.php +++ b/lib/private/TextProcessing/Manager.php @@ -82,6 +82,20 @@ public function getProviders(): array { } public function hasProviders(): bool { + // check if task processing equivalent types are available + $taskTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes(); + $taskProcessingCompatibleTaskTypes = [ + FreePromptTaskType::class => TextToText::ID, + HeadlineTaskType::class => TextToTextHeadline::ID, + SummaryTaskType::class => TextToTextSummary::ID, + TopicsTaskType::class => TextToTextTopics::ID, + ]; + foreach ($taskProcessingCompatibleTaskTypes as $textTaskTypeClass => $taskTaskTypeId) { + if (isset($taskTaskTypes[$taskTaskTypeId])) { + return true; + } + } + $context = $this->coordinator->getRegistrationContext(); if ($context === null) { return false; @@ -97,6 +111,21 @@ public function getAvailableTaskTypes(): array { foreach ($this->getProviders() as $provider) { $tasks[$provider->getTaskType()] = true; } + + // check if task processing equivalent types are available + $taskTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes(); + $taskProcessingCompatibleTaskTypes = [ + FreePromptTaskType::class => TextToText::ID, + HeadlineTaskType::class => TextToTextHeadline::ID, + SummaryTaskType::class => TextToTextSummary::ID, + TopicsTaskType::class => TextToTextTopics::ID, + ]; + foreach ($taskProcessingCompatibleTaskTypes as $textTaskTypeClass => $taskTaskTypeId) { + if (isset($taskTaskTypes[$taskTaskTypeId])) { + $tasks[$textTaskTypeClass] = true; + } + } + return array_keys($tasks); }