From 6c2ede874e4c59241554c48bd0f56235e5a8f833 Mon Sep 17 00:00:00 2001 From: Alexander Piskun Date: Thu, 25 Jan 2024 18:40:15 +0300 Subject: [PATCH] AppAPI 2.0 support --- Makefile | 14 +++++++------- appinfo/info.xml | 4 ++-- lib/main.py | 6 ++++-- requirements.txt | 3 +-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 1bf2e5e..f6ac549 100644 --- a/Makefile +++ b/Makefile @@ -24,42 +24,42 @@ help: .PHONY: build-push build-push: docker login ghcr.io - docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/cloud-py-api/ai_image_generator_bot:1.0.0 --tag ghcr.io/cloud-py-api/ai_image_generator_bot:latest . + docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/cloud-py-api/ai_image_generator_bot:2.0.0 --tag ghcr.io/cloud-py-api/ai_image_generator_bot:latest . .PHONY: deploy deploy: docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true - docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:deploy ai_image_generator_bot docker_dev \ + docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:deploy ai_image_generator_bot \ --info-xml https://raw.githubusercontent.com/cloud-py-api/ai_image_generator_bot/main/appinfo/info.xml .PHONY: deploy27 deploy27: docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true - docker exec master-stable27-1 sudo -u www-data php occ app_api:app:deploy ai_image_generator_bot docker_dev \ + docker exec master-stable27-1 sudo -u www-data php occ app_api:app:deploy ai_image_generator_bot \ --info-xml https://raw.githubusercontent.com/cloud-py-api/ai_image_generator_bot/main/appinfo/info.xml .PHONY: run run: docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true - docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot docker_dev --force-scopes \ + docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot --force-scopes \ --info-xml https://raw.githubusercontent.com/cloud-py-api/ai_image_generator_bot/main/appinfo/info.xml .PHONY: run27 run27: docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true - docker exec master-stable27-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot docker_dev --force-scopes \ + docker exec master-stable27-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot --force-scopes \ --info-xml https://raw.githubusercontent.com/cloud-py-api/ai_image_generator_bot/main/appinfo/info.xml .PHONY: register register: docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true docker exec master-nextcloud-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot manual_install --json-info \ - "{\"appid\":\"ai_image_generator_bot\",\"name\":\"AIImageGeneratorBot\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"host\":\"host.docker.internal\",\"port\":9080,\"scopes\":{\"required\":[\"TALK\", \"TALK_BOT\", \"FILES\", \"FILES_SHARING\"],\"optional\":[]},\"protocol\":\"http\",\"system_app\":1}" \ + "{\"appid\":\"ai_image_generator_bot\",\"name\":\"AIImageGeneratorBot\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9080,\"scopes\":{\"required\":[\"TALK\", \"TALK_BOT\", \"FILES\", \"FILES_SHARING\"],\"optional\":[]},\"system_app\":1}" \ --force-scopes --wait-finish .PHONY: register27 register27: docker exec master-stable27-1 sudo -u www-data php occ app_api:app:unregister ai_image_generator_bot --silent --force || true docker exec master-stable27-1 sudo -u www-data php occ app_api:app:register ai_image_generator_bot manual_install --json-info \ - "{\"appid\":\"ai_image_generator_bot\",\"name\":\"AIImageGeneratorBot\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"host\":\"host.docker.internal\",\"port\":9080,\"scopes\":{\"required\":[\"TALK\", \"TALK_BOT\", \"FILES\", \"FILES_SHARING\"],\"optional\":[]},\"protocol\":\"http\",\"system_app\":1}" \ + "{\"appid\":\"ai_image_generator_bot\",\"name\":\"AIImageGeneratorBot\",\"daemon_config_name\":\"manual_install\",\"version\":\"1.0.0\",\"secret\":\"12345\",\"port\":9080,\"scopes\":{\"required\":[\"TALK\", \"TALK_BOT\", \"FILES\", \"FILES_SHARING\"],\"optional\":[]},\"system_app\":1}" \ --force-scopes --wait-finish diff --git a/appinfo/info.xml b/appinfo/info.xml index 0d34cc8..9573137 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -19,7 +19,7 @@ This is not an example, this is a ready-to-use application, just enable the bot `@image cinematic portrait of fluffy cat with black eyes` ]]> - 1.0.1 + 2.0.0 MIT Andrey Borysenko Alexander Piskun @@ -41,7 +41,7 @@ This is not an example, this is a ready-to-use application, just enable the bot ghcr.io cloud-py-api/ai_image_generator_bot - 1.0.0 + 2.0.0 diff --git a/lib/main.py b/lib/main.py index 3149897..ebb5b6b 100644 --- a/lib/main.py +++ b/lib/main.py @@ -16,7 +16,8 @@ from nc_py_api import AsyncNextcloudApp, NextcloudApp from nc_py_api.ex_app import ( LogLvl, - atalk_bot_app, + anc_app, + atalk_bot_msg, persistent_storage, run_app, set_handlers, @@ -126,7 +127,8 @@ async def stable_diffusion_process_request(message: TalkBotMessage): @APP.post("/stable_diffusion") async def stable_diffusion( - message: Annotated[TalkBotMessage, Depends(atalk_bot_app)], + message: Annotated[TalkBotMessage, Depends(atalk_bot_msg)], + _nc: Annotated[AsyncNextcloudApp, Depends(anc_app)], background_tasks: BackgroundTasks, ): if message.object_name == "message" and message.actor_id.startswith("users/"): diff --git a/requirements.txt b/requirements.txt index 8b4a424..7f14a1e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,7 @@ -nc_py_api[app]>=0.7.0 +nc_py_api[app]>=0.9.0 diffusers>=0.23.1 transformers>=4.36.1 accelerate huggingface_hub torch torchvision -torchaudio