]> source.dussan.org Git - nextcloud-server.git/commitdiff
LLM OCP API: s/getAvailableTasks/getAvailableTaskClasses/
authorMarcel Klehr <mklehr@gmx.net>
Fri, 7 Jul 2023 09:40:19 +0000 (11:40 +0200)
committerMarcel Klehr <mklehr@gmx.net>
Wed, 9 Aug 2023 08:02:00 +0000 (10:02 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
(cherry picked from commit d56286b8acb319e05eaa8b8a920c76e76da336cf)

lib/private/LanguageModel/LanguageModelManager.php
lib/public/LanguageModel/ILanguageModelManager.php
tests/lib/LanguageModel/LanguageModelManagerTest.php

index 3b27fbae5ac37ab1f7d178dccb08f6950db85c78..11154849c42aa1ac53c5b29826b147ca350b611b 100644 (file)
@@ -102,7 +102,7 @@ class LanguageModelManager implements ILanguageModelManager {
        /**
         * @inheritDoc
         */
-       public function getAvailableTasks(): array {
+       public function getAvailableTaskClasses(): array {
                $tasks = [];
                foreach ($this->getProviders() as $provider) {
                        $tasks[FreePromptTask::class] = true;
@@ -123,11 +123,11 @@ class LanguageModelManager implements ILanguageModelManager {
         * @inheritDoc
         */
        public function getAvailableTaskTypes(): array {
-               return array_map(fn ($taskClass) => $taskClass::TYPE, $this->getAvailableTasks());
+               return array_map(fn ($taskClass) => $taskClass::TYPE, $this->getAvailableTaskClasses());
        }
 
        public function canHandleTask(ILanguageModelTask $task): bool {
-               return count(array_filter($this->getAvailableTasks(), fn ($class) => $task instanceof $class)) > 0;
+               return count(array_filter($this->getAvailableTaskClasses(), fn ($class) => $task instanceof $class)) > 0;
        }
 
        /**
index 055fb69820f0d1528f532c54e56476b2bc35fc48..438ed1ceb00ed910a0704602fe062bcf5f275612 100644 (file)
@@ -45,7 +45,7 @@ interface ILanguageModelManager {
         * @return string[]
         * @since 28.0.0
         */
-       public function getAvailableTasks(): array;
+       public function getAvailableTaskClasses(): array;
 
        /**
         * @return string[]
index 423eb525ba270caed28d1bdb2124eb711ed7a872..1eea6bf2074de94d62c52f1998f0ba7bd1f6c0ec 100644 (file)
@@ -163,7 +163,7 @@ class LanguageModelManagerTest extends \Test\TestCase {
 
        public function testShouldNotHaveAnyProviders() {
                $this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([]);
-               $this->assertCount(0, $this->languageModelManager->getAvailableTasks());
+               $this->assertCount(0, $this->languageModelManager->getAvailableTaskClasses());
                $this->assertCount(0, $this->languageModelManager->getAvailableTaskTypes());
                $this->assertFalse($this->languageModelManager->hasProviders());
                $this->expectException(PreConditionNotMetException::class);
@@ -174,7 +174,7 @@ class LanguageModelManagerTest extends \Test\TestCase {
                $this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([
                        new ServiceRegistration('test', TestVanillaLanguageModelProvider::class)
                ]);
-               $this->assertCount(1, $this->languageModelManager->getAvailableTasks());
+               $this->assertCount(1, $this->languageModelManager->getAvailableTaskClasses());
                $this->assertCount(1, $this->languageModelManager->getAvailableTaskTypes());
                $this->assertTrue($this->languageModelManager->hasProviders());
                $this->assertEquals('Hello Free Prompt', $this->languageModelManager->runTask(new FreePromptTask('Hello', 'test', null)));
@@ -189,7 +189,7 @@ class LanguageModelManagerTest extends \Test\TestCase {
                $this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([
                        new ServiceRegistration('test', TestVanillaLanguageModelProvider::class)
                ]);
-               $this->assertCount(1, $this->languageModelManager->getAvailableTasks());
+               $this->assertCount(1, $this->languageModelManager->getAvailableTaskClasses());
                $this->assertCount(1, $this->languageModelManager->getAvailableTaskTypes());
                $this->assertTrue($this->languageModelManager->hasProviders());
 
@@ -259,7 +259,7 @@ class LanguageModelManagerTest extends \Test\TestCase {
                        new ServiceRegistration('test', TestVanillaLanguageModelProvider::class),
                        new ServiceRegistration('test', TestFullLanguageModelProvider::class),
                ]);
-               $this->assertCount(3, $this->languageModelManager->getAvailableTasks());
+               $this->assertCount(3, $this->languageModelManager->getAvailableTaskClasses());
                $this->assertCount(3, $this->languageModelManager->getAvailableTaskTypes());
                $this->assertTrue($this->languageModelManager->hasProviders());
 
@@ -287,7 +287,7 @@ class LanguageModelManagerTest extends \Test\TestCase {
                $this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([
                        new ServiceRegistration('test', TestFailingLanguageModelProvider::class),
                ]);
-               $this->assertCount(1, $this->languageModelManager->getAvailableTasks());
+               $this->assertCount(1, $this->languageModelManager->getAvailableTaskClasses());
                $this->assertCount(1, $this->languageModelManager->getAvailableTaskTypes());
                $this->assertTrue($this->languageModelManager->hasProviders());
 
@@ -354,7 +354,7 @@ class LanguageModelManagerTest extends \Test\TestCase {
                $this->registrationContext->expects($this->any())->method('getLanguageModelProviders')->willReturn([
                        new ServiceRegistration('test', TestVanillaLanguageModelProvider::class)
                ]);
-               $this->assertCount(1, $this->languageModelManager->getAvailableTasks());
+               $this->assertCount(1, $this->languageModelManager->getAvailableTaskClasses());
                $this->assertCount(1, $this->languageModelManager->getAvailableTaskTypes());
                $this->assertTrue($this->languageModelManager->hasProviders());
                $task = new FreePromptTask('Hello', 'test', null);