2727namespace OC \Core \Controller ;
2828
2929use InvalidArgumentException ;
30+ use OCA \Core \ResponseDefinitions ;
3031use OCP \AppFramework \Http ;
3132use OCP \AppFramework \Http \DataResponse ;
3233use OCP \Common \Exception \NotFoundException ;
4142use Psr \Container \NotFoundExceptionInterface ;
4243use Psr \Log \LoggerInterface ;
4344
45+ /**
46+ * @psalm-import-type CoreTextProcessingTask from ResponseDefinitions
47+ */
4448class TextProcessingApiController extends \OCP \AppFramework \OCSController {
4549 public function __construct (
4650 string $ appName ,
@@ -58,10 +62,13 @@ public function __construct(
5862 * This endpoint returns all available LanguageModel task types
5963 *
6064 * @PublicPage
65+ *
66+ * @return DataResponse<Http::STATUS_OK, array{types: array{id: string, name: string, description: string}[]}, array{}>
6167 */
6268 public function taskTypes (): DataResponse {
6369 $ typeClasses = $ this ->languageModelManager ->getAvailableTaskTypes ();
6470 $ types = [];
71+ /** @var string $typeClass */
6572 foreach ($ typeClasses as $ typeClass ) {
6673 try {
6774 /** @var ITaskType $object */
@@ -88,6 +95,17 @@ public function taskTypes(): DataResponse {
8895 * @PublicPage
8996 * @UserRateThrottle(limit=20, period=120)
9097 * @AnonRateThrottle(limit=5, period=120)
98+ *
99+ * @param string $input Input text
100+ * @param string $type Type of the task
101+ * @param string $appId ID of the app that will execute the task
102+ * @param string $identifier An arbitrary identifier for the task
103+ *
104+ * @return DataResponse<Http::STATUS_OK, array{task: CoreTextProcessingTask}, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_PRECONDITION_FAILED, array{message: string}, array{}>
105+ *
106+ * 200: Task scheduled successfully
107+ * 400: Scheduling task is not possible
108+ * 412: Scheduling task is not possible
91109 */
92110 public function schedule (string $ input , string $ type , string $ appId , string $ identifier = '' ): DataResponse {
93111 try {
@@ -114,6 +132,11 @@ public function schedule(string $input, string $type, string $appId, string $ide
114132 *
115133 * @PublicPage
116134 * @param int $id The id of the task
135+ *
136+ * @return DataResponse<Http::STATUS_OK, array{task: CoreTextProcessingTask}, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
137+ *
138+ * 200: Task returned
139+ * 404: Task not found
117140 */
118141 public function getTask (int $ id ): DataResponse {
119142 try {
0 commit comments