Skip to content

Commit

Permalink
fix(textprocessing): also list types that are available in task proce…
Browse files Browse the repository at this point in the history
…ssing

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
  • Loading branch information
julien-nc committed Oct 24, 2024
1 parent f1684ff commit 54cebc2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/private/TextProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit 54cebc2

Please sign in to comment.