mirror of
https://github.com/nextcloud/documentation.git
synced 2026-01-02 09:49:33 +07:00
@@ -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
|
||||
+ ``message`` - Only provided when not ``200 OK``, an error message in the user's language, ready to be displayed
|
||||
|
||||
@@ -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 <Task>(string $input, string $appId, ?string $userId)``. For example:
|
||||
All Task classes implement ``OCP\LanguageModel\ILanguageModelTask``. To create a task you can write ``new <Task>(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
|
||||
|
||||
Reference in New Issue
Block a user