Skip to content

Commit 6c5164c

Browse files
committed
fix(TextProcessing): Add task type template param to IManager and registerTextProcessingProvider
otherwise we cannot use them reasonably Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 0da05fc commit 6c5164c

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

lib/public/AppFramework/Bootstrap/IRegistrationContext.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use OCP\Files\Template\ICustomTemplateProvider;
3939
use OCP\IContainer;
4040
use OCP\TextProcessing\IProvider as ITextProcessingProvider;
41+
use OCP\TextProcessing\ITaskType;
4142
use OCP\TextToImage\IProvider as ITextToImageProvider;
4243
use OCP\Notification\INotifier;
4344
use OCP\Preview\IProviderV2;
@@ -226,7 +227,8 @@ public function registerSpeechToTextProvider(string $providerClass): void;
226227
* through the OCP\TextProcessing APIs
227228
*
228229
* @param string $providerClass
229-
* @psalm-param class-string<ITextProcessingProvider> $providerClass
230+
* @psalm-template T of ITaskType
231+
* @psalm-param class-string<ITextProcessingProvider<T>> $providerClass
230232
* @since 27.1.0
231233
*/
232234
public function registerTextProcessingProvider(string $providerClass): void;

lib/public/TextProcessing/IManager.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public function getProviders(): array;
5656
public function getAvailableTaskTypes(): array;
5757

5858
/**
59-
* @param Task $task The task to run
59+
* @psalm-template T of ITaskType
60+
* @param Task<T> $task The task to run
6061
* @throws PreConditionNotMetException If no or not the requested provider was registered but this method was still called
6162
* @throws TaskFailureException If running the task failed
6263
* @since 27.1.0
@@ -68,7 +69,8 @@ public function runTask(Task $task): string;
6869
* with the \OCP\LanguageModel\Events\TaskSuccessfulEvent
6970
* If inference fails a \OCP\LanguageModel\Events\TaskFailedEvent will be dispatched instead
7071
*
71-
* @param Task $task The task to schedule
72+
* @psalm-template T of ITaskType
73+
* @param Task<T> $task The task to schedule
7274
* @throws PreConditionNotMetException If no or not the requested provider was registered but this method was still called
7375
* @throws Exception storing the task in the database failed
7476
* @since 27.1.0
@@ -80,7 +82,8 @@ public function scheduleTask(Task $task) : void;
8082
* max execution time of this php process and run it synchronously if it does, if it doesn't fit (or the provider doesn't provide that information)
8183
* execution is deferred to a background job
8284
*
83-
* @param Task $task The task to schedule
85+
* @psalm-template T of ITaskType
86+
* @param Task<T> $task The task to schedule
8487
* @returns bool A boolean indicating whether the task was run synchronously (`true`) or offloaded to a background job (`false`)
8588
* @throws PreConditionNotMetException If no or not the requested provider was registered but this method was still called
8689
* @throws TaskFailureException If running the task failed
@@ -92,7 +95,8 @@ public function runOrScheduleTask(Task $task): bool;
9295
/**
9396
* Delete a task that has been scheduled before
9497
*
95-
* @param Task $task The task to delete
98+
* @psalm-template T of ITaskType
99+
* @param Task<T> $task The task to delete
96100
* @since 27.1.0
97101
*/
98102
public function deleteTask(Task $task): void;

0 commit comments

Comments
 (0)