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
Changes proposed in this pull request:
* Adjusted AI example to use automatic model download feature
* Adjusted Makefiles of all examples
* Fixed missing default icon for `files_dropdown_menu` API
* Updated README.md
---------
Signed-off-by: Alexander Piskun <[email protected]>
Copy file name to clipboardExpand all lines: docs/NextcloudApp.rst
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,12 +12,12 @@ Skeleton
12
12
13
13
What's going on in the skeleton?
14
14
15
-
First, it's important to understand that an external application acts more like a microservice, with its endpoints being called by Nextcloud.
15
+
In `FastAPI lifespan <https://fastapi.tiangolo.com/advanced/events/?h=lifespan#lifespan>`_ we call the ``set_handlers`` function to further process the application installation logic.
16
16
17
-
Therefore, when the application receives a request at the endpoint ``/enable``,
18
-
it should register all its functionalities in the cloud and wait for requests from Nextcloud.
17
+
Since this is a simple skeleton application, we only define the ``/enable`` endpoint.
19
18
20
-
.. note:: This doesn't apply to system applications, which will be covered in the next chapter.
19
+
When the application receives a request at the endpoint ``/enable``,
20
+
it should register all its functionalities in the cloud and wait for requests from Nextcloud.
21
21
22
22
So, calling:
23
23
@@ -54,7 +54,7 @@ Here they are:
54
54
55
55
* APP_ID - ID of the application.
56
56
* APP_PORT - Port on which application listen for the requests from the Nextcloud.
57
-
* APP_SECRET - Secret for ``hmac`` signature generation.
57
+
* APP_SECRET - Shared secret between Nextcloud and Application.
58
58
* APP_VERSION - Version of the application.
59
59
* AA_VERSION - Version of the AppAPI.
60
60
* NEXTCLOUD_URL - URL at which the application can access the Nextcloud API.
@@ -67,7 +67,7 @@ After launching your application, execute the following command in the Nextcloud
Copy file name to clipboardExpand all lines: docs/NextcloudTalkBotTransformers.rst
+14-54Lines changed: 14 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ Requirements
37
37
We opt for the latest version of the Transformers library.
38
38
Because the example was developed on a Mac, we ended up using Torchvision.
39
39
40
-
`If you're working solely with Nvidia, you're free to use TensorFlow instead of PyTorch.`
40
+
`You're free to use TensorFlow instead of PyTorch.`
41
41
42
42
Next, we integrate the latest version of `nc_py_api` to minimize code redundancy and focus on the application's logic.
43
43
@@ -52,63 +52,20 @@ We specify the model name globally so that we can easily change the model name i
52
52
53
53
**When Should We Download the Language Model?**
54
54
55
-
Although the example uses the smallest model available, weighing in at 300 megabytes, it's common knowledge that larger language models can be substantially bigger.
56
-
Downloading such models should not begin when a processing request is already received.
55
+
To make process of initializing applications more robust, separate logic was introduced, with an ``/init`` endpoint.
57
56
58
-
So we have two options:
59
-
60
-
* Heartbeat
61
-
* enabled_handler
62
-
63
-
This can't be accomplished in the **app on/off handler** as Nextcloud expects an immediate response regarding the app's operability.
64
-
65
-
Thus, we place the model downloading within the Heartbeat:
66
-
67
-
.. code-block::
68
-
69
-
# Thread that performs model download.
70
-
def download_models():
71
-
pipeline("text2text-generation", model=MODEL_NAME) # this will download model
72
-
73
-
74
-
def heartbeat_handler() -> str:
75
-
global MODEL_INIT_THREAD
76
-
print("heartbeat_handler: called") # for debug
77
-
# if it is the first heartbeat, then start background thread to download a model
.. note:: While this may not be the most ideal way to download models, it remains a viable method.
95
-
In the future, a more efficient wrapper for model downloading is planned to make the process even more convenient.
96
-
97
-
Model Storage
98
-
"""""""""""""
99
-
100
-
By default, models will be downloaded to a directory that's removed when updating the app.
101
-
To persistently store the models even after updates, add the following line to your code:
57
+
This library also provides an additional functionality over this endpoint for easy downloading of models from the `huggingface <https://huggingface.co>`_.
102
58
103
59
.. code-block::
104
60
105
-
from nc_py_api.ex_app import persist_transformers_cache # noqa # isort:skip
0 commit comments