]> source.dussan.org Git - nextcloud-server.git/commitdiff
LLM OCP API: Avoid using OC in OCP
authorMarcel Klehr <mklehr@gmx.net>
Fri, 7 Jul 2023 09:50:01 +0000 (11:50 +0200)
committerMarcel Klehr <mklehr@gmx.net>
Wed, 9 Aug 2023 08:02:14 +0000 (10:02 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
(cherry picked from commit 8f1a4f42557302c7d1c97be0439c47e59133955a)

lib/private/LanguageModel/Db/Task.php
lib/private/LanguageModel/LanguageModelManager.php
lib/public/LanguageModel/AbstractLanguageModelTask.php

index 8eb71b0ea5710b1d47f80de4f86ef2396377633d..4e46f19e8a91f8d25d9fe64fac653c626cbf856f 100644 (file)
@@ -26,6 +26,7 @@ declare(strict_types=1);
 namespace OC\LanguageModel\Db;
 
 use OCP\AppFramework\Db\Entity;
+use OCP\LanguageModel\AbstractLanguageModelTask;
 use OCP\LanguageModel\ILanguageModelTask;
 
 /**
@@ -101,4 +102,12 @@ class Task extends Entity {
                ]);
                return $task;
        }
+
+       public function toLanguageModelTask(): ILanguageModelTask {
+               $task = AbstractLanguageModelTask::factory($this->getType(), $this->getInput(), $this->getuserId(), $this->getAppId(), $this->getIdentifier());
+               $task->setId($this->getId());
+               $task->setStatus($this->getStatus());
+               $task->setOutput($this->getOutput());
+               return $task;
+       }
 }
index c195669acb433aaaa21065cca8bddd4dba19f469..c956dfc64abafd3cb49f3e06c62adb0bf0f7a9dd 100644 (file)
@@ -201,7 +201,7 @@ class LanguageModelManager implements ILanguageModelManager {
        public function getTask(int $id): ILanguageModelTask {
                try {
                        $taskEntity = $this->taskMapper->find($id);
-                       return AbstractLanguageModelTask::fromTaskEntity($taskEntity);
+                       return $taskEntity->toLanguageModelTask();
                } catch (DoesNotExistException $e) {
                        throw new NotFoundException('Could not find task with the provided id');
                } catch (MultipleObjectsReturnedException $e) {
index 884f26e14574a865334d1cd05601244e7a4861fb..2b92e6f115d1d97faaa492a533f9f1bc796f36ca 100644 (file)
@@ -25,8 +25,6 @@ declare(strict_types=1);
 
 namespace OCP\LanguageModel;
 
-use OC\LanguageModel\Db\Task;
-
 /**
  * This is an abstract LanguageModel task that implements basic
  * goodies for downstream tasks
@@ -161,20 +159,6 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
                ];
        }
 
-
-       /**
-        * @param Task $taskEntity
-        * @return ILanguageModelTask
-        * @since 28.0.0
-        */
-       final public static function fromTaskEntity(Task $taskEntity): ILanguageModelTask {
-               $task = self::factory($taskEntity->getType(), $taskEntity->getInput(), $taskEntity->getuserId(), $taskEntity->getAppId(), $taskEntity->getIdentifier());
-               $task->setId($taskEntity->getId());
-               $task->setStatus($taskEntity->getStatus());
-               $task->setOutput($taskEntity->getOutput());
-               return $task;
-       }
-
        /**
         * @param string $type
         * @param string $input