From 961458cd17e156f374cc552e2ea3a34e90196d1f Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Thu, 8 Feb 2024 16:07:45 +0200 Subject: [PATCH] fix(ai_providers): use PublicFunctions to call to ExApp (#226) We broke all AI providers in `2.0.0` version, this is a fix for that. --------- Signed-off-by: Andrey Borysenko --- CHANGELOG.md | 3 ++- appinfo/info.xml | 2 +- lib/Service/ProvidersAI/SpeechToTextService.php | 8 ++++---- lib/Service/ProvidersAI/TextProcessingService.php | 8 ++++---- lib/Service/ProvidersAI/TranslationService.php | 8 ++++---- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c84d57eb..4e163e72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -## [2.x.x - 2024-02-xx] +## [2.0.4 - 2024-02-08] ### Changed @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - OCS API `log` always fail during ExApp `init` state. #224 +- AI providers: undefined method call to ExApp. #226 ## [2.0.3 - 2024-02-01] diff --git a/appinfo/info.xml b/appinfo/info.xml index 23f29aec..65b81213 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -42,7 +42,7 @@ to join us in shaping a more versatile, stable, and secure app landscape. *Your insights, suggestions, and contributions are invaluable to us.* ]]> - 2.0.3 + 2.0.4 agpl Andrey Borysenko Alexander Piskun diff --git a/lib/Service/ProvidersAI/SpeechToTextService.php b/lib/Service/ProvidersAI/SpeechToTextService.php index 67417418..0949cf1f 100644 --- a/lib/Service/ProvidersAI/SpeechToTextService.php +++ b/lib/Service/ProvidersAI/SpeechToTextService.php @@ -9,7 +9,7 @@ use OCA\AppAPI\Db\SpeechToText\SpeechToTextProviderMapper; use OCA\AppAPI\Db\SpeechToText\SpeechToTextProviderQueue; use OCA\AppAPI\Db\SpeechToText\SpeechToTextProviderQueueMapper; -use OCA\AppAPI\Service\AppAPICommonService; +use OCA\AppAPI\PublicFunctions; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; @@ -169,8 +169,8 @@ public function getName(): string { } public function transcribeFile(File $file, float $maxExecutionTime = 0): string { - /** @var AppAPICommonService $service */ - $service = $this->serverContainer->get(AppAPICommonService::class); + /** @var PublicFunctions $service */ + $service = $this->serverContainer->get(PublicFunctions::class); $mapper = $this->serverContainer->get(SpeechToTextProviderQueueMapper::class); $route = $this->provider->getActionHandler(); $queueRecord = $mapper->insert(new SpeechToTextProviderQueue(['created_time' => time()])); @@ -181,7 +181,7 @@ public function transcribeFile(File $file, float $maxExecutionTime = 0): string } catch (Exception $e) { throw new \Exception(sprintf('Failed to open file: %s. Error: %s', $file->getName(), $e->getMessage())); } - $response = $service->requestToExAppById($this->provider->getAppid(), + $response = $service->exAppRequestWithUserInit($this->provider->getAppid(), $route, $this->userId, options: [ diff --git a/lib/Service/ProvidersAI/TextProcessingService.php b/lib/Service/ProvidersAI/TextProcessingService.php index 721537f7..f3b6ffaa 100644 --- a/lib/Service/ProvidersAI/TextProcessingService.php +++ b/lib/Service/ProvidersAI/TextProcessingService.php @@ -9,7 +9,7 @@ use OCA\AppAPI\Db\TextProcessing\TextProcessingProviderMapper; use OCA\AppAPI\Db\TextProcessing\TextProcessingProviderQueue; use OCA\AppAPI\Db\TextProcessing\TextProcessingProviderQueueMapper; -use OCA\AppAPI\Service\AppAPICommonService; +use OCA\AppAPI\PublicFunctions; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; @@ -182,14 +182,14 @@ public function getName(): string { } public function process(string $prompt, float $maxExecutionTime = 0): string { - /** @var AppAPICommonService $service */ - $service = $this->serverContainer->get(AppAPICommonService::class); + /** @var PublicFunctions $service */ + $service = $this->serverContainer->get(PublicFunctions::class); $mapper = $this->serverContainer->get(TextProcessingProviderQueueMapper::class); $route = $this->provider->getActionHandler(); $queueRecord = $mapper->insert(new TextProcessingProviderQueue(['created_time' => time()])); $taskId = $queueRecord->getId(); - $response = $service->requestToExAppById($this->provider->getAppid(), + $response = $service->exAppRequestWithUserInit($this->provider->getAppid(), $route, $this->userId, params: [ diff --git a/lib/Service/ProvidersAI/TranslationService.php b/lib/Service/ProvidersAI/TranslationService.php index cdac1871..f09b3d81 100644 --- a/lib/Service/ProvidersAI/TranslationService.php +++ b/lib/Service/ProvidersAI/TranslationService.php @@ -9,7 +9,7 @@ use OCA\AppAPI\Db\Translation\TranslationProviderMapper; use OCA\AppAPI\Db\Translation\TranslationQueue; use OCA\AppAPI\Db\Translation\TranslationQueueMapper; -use OCA\AppAPI\Service\AppAPICommonService; +use OCA\AppAPI\PublicFunctions; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; @@ -199,15 +199,15 @@ public function getAvailableLanguages(): array { } public function translate(?string $fromLanguage, string $toLanguage, string $text, float $maxExecutionTime = 0): string { - /** @var AppAPICommonService $service */ - $service = $this->serverContainer->get(AppAPICommonService::class); + /** @var PublicFunctions $service */ + $service = $this->serverContainer->get(PublicFunctions::class); /** @var TranslationQueueMapper $mapper */ $mapper = $this->serverContainer->get(TranslationQueueMapper::class); $route = $this->provider->getActionHandler(); $queueRecord = $mapper->insert(new TranslationQueue(['created_time' => time()])); $taskId = $queueRecord->getId(); - $response = $service->requestToExAppById($this->provider->getAppid(), + $response = $service->exAppRequestWithUserInit($this->provider->getAppid(), $route, $this->userId, params: [