You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: admin_manual/ai/app_assistant.rst
+14
Original file line number
Diff line number
Diff line change
@@ -160,3 +160,17 @@ This field is appended to the block of chat messages, i.e. attached after the me
160
160
161
161
The number of latest messages to consider for generating the next message. This does not include the user instructions, which is always considered in addition to this. This value should be adjusted in case you are hitting the token limit in your conversations too often.
162
162
The AI text generation provider should ideally handle the max token limit case.
163
+
164
+
Improve AI processing throughput
165
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166
+
167
+
Most AI tasks will be run as part of the background job system in Nextcloud which only runs jobs every 5 minutes by default.
168
+
To pick up scheduled jobs faster you can set up background job workers that process AI tasks as soon as they are scheduled:
169
+
170
+
run the following occ commands a daemon (you can also spawn multiple, for parallel processing):
Copy file name to clipboardExpand all lines: admin_manual/ai/app_context_chat.rst
+5-3
Original file line number
Diff line number
Diff line change
@@ -57,18 +57,20 @@ Installation
57
57
Initial loading of data
58
58
-----------------------
59
59
60
-
Context chat will automatically load user data into the Vector DB using background jobs. To speed this up, you can set up multiple background job worker machines and run the following occ commands in parallel on each:
60
+
Context chat will automatically load user data into the Vector DB using background jobs. To speed this up, you can set up multiple background job workers (possibly on dedicated machines) and run the following occ commands as daemons in parallel on each:
This will ensure that the necessary background jobs are run as often as possible: ``StorageCrawlJob`` will crawl Nextcloud storages and put files that it finds into a queue and ``IndexerJob`` will iterate over the queue and load the file content into the Vector DB.
71
71
72
+
Make sure to restart these daemons regularly. For example once a day.
If you want Imaginary to also create preview images from PDF Documents, you have to add
1954
-
- ``OC\Preview\ImaginaryPDF``
1955
-
provider as well.
1949
+
Also requires the ``OC\Preview\Imaginary``
1950
+
provider to be enabled in the 'enabledPreviewProviders' array to create previews for these mimetypes: bmp, x-bitmap, png, jpeg, gif, heic, heif, svg+xml, tiff, webp and illustrator.
1951
+
1952
+
If you want Imaginary to also create preview images from PDF Documents, you have to add ``OC\Preview\ImaginaryPDF`` provider as well.
1956
1953
1957
1954
See https://github.com/h2non/imaginary
1958
1955
@@ -2317,16 +2314,16 @@ memcached_options
2317
2314
\Memcached::OPT_SEND_TIMEOUT => 50,
2318
2315
\Memcached::OPT_RECV_TIMEOUT => 50,
2319
2316
\Memcached::OPT_POLL_TIMEOUT => 50,
2320
-
2317
+
2321
2318
// Enable compression
2322
2319
\Memcached::OPT_COMPRESSION => true,
2323
-
2320
+
2324
2321
// Turn on consistent hashing
2325
2322
\Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
2326
-
2323
+
2327
2324
// Enable Binary Protocol
2328
2325
\Memcached::OPT_BINARY_PROTOCOL => true,
2329
-
2326
+
2330
2327
// Binary serializer vill be enabled if the igbinary PECL module is available
Copy file name to clipboardExpand all lines: developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_30.rst
+8
Original file line number
Diff line number
Diff line change
@@ -126,6 +126,10 @@ Added APIs
126
126
- ``OCP\App\IAppManager::BACKEND_CALDAV`` was added to represent the caldav backend dependency for ``isBackendRequired()``.
127
127
- ``OCP\App\IAppManager::isBackendRequired()`` was added to check if at least one app requires a specific backend (currently only ``caldav``).
128
128
- ``OCP\Accounts\IAccountManager::PROPERTY_BIRTHDATE`` was added to allow users to configure their date of birth in their profiles.
129
+
- ``OCP\TaskProcessing``` was added to unify task processing of AI tasks and other types of tasks. See :ref:`Task Processing<task_processing>`
130
+
- ``OCP\AppFramework\Bootstrap\IRegistrationContext::registerTaskProcessingProvider()`` was added to allow registering task processing providers
131
+
- ``OCP\AppFramework\Bootstrap\IRegistrationContext::registerTaskProcessingTaskType()`` was added to allow registering task processing task types
132
+
- ``OCP\Files\IRootFolder::getAppDataDirectoryName()`` was added to allow getting the name of the app data directory
129
133
130
134
Changed APIs
131
135
^^^^^^^^^^^^
@@ -175,6 +179,10 @@ Deprecated APIs
175
179
- Calling ``OCP\DB\QueryBuilder\IQueryBuilder::update()`` with ``$alias`` is deprecated and will throw an exception in a future version as the underlying library is removing the functionality.
176
180
- Calling ``OCP\IDBConnection::getDatabasePlatform()`` is deprecated and will throw an exception in a future version as the underlying library is renaming and removing platforms which breaks the backwards-compatibility. Use ``getDatabaseProvider()`` instead.
177
181
- Calling ``OCP\Files\Lock\ILockManager::registerLockProvider()`` is deprecated and will be removed in the future. Use ``registerLazyLockProvider()`` instead.
182
+
- Using ``OCP\Translation`` is deprecated and will be removed in the future. Use ``OCP\TaskProcessing`` instead.
183
+
- Using ``OCP\SpeechToText`` is deprecated and will be removed in the future. Use ``OCP\TaskProcessing`` instead. Existing ``SpeechToText`` providers will continue to work with the TaskProcessing API until then.
184
+
- Using ``OCP\TextToImage`` is deprecated and will be removed in the future. Use ``OCP\TaskProcessing`` instead. Existing ``TextToImage`` providers will continue to work with the TaskProcessing API until then.
185
+
- Using ``OCP\TextProcessing`` is deprecated and will be removed in the future. Use ``OCP\TaskProcessing`` instead. Existing ``TextProcessing`` providers will continue to work with the TaskProcessing API until then.
Copy file name to clipboardExpand all lines: developer_manual/digging_deeper/speech-to-text.rst
+4-1
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@ Speech-To-Text
6
6
7
7
.. versionadded:: 27
8
8
9
+
.. deprecated:: 30
10
+
Use the TaskProcessing API instead
11
+
9
12
Nextcloud offers a **Speech-To-Text** API. The overall idea is that there is a central OCP API that apps can use to request transcriptions of audio or video files. To be technology agnostic any app can provide this Speech-To-Text functionality by registering a Speech-To-Text provider.
10
13
11
14
Consuming the Speech-To-Text API
@@ -182,4 +185,4 @@ The provider class is registered via the :ref:`bootstrap mechanism<Bootstrapping
182
185
183
186
public function boot(IBootContext $context): void {}
Copy file name to clipboardExpand all lines: developer_manual/digging_deeper/task_processing.rst
+134-3
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,13 @@ The following built-in task types are available:
68
68
* ``input``: ``Text``
69
69
* Output shape:
70
70
* ``output``: ``Text``
71
+
* ``'core:text2text:translate'``: This task will translate text from one language to another. It is implemented by ``\OCP\TaskProcessing\TaskTypes\TextToTextTranslate``
72
+
* Input shape:
73
+
* ``input``: ``Text``
74
+
* ``origin_language``: ``Enum``
75
+
* ``target_language``: ``Enum``
76
+
* Output shape:
77
+
* ``output``: ``Text``
71
78
* ``'core:audio2text'``: This task type is for transcribing audio to text. It is implemented by ``\OCP\TaskProcessing\TaskTypes\AudioToText``
72
79
* Input shape:
73
80
* ``input``: ``Audio``
@@ -126,6 +133,7 @@ Input and output shape keys can have one of a pre-defined set of types, which ar
126
133
case Audio = 3;
127
134
case Video = 4;
128
135
case File = 5;
136
+
case Enum = 6;
129
137
case ListOfNumbers = 10;
130
138
case ListOfTexts = 11;
131
139
case ListOfImages = 12;
@@ -158,6 +166,17 @@ The task class objects have the following methods available:
158
166
* ``getAppId()`` This returns the originating application ID of the task.
159
167
* ``getCustomId()`` This returns the original scheduler-defined identifier for the task
160
168
* ``getUserId()`` This returns the originating user ID of the task.
169
+
* ``getCompletionExpectedAt()`` This is available after scheduling the task and returns the DateTime when the task is expected to be completed
170
+
* ``getLastUpdated()`` This returns the time the task was last updated as a unix timestamp
171
+
* ``getScheduledAt()`` This returns the time the task was scheduled as a unix timestamp
172
+
* ``getStartedAt()`` This returns the time the task execution started as a unix timestamp
173
+
* ``getEndedAt()`` This returns the time the task execution ended as a unix timestamp
174
+
* ``getErrorMessage()`` This returns the error message if the task execution failed
175
+
* ``getProgress()`` This returns the current task progress, between 0 and 1 while the task is running. Will be 1 when the task is completed
176
+
* ``setWebhookUri()`` This sets the URI of a webhook that will be notified when the task execution has ended
177
+
* ``setWebhookMethod()`` This sets the HTTP method that will be used for the webhook when the task execution has ended
178
+
* ``getWebhookUri()`` This returns the webhook URI that will be notified when the task execution has ended
179
+
* ``getWebhookMethod()`` This returns the HTTP method that will be used for the webhook when the task execution has ended
161
180
162
181
You could now schedule the task as follows:
163
182
@@ -261,7 +280,7 @@ A **Task processing provider** will usually be a class that implements the inter
261
280
) {
262
281
}
263
282
264
-
public function getId() {
283
+
public function getId(): string {
265
284
return 'myapp:summary';
266
285
}
267
286
@@ -277,17 +296,129 @@ A **Task processing provider** will usually be a class that implements the inter
277
296
// Return the output here
278
297
}
279
298
280
-
public function getExpectedRuntime() {
299
+
public function getExpectedRuntime(): int {
281
300
// usually takes 1min on average
282
301
return 60;
283
302
}
303
+
304
+
public function getInputShapeDefaults(): array {
305
+
return [];
306
+
}
307
+
308
+
public function getOptionalInputShape(): array {
309
+
return [];
310
+
}
311
+
312
+
public function getOptionalInputShapeDefaults(): array {
313
+
return [];
314
+
}
315
+
316
+
public function getOptionalOutputShape(): array {
317
+
return [];
318
+
}
319
+
320
+
public function getInputShapeEnumValues(): array {
321
+
return [];
322
+
}
323
+
324
+
public function getOptionalInputShapeEnumValues(): array {
325
+
return [];
326
+
}
327
+
328
+
public function getOutputShapeEnumValues(): array {
329
+
return [];
330
+
}
331
+
332
+
public function getOptionalOutputShapeEnumValues(): array {
333
+
return [];
334
+
}
284
335
}
285
336
286
337
The method ``getName`` returns a string to identify the registered provider in the user interface.
287
338
288
339
The method ``process`` implements the text processing step. In case execution fails for some reason, you should throw a ``\OCP\TaskProcessing\Exception\ProcessingException`` with an explanatory error message. Important to note here is that ``Image``, ``Audio``, ``Video`` and ``File`` slots in the input array will be filled with ``\OCP\Files\File`` objects for your convenience. When outputting one of these you should simply return a string, the API will turn the data into a proper file for convenience. The ``$reportProgress`` parameter is a callback that you may use at will to report the task progress as a single float value between 0 and 1. Its return value will indicate if the task is still running (``true``) or if it was cancelled (``false``) and processing should be terminated.
289
340
290
-
This class would typically be saved into a file in ``lib/TextProcessing`` of your app but you are free to put it elsewhere as long as it's loadable by Nextcloud's :ref:`dependency injection container<dependency-injection>`.
341
+
This class would typically be saved into a file in ``lib/TaskProcessing`` of your app but you are free to put it elsewhere as long as it's loadable by Nextcloud's :ref:`dependency injection container<dependency-injection>`.
342
+
343
+
Providing additional inputs and outputs
344
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
345
+
346
+
Built-in task types often only specify the most basic input and output slots. If you would like to offer more input options
347
+
with your provider you can specify optional inputs and outputs using the ``getOptionalInputShape`` and ``getOptionalOutputShape`` methods.
348
+
You will need to return an associative array of ``\OCP\TaskProcessing\ShapeDescriptor`` objects.
349
+
350
+
.. code-block:: php
351
+
352
+
public function getOptionalInputShape(): array {
353
+
return [
354
+
'tone' => new ShapeDescriptor($this->l->t('Tone of voice'), $this->l->t('Set the tone of voice to be used for the output'), EShapeType::Text)
355
+
];
356
+
}
357
+
358
+
In the same vein you can also provide optional output shape slots in addition to the pre-defined output slots.
359
+
360
+
.. code-block:: php
361
+
362
+
public function getOptionalOutputShape(): array {
363
+
return [
364
+
'co2_emissions' => new ShapeDescriptor($this->l->t('CO2 Emissions'), $this->l->t('The CO2 emissions produced by running this task in metric tons'), EShapeType::Number)
365
+
];
366
+
}
367
+
368
+
Providing input defaults
369
+
^^^^^^^^^^^^^^^^^^^^^^^^
370
+
371
+
With the method ``getInputShapeDefaults`` you can specify default values for input slots (which are defined by the task type). For example:
372
+
373
+
.. code-block:: php
374
+
375
+
public function getInputShapeDefaults(): array {
376
+
return [
377
+
'input' => 'There was once a man with many cows who wanted to have even more cows.'
378
+
];
379
+
}
380
+
381
+
Note that you can only specify default values for 'Text' and 'Number' slots.
382
+
383
+
The same works for your optional input shapes that you defined in ``getOptionalInputShape``:
384
+
385
+
.. code-block:: php
386
+
387
+
public function getOptionalInputShapeDefaults(): array {
388
+
return [
389
+
'tone' => 'Formal'
390
+
];
391
+
}
392
+
393
+
Working with Enum shape types
394
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
395
+
396
+
Both input and output shapes as well as the optional input and output shapes allow declaring slots of type ``'Enum'``. An Enum
397
+
is a type that only allows values from a pre-defined set. In the case of the TaskProcessing API this set is not defined by the task type, but
398
+
by the provider implementing the task type using ``getInputShapeEnumValues``, ``getOutputShapeEnumValues``, ``getOptionalInputShapeEnumValues`` and ``getOptionalOutputShapeEnumValues``.
399
+
400
+
You could, for example, implement the above tone of voice slot using an Enum:
401
+
402
+
.. code-block:: php
403
+
404
+
public function getOptionalInputShape(): array {
405
+
return [
406
+
'tone' => new ShapeDescriptor($this->l->t('Tone of voice'), $this->l->t('Set the tone of voice to be used for the output'), EShapeType::Enum)
407
+
];
408
+
}
409
+
410
+
.. code-block:: php
411
+
412
+
public function getOptionalInputShapeEnumValues(): array {
413
+
return [
414
+
'tone' => [
415
+
new ShapeEnumValue($this->l->t('Simple'), 'So that a kid could understand'),
416
+
new ShapeEnumValue($this->l->t('Funny'), 'Funny'),
417
+
new ShapeEnumValue($this->l->t('Formal'), 'Formal'),
Copy file name to clipboardExpand all lines: developer_manual/digging_deeper/text2image.rst
+3
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@ Text-To-Image
6
6
7
7
.. versionadded:: 28
8
8
9
+
.. deprecated:: 30
10
+
Use the TaskProcessing API instead
11
+
9
12
Nextcloud offers a **Text-To-Image** API. The overall idea is that there is a central OCP API that apps can use to prompt tasks to latent diffusion AI models and similar image generation tools. To be technology agnostic any app can provide this functionality by registering a Text-To-Image provider.
Copy file name to clipboardExpand all lines: developer_manual/digging_deeper/text_processing.rst
+4
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,10 @@ Text Processing
6
6
7
7
.. versionadded:: 27.1.0
8
8
9
+
.. deprecated:: 30
10
+
Use the TaskProcessing API instead
11
+
12
+
9
13
Nextcloud offers a **Text Processing** API. The overall idea is that there is a central OCP API that apps can use to prompt tasks to Large Language Models and similar text processing tools. To be technology agnostic any app can provide this functionality by registering Text Processing providers.
Copy file name to clipboardExpand all lines: developer_manual/digging_deeper/translation.rst
+4-1
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,9 @@ Machine Translation
6
6
7
7
.. versionadded:: 26
8
8
9
+
.. deprecated:: 30
10
+
Use the TaskProcessing API instead
11
+
9
12
Nextcloud offers a **Translation** API. The overall idea is that there is a central OCP API that apps can use to request machine translations of text. To be technology agnostic any app can provide this Translation functionality by registering a Translation provider.
10
13
11
14
Consuming the Translation API
@@ -187,4 +190,4 @@ The provider class is registered via the :ref:`bootstrap mechanism<Bootstrapping
187
190
188
191
public function boot(IBootContext $context): void {}
0 commit comments