Skip to content

Commit

Permalink
fix(ai_providers): use PublicFunctions to call to ExApp (#226)
Browse files Browse the repository at this point in the history
We broke all AI providers in `2.0.0` version, this is a fix for that.

---------

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
  • Loading branch information
andrey18106 committed Feb 8, 2024
1 parent 2caf2b1 commit 961458c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
]]></description>
<version>2.0.3</version>
<version>2.0.4</version>
<licence>agpl</licence>
<author mail="andrey18106x@gmail.com" homepage="https://github.com/andrey18106">Andrey Borysenko</author>
<author mail="bigcat88@icloud.com" homepage="https://github.com/bigcat88">Alexander Piskun</author>
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/ProvidersAI/SpeechToTextService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()]));
Expand All @@ -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: [
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/ProvidersAI/TextProcessingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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: [
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/ProvidersAI/TranslationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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: [
Expand Down

0 comments on commit 961458c

Please sign in to comment.