From ab64828840d7443eb9f920ff3ca7851279b4b8b8 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Fri, 7 Jul 2023 11:34:22 +0200 Subject: [PATCH] Update LanguageModel APIs Signed-off-by: Marcel Klehr --- .../client_apis/OCS/ocs-languagemodel-api.rst | 12 ++++++++---- developer_manual/digging_deeper/language_model.rst | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/developer_manual/client_apis/OCS/ocs-languagemodel-api.rst b/developer_manual/client_apis/OCS/ocs-languagemodel-api.rst index 3b174ba43..ddcf581bb 100644 --- a/developer_manual/client_apis/OCS/ocs-languagemodel-api.rst +++ b/developer_manual/client_apis/OCS/ocs-languagemodel-api.rst @@ -19,7 +19,7 @@ Get available task types .. versionadded:: 28 * Method: ``GET`` -* Endpoint: ``/tasks`` +* Endpoint: ``/tasktypes`` * Response: - Status code: + ``200 OK`` @@ -28,7 +28,7 @@ Get available task types +----------------------+--------+---------------------------------------------------------------------------------------------------------------+ | field | type | Description | +----------------------+--------+---------------------------------------------------------------------------------------------------------------+ -|``tasks`` | array | The list of supported task types, all existing types are: ``"free_prompt", "headline", "topics", "summary"`` | +|``types`` | array | The list of supported task types, all existing types are: ``"free_prompt", "headline", "topics", "summary"`` | +----------------------+--------+---------------------------------------------------------------------------------------------------------------+ Schedule a task @@ -45,12 +45,14 @@ Schedule a task +-----------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | field | type | Description | +-----------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -|``text`` | string | The input text for the task | +|``input`` | string | The input text for the task | +-----------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ |``type`` | string | One of the available task types returned above. | +-----------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ |``appId`` | string | The id of the requesting app | +-----------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +|``identifier`` | string | An app-defined identifier for the task | ++-----------------+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ * Response: - Status code: @@ -66,6 +68,7 @@ Schedule a task + ``status`` - Only provided in case of ``200 OK``, the current task status, int, see backend API + ``userId`` - Only provided in case of ``200 OK``, the originating userId of the task, string + ``appId`` - Only provided in case of ``200 OK``, the originating appId of the task, string + + ``identifier`` - Only provided in case of ``200 OK``, the originating appId of the task, string + ``output`` - Only provided in case of ``200 OK``, the output from the model, string or null + ``message`` - Only provided when not ``200 OK``, an error message in the user's language, ready to be displayed @@ -91,5 +94,6 @@ Fetch a task by ID + ``status`` - Only provided in case of ``200 OK``, the current task status, int, see backend API + ``userId`` - Only provided in case of ``200 OK``, the originating userId of the task, string + ``appId`` - Only provided in case of ``200 OK``, the originating appId of the task, string + + ``identifier`` - Only provided in case of ``200 OK``, the originating appId of the task, string + ``output`` - Only provided in case of ``200 OK``, the output from the model, string or null - + ``message`` - Only provided when not ``200 OK``, an error message in the user's language, ready to be displayed \ No newline at end of file + + ``message`` - Only provided when not ``200 OK``, an error message in the user's language, ready to be displayed diff --git a/developer_manual/digging_deeper/language_model.rst b/developer_manual/digging_deeper/language_model.rst index 65b5f3073..259b0c092 100644 --- a/developer_manual/digging_deeper/language_model.rst +++ b/developer_manual/digging_deeper/language_model.rst @@ -32,14 +32,13 @@ The following task types are available: * class: ``\OCP\LanguageModel\TopicsTask``, type: ``"topics"``: This task will generate a comma-separated list of topics for the passed input text. * class: ``\OCP\LanguageModel\SummaryTask``, type: ``"summarize"``: This task will summarize the passed input text. -All Task classes implement ``OCP\LanguageModel\ILanguageModelTask``. To create a task you can write ``new (string $input, string $appId, ?string $userId)``. For example: +All Task classes implement ``OCP\LanguageModel\ILanguageModelTask``. To create a task you can write ``new (string $input, string $appId, ?string $userId, string $identifier = '')``. For example: .. code-block:: php if (in_array(SummaryTask::TYPE, $languageModelManager->getAvailableTaskTypes()) { - $summaryTask = new SummaryTask($emailText, "my_app", $userId); + $summaryTask = new SummaryTask($emailText, "my_app", $userId, (string) $emailId); $languageModelManager->scheduleTask($summaryTask); - // store $summaryTask->getId() somewhere } else { // cannot use summarization } @@ -52,6 +51,7 @@ All task objects have the following methods available: * ``getInput()`` This returns the input string. * ``getOutput()`` This method will return ``null`` unless the task is successful * ``getAppId()`` This returns the originating application ID of the task. + * ``getIdentifier()`` This returns the original scheduler-defined identifier for the task * ``getUserId()`` This returns the originating user ID of the task. Task statuses