summaryrefslogtreecommitdiffstats
path: root/lib/public/LanguageModel/TopicsTask.php
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-06-27 16:43:54 +0200
committerMarcel Klehr <mklehr@gmx.net>2023-08-09 10:00:56 +0200
commitc8bbe8fc75f24262573f9cafee533701680fb1e1 (patch)
treec5851c2b284be2e7b957086e6b2bc8733c067170 /lib/public/LanguageModel/TopicsTask.php
parent44050274715bc389ed5cde3d8ac58dd241da7865 (diff)
downloadnextcloud-server-c8bbe8fc75f24262573f9cafee533701680fb1e1.tar.gz
nextcloud-server-c8bbe8fc75f24262573f9cafee533701680fb1e1.zip
LLM OCP API: Type shenanigans for Visitor pattern
Signed-off-by: Marcel Klehr <mklehr@gmx.net> (cherry picked from commit 906e9b7014203ac4e7608155287efe793a83aa8e)
Diffstat (limited to 'lib/public/LanguageModel/TopicsTask.php')
-rw-r--r--lib/public/LanguageModel/TopicsTask.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/public/LanguageModel/TopicsTask.php b/lib/public/LanguageModel/TopicsTask.php
index a628695a59a..41571fb7e21 100644
--- a/lib/public/LanguageModel/TopicsTask.php
+++ b/lib/public/LanguageModel/TopicsTask.php
@@ -6,6 +6,7 @@ namespace OCP\LanguageModel;
* This LanguageModel Task represents topics synthesis
* which outputs comma-separated topics for the passed text
* @since 28.0.0
+ * @template-extends AbstractLanguageModelTask<ITopicsProvider>
*/
final class TopicsTask extends AbstractLanguageModelTask {
/**
@@ -17,9 +18,9 @@ final class TopicsTask extends AbstractLanguageModelTask {
* @inheritDoc
* @since 28.0.0
*/
- public function visitProvider(ILanguageModelProvider $provider): string {
- if (!$provider instanceof ITopicsProvider) {
- throw new \RuntimeException('SummaryTask#visitProvider expects IHeadlineProvider');
+ public function visitProvider($provider): string {
+ if (!$this->canUseProvider($provider)) {
+ throw new \RuntimeException('TopicsTask#visitProvider expects ITopicsProvider');
}
return $provider->findTopics($this->getInput());
}
@@ -28,7 +29,7 @@ final class TopicsTask extends AbstractLanguageModelTask {
* @inheritDoc
* @since 28.0.0
*/
- public function canUseProvider(ILanguageModelProvider $provider): bool {
+ public function canUseProvider($provider): bool {
return $provider instanceof ITopicsProvider;
}