]> source.dussan.org Git - nextcloud-server.git/commitdiff
LLM OCP API: Fix psam errors
authorMarcel Klehr <mklehr@gmx.net>
Thu, 6 Jul 2023 10:48:40 +0000 (12:48 +0200)
committerMarcel Klehr <mklehr@gmx.net>
Wed, 9 Aug 2023 08:01:40 +0000 (10:01 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
(cherry picked from commit d6d4e0ffe367a89dda1105fed3df15bc66bff11a)

core/Controller/LanguageModelApiController.php
lib/public/LanguageModel/AbstractLanguageModelTask.php

index 21954e7f1c753cdaf996e81df616bf45726ebcfd..9763e5878a8208f85e1d925cd8825057782fde56 100644 (file)
@@ -61,9 +61,9 @@ class LanguageModelApiController extends \OCP\AppFramework\OCSController {
         * @UserRateThrottle(limit=20, period=120)
         * @AnonRateThrottle(limit=5, period=120)
         */
-       public function schedule(string $text, string $type, ?string $appId): DataResponse {
+       public function schedule(string $text, string $type, ?string $appId, string $identifier = ''): DataResponse {
                try {
-                       $task = AbstractLanguageModelTask::factory($type, $text, $this->userId, $appId);
+                       $task = AbstractLanguageModelTask::factory($type, $text, $this->userId, $appId, $identifier);
                } catch (InvalidArgumentException $e) {
                        return new DataResponse(['message' => $this->l->t('Requested task type does not exist')], Http::STATUS_BAD_REQUEST);
                }
index 90e9c42de0957e07975579de77d3f8e0889e4e85..884f26e14574a865334d1cd05601244e7a4861fb 100644 (file)
@@ -37,6 +37,10 @@ use OC\LanguageModel\Db\Task;
 abstract class AbstractLanguageModelTask implements ILanguageModelTask {
        protected ?int $id = null;
        protected ?string $output = null;
+
+       /**
+        * @psalm-var ILanguageModelTask::STATUS_*
+        */
        protected int $status = ILanguageModelTask::STATUS_UNKNOWN;
 
        /**
@@ -77,7 +81,7 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
        }
 
        /**
-        * @return ILanguageModelTask::STATUS_*
+        * @psalm-return ILanguageModelTask::STATUS_*
         * @since 28.0.0
         */
        final public function getStatus(): int {
@@ -181,7 +185,7 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
         * @throws \InvalidArgumentException
         * @since 28.0.0
         */
-       final public static function factory(string $type, string $input, ?string $userId, string $appId, string $identifier): ILanguageModelTask {
+       final public static function factory(string $type, string $input, ?string $userId, string $appId, string $identifier = ''): ILanguageModelTask {
                if (!in_array($type, array_keys(self::TYPES))) {
                        throw new \InvalidArgumentException('Unknown task type');
                }