Skip to content

Commit

Permalink
Merge pull request #10629 from nextcloud/fix/10616-adjust-taskprocess…
Browse files Browse the repository at this point in the history
…inglistener-v2

fix: Adjust TaskProcessingListener Again
  • Loading branch information
hamza221 authored Jan 30, 2025
2 parents d3d7af0 + f0758c8 commit 2a2f82e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/Listener/TaskProcessingListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\TaskProcessing\Events\TaskSuccessfulEvent;
use OCP\TaskProcessing\TaskTypes\TextToTextSummary;
use OCP\TaskProcessing\TaskTypes\TextToText;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -40,7 +40,7 @@ public function handle(Event $event): void {
return;
}

if ($task->getTaskTypeId() !== TextToTextSummary::ID) {
if ($task->getTaskTypeId() !== TextToText::ID) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Service/AiIntegrations/AiIntegrationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use OCP\IConfig;
use OCP\TaskProcessing\IManager as TaskProcessingManager;
use OCP\TaskProcessing\Task as TaskProcessingTask;
use OCP\TaskProcessing\TaskTypes\TextToTextSummary;
use OCP\TaskProcessing\TaskTypes\TextToText;
use OCP\TextProcessing\FreePromptTaskType;
use OCP\TextProcessing\IManager;
use OCP\TextProcessing\SummaryTaskType;
Expand Down Expand Up @@ -66,7 +66,7 @@ public function __construct(
*/
public function summarizeMessages(Account $account, array $messages): void {
$availableTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes();
if (!isset($availableTaskTypes[TextToTextSummary::ID])) {
if (!isset($availableTaskTypes[TextToText::ID])) {
$this->logger->info('No text summary provider available');
return;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ public function summarizeMessages(Account $account, array $messages): void {
"Here is the ***E-MAIL*** for which you must generate a helpful summary: \r\n" .
"***START_OF_E-MAIL***\r\n$messageBody\r\n***END_OF_E-MAIL***\r\n";
$task = new TaskProcessingTask(
TextToTextSummary::ID,
TextToText::ID,
[
'max_tokens' => 1024,
'input' => $prompt,
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Service/AiIntegrationsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function testSummarizeMessagesContainsSummary() {

$this->taskProcessingManager->expects(self::once())
->method('getAvailableTaskTypes')
->willReturn(['core:text2text:summary' => $this->taskProcessingProvider]);
->willReturn(['core:text2text' => $this->taskProcessingProvider]);
$this->clientFactory->expects(self::once())
->method('getClient');

Expand Down Expand Up @@ -440,7 +440,7 @@ public function testSummarizeMessagesIsEncrypted() {

$this->taskProcessingManager->expects(self::once())
->method('getAvailableTaskTypes')
->willReturn(['core:text2text:summary' => $this->taskProcessingProvider]);
->willReturn(['core:text2text' => $this->taskProcessingProvider]);
$this->taskProcessingManager->expects(self::never())
->method('scheduleTask');

Expand Down Expand Up @@ -499,7 +499,7 @@ public function testSummarizeMessages() {

$this->taskProcessingManager->expects(self::once())
->method('getAvailableTaskTypes')
->willReturn(['core:text2text:summary' => $this->taskProcessingProvider]);
->willReturn(['core:text2text' => $this->taskProcessingProvider]);
$this->taskProcessingManager->expects(self::once())
->method('scheduleTask');

Expand Down

0 comments on commit 2a2f82e

Please sign in to comment.