From dd7eafaa48842857b95edfb24f27f077bf58f200 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Tue, 20 Jun 2023 18:26:29 +0200 Subject: LLM OCP API: Fix coding style and psalm Signed-off-by: Marcel Klehr (cherry picked from commit 72ea76178a694b302ece8a0752bbf5a22afc637a) --- lib/public/LanguageModel/Events/TaskFailedEvent.php | 5 +++++ lib/public/LanguageModel/Events/TaskSuccessfulEvent.php | 4 ++++ lib/public/LanguageModel/FreePromptTask.php | 3 +++ lib/public/LanguageModel/HeadlineTask.php | 15 ++++++++++----- lib/public/LanguageModel/ILanguageModelManager.php | 3 +++ lib/public/LanguageModel/SummaryTask.php | 3 +++ lib/public/LanguageModel/TopicsTask.php | 3 +++ 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/public/LanguageModel/Events/TaskFailedEvent.php b/lib/public/LanguageModel/Events/TaskFailedEvent.php index 5425368d57d..efc7d9043c8 100644 --- a/lib/public/LanguageModel/Events/TaskFailedEvent.php +++ b/lib/public/LanguageModel/Events/TaskFailedEvent.php @@ -8,6 +8,11 @@ use OCP\LanguageModel\ILanguageModelTask; * @since 28.0.0 */ class TaskFailedEvent extends AbstractLanguageModelEvent { + /** + * @param ILanguageModelTask $task + * @param string $errorMessage + * @since 28.0.0 + */ public function __construct(ILanguageModelTask $task, private string $errorMessage) { parent::__construct($task); diff --git a/lib/public/LanguageModel/Events/TaskSuccessfulEvent.php b/lib/public/LanguageModel/Events/TaskSuccessfulEvent.php index 35b5a043215..ec8a8586a3e 100644 --- a/lib/public/LanguageModel/Events/TaskSuccessfulEvent.php +++ b/lib/public/LanguageModel/Events/TaskSuccessfulEvent.php @@ -8,6 +8,10 @@ use OCP\LanguageModel\ILanguageModelTask; * @since 28.0.0 */ class TaskSuccessfulEvent extends AbstractLanguageModelEvent { + /** + * @param ILanguageModelTask $task + * @since 28.0.0 + */ public function __construct(ILanguageModelTask $task) { parent::__construct($task); } diff --git a/lib/public/LanguageModel/FreePromptTask.php b/lib/public/LanguageModel/FreePromptTask.php index 180d778b34c..02eb6803276 100644 --- a/lib/public/LanguageModel/FreePromptTask.php +++ b/lib/public/LanguageModel/FreePromptTask.php @@ -13,6 +13,7 @@ final class FreePromptTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function visitProvider(ILanguageModelProvider $provider): string { return $provider->prompt($this->getInput()); @@ -20,6 +21,7 @@ final class FreePromptTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function canUseProvider(ILanguageModelProvider $provider): bool { return true; @@ -27,6 +29,7 @@ final class FreePromptTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function getType(): string { return self::TYPE; diff --git a/lib/public/LanguageModel/HeadlineTask.php b/lib/public/LanguageModel/HeadlineTask.php index 283af6657e8..fadaea0b92d 100644 --- a/lib/public/LanguageModel/HeadlineTask.php +++ b/lib/public/LanguageModel/HeadlineTask.php @@ -2,8 +2,6 @@ namespace OCP\LanguageModel; -use RuntimeException; - /** * @since 28.0.0 */ @@ -14,9 +12,8 @@ final class HeadlineTask extends AbstractLanguageModelTask { public const TYPE = 'headline'; /** - * @param ILanguageModelProvider $provider - * @throws RuntimeException - * @return string + * @inheritDoc + * @since 28.0.0 */ public function visitProvider(ILanguageModelProvider $provider): string { if (!$provider instanceof IHeadlineProvider) { @@ -25,10 +22,18 @@ final class HeadlineTask extends AbstractLanguageModelTask { return $provider->findHeadline($this->getInput()); } + /** + * @inheritDoc + * @since 28.0.0 + */ public function canUseProvider(ILanguageModelProvider $provider): bool { return $provider instanceof IHeadlineProvider; } + /** + * @inheritDoc + * @since 28.0.0 + */ public function getType(): string { return self::TYPE; } diff --git a/lib/public/LanguageModel/ILanguageModelManager.php b/lib/public/LanguageModel/ILanguageModelManager.php index 5e3f350df66..80546149a62 100644 --- a/lib/public/LanguageModel/ILanguageModelManager.php +++ b/lib/public/LanguageModel/ILanguageModelManager.php @@ -29,6 +29,9 @@ namespace OCP\LanguageModel; use OCP\PreConditionNotMetException; use RuntimeException; +/** + * @since 28.0.0 + */ interface ILanguageModelManager { /** * @since 28.0.0 diff --git a/lib/public/LanguageModel/SummaryTask.php b/lib/public/LanguageModel/SummaryTask.php index e454404be92..b5a3bd25c4f 100644 --- a/lib/public/LanguageModel/SummaryTask.php +++ b/lib/public/LanguageModel/SummaryTask.php @@ -13,6 +13,7 @@ final class SummaryTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function visitProvider(ILanguageModelProvider $provider): string { if (!$provider instanceof ISummaryProvider) { @@ -23,6 +24,7 @@ final class SummaryTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function canUseProvider(ILanguageModelProvider $provider): bool { return $provider instanceof ISummaryProvider; @@ -30,6 +32,7 @@ final class SummaryTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function getType(): string { return self::TYPE; diff --git a/lib/public/LanguageModel/TopicsTask.php b/lib/public/LanguageModel/TopicsTask.php index 114c3c0ab06..a7a29603362 100644 --- a/lib/public/LanguageModel/TopicsTask.php +++ b/lib/public/LanguageModel/TopicsTask.php @@ -13,6 +13,7 @@ final class TopicsTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function visitProvider(ILanguageModelProvider $provider): string { if (!$provider instanceof ITopicsProvider) { @@ -23,6 +24,7 @@ final class TopicsTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function canUseProvider(ILanguageModelProvider $provider): bool { return $provider instanceof ITopicsProvider; @@ -30,6 +32,7 @@ final class TopicsTask extends AbstractLanguageModelTask { /** * @inheritDoc + * @since 28.0.0 */ public function getType(): string { return self::TYPE; -- cgit v1.2.3