Skip to content

Commit

Permalink
AppAPI 2.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 committed Jan 25, 2024
1 parent 122123f commit 6c2ede8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
]]></description>
<version>1.0.1</version>
<version>2.0.0</version>
<licence>MIT</licence>
<author mail="[email protected]" homepage="https://github.com/andrey18106">Andrey Borysenko</author>
<author mail="[email protected]" homepage="https://github.com/bigcat88">Alexander Piskun</author>
Expand All @@ -41,7 +41,7 @@ This is not an example, this is a ready-to-use application, just enable the bot
<docker-install>
<registry>ghcr.io</registry>
<image>cloud-py-api/ai_image_generator_bot</image>
<image-tag>1.0.0</image-tag>
<image-tag>2.0.0</image-tag>
</docker-install>
<scopes>
<required>
Expand Down
6 changes: 4 additions & 2 deletions lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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/"):
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6c2ede8

Please sign in to comment.