]> source.dussan.org Git - nextcloud-server.git/commitdiff
ILanguageModelTask: Use php type checking along with psalm parameterized types
authorMarcel Klehr <mklehr@gmx.net>
Wed, 28 Jun 2023 13:19:57 +0000 (15:19 +0200)
committerMarcel Klehr <mklehr@gmx.net>
Wed, 9 Aug 2023 08:01:17 +0000 (10:01 +0200)
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
(cherry picked from commit 27e1c86652d73b27f48756b350bb4578cdeeee0b)

lib/public/LanguageModel/FreePromptTask.php
lib/public/LanguageModel/HeadlineTask.php
lib/public/LanguageModel/ILanguageModelTask.php
lib/public/LanguageModel/SummaryTask.php
lib/public/LanguageModel/TopicsTask.php

index ac8ba6638a193a7f68440ed913b5a362ef11ff43..3de215784ab70fb5a6d77187ca1a41041dac7187 100644 (file)
@@ -39,7 +39,7 @@ final class FreePromptTask extends AbstractLanguageModelTask {
         * @inheritDoc
         * @since 28.0.0
         */
-       public function visitProvider($provider): string {
+       public function visitProvider(ILanguageModelProvider $provider): string {
                return $provider->prompt($this->getInput());
        }
 
@@ -47,7 +47,7 @@ final class FreePromptTask extends AbstractLanguageModelTask {
         * @inheritDoc
         * @since 28.0.0
         */
-       public function canUseProvider($provider): bool {
+       public function canUseProvider(ILanguageModelProvider $provider): bool {
                return true;
        }
 
index 789ad22665635d791ef298fe3b82085933cf19b3..e66c8893d8301044194fc37944bb75d254f688ee 100644 (file)
@@ -41,7 +41,7 @@ final class HeadlineTask extends AbstractLanguageModelTask {
         * @inheritDoc
         * @since 28.0.0
         */
-       public function visitProvider($provider): string {
+       public function visitProvider(ILanguageModelProvider $provider): string {
                if (!$this->canUseProvider($provider)) {
                        throw new \RuntimeException('HeadlineTask#visitProvider expects IHeadlineProvider');
                }
@@ -52,7 +52,7 @@ final class HeadlineTask extends AbstractLanguageModelTask {
         * @inheritDoc
         * @since 28.0.0
         */
-       public function canUseProvider($provider): bool {
+       public function canUseProvider(ILanguageModelProvider $provider): bool {
                return $provider instanceof IHeadlineProvider;
        }
 
index f5793632f582c7abcb161933d7ac116f05caa00d..09d750766226153112715d4747f765e06ea37ce9 100644 (file)
@@ -62,18 +62,20 @@ interface ILanguageModelTask extends \JsonSerializable {
        ];
 
        /**
-        * @param T $provider
+        * @psalm-param T $provider
+        * @param ILanguageModelProvider $provider
         * @return string
         * @since 28.0.0
         */
-       public function visitProvider($provider): string;
+       public function visitProvider(ILanguageModelProvider $provider): string;
 
        /**
-        * @param T $provider
+        * @psalm-param T $provider
+        * @param ILanguageModelProvider $provider
         * @return bool
         * @since 28.0.0
         */
-       public function canUseProvider($provider): bool;
+       public function canUseProvider(ILanguageModelProvider $provider): bool;
 
 
        /**
index 4d7f9e0813f5745ef323790086bf760b4b87553c..4504cdff7503cfb58426b3ce44864f9c510a7589 100644 (file)
@@ -41,7 +41,7 @@ final class SummaryTask extends AbstractLanguageModelTask {
         * @inheritDoc
         * @since 28.0.0
         */
-       public function visitProvider($provider): string {
+       public function visitProvider(ILanguageModelProvider $provider): string {
                if (!$this->canUseProvider($provider)) {
                        throw new \RuntimeException('SummaryTask#visitProvider expects ISummaryProvider');
                }
@@ -52,7 +52,7 @@ final class SummaryTask extends AbstractLanguageModelTask {
         * @inheritDoc
         * @since 28.0.0
         */
-       public function canUseProvider($provider): bool {
+       public function canUseProvider(ILanguageModelProvider $provider): bool {
                return $provider instanceof ISummaryProvider;
        }
 
index 513241240a223281b5ffda1db89fdd5a16e6a2ba..ccf5d512a8a97e908ae909f68d334f159130a9dc 100644 (file)
@@ -41,7 +41,7 @@ final class TopicsTask extends AbstractLanguageModelTask {
         * @inheritDoc
         * @since 28.0.0
         */
-       public function visitProvider($provider): string {
+       public function visitProvider(ILanguageModelProvider $provider): string {
                if (!$this->canUseProvider($provider)) {
                        throw new \RuntimeException('TopicsTask#visitProvider expects ITopicsProvider');
                }
@@ -52,7 +52,7 @@ final class TopicsTask extends AbstractLanguageModelTask {
         * @inheritDoc
         * @since 28.0.0
         */
-       public function canUseProvider($provider): bool {
+       public function canUseProvider(ILanguageModelProvider $provider): bool {
                return $provider instanceof ITopicsProvider;
        }