Skip to content

Commit

Permalink
Refactoring and supporting SSE server (#59)
Browse files Browse the repository at this point in the history
* Refactoring and supporting SSE server

* refine

* refine

* refine config

* refine

* refine error print

* add kolors demo

* refine

* refine set API_KEY

* refine examples json

* refine routing

* fix merge

* refine

* annotate unverified ipa nodes

* Add docs for bizyair ksampler (#65)

* refine

* add docs

* update kolors docs

* add news

* refine

* refine

* refine kolors inpaintig workflow

* refine

* reformat

* refine

* Update download URL in README.md (#66)

* refine

* remove useless model

* refine interior design

* refine

* refine

---------

Co-authored-by: Yao Chi <[email protected]>
Co-authored-by: Shenghang Tsai <[email protected]>
  • Loading branch information
3 people authored Aug 1, 2024
1 parent 1d95bb8 commit 67a0a0b
Show file tree
Hide file tree
Showing 50 changed files with 5,289 additions and 1,801 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ __pycache__/
.idea/
venv/
*.log

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# BizyAir

- [2024/08/01] 🌩️ [BizyAir MinusZone Kolors](https://siliconflow.github.io/BizyAir/kolors/introduce.html) nodes have been released(thanks to [MinusZoneAI/ComfyUI-Kolors-MZ](https://github.com/MinusZoneAI/ComfyUI-Kolors-MZ)), and BizyAir now supports over 10 new base models. They all support ControlNet, LoRA, and IPAdapter. [BizyAir KSampler](https://siliconflow.github.io/BizyAir/ksampler/introduce.html)
- [2024/07/31] 🌩️ The super-resolution node has been released, capable of enlarging images four times their original size. [BizyAir Photorealistic Image Super Resolution](https://siliconflow.github.io/BizyAir/others/index.html#bizyair-photorealistic-image-super-resolution)
- [2024/07/25] 🌩️ Users can load BizyAir workflow examples directly by clicking the "☁️BizyAir Workflow Examples" button. [Example GIF](./docs/docs/getting-started/imgs/run-bizyair-examples.gif)
- [2024/07/23] 🌩️ [BizyAir ChatGLM3 Text Encode](./examples/bizyair_showcase_run_with_local_nodes.json) node is released.
Expand Down Expand Up @@ -79,7 +80,7 @@ https://github.com/siliconflow/ComfyUI/releases/tag/latest

For CN users:

https://bizy-air.oss-cn-beijing.aliyuncs.com/new_ComfyUI_windows_portable_nvidia_cu121_or_cpu.7z
https://bizy-air.oss-cn-beijing.aliyuncs.com/new_ComfyUI_windows_portable_nvidia_none_or_cpu.7z


## Examples
Expand Down
12 changes: 9 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from . import register
import os
import sys

current_path = os.path.abspath(os.path.dirname(__file__))
src_path = os.path.join(current_path, "src")
if os.path.isdir(src_path):
sys.path.insert(0, src_path)

from bizyair import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
from . import nodes
from . import bizyair_extras
from . import showcase

WEB_DIRECTORY = "./js"
NODE_CLASS_MAPPINGS: dict = register.NODE_CLASS_MAPPINGS
NODE_DISPLAY_NAME_MAPPINGS: dict = register.NODE_DISPLAY_NAME_MAPPINGS


from . import auth
Expand Down
2 changes: 1 addition & 1 deletion api_key.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[auth]
# api_key =
# api_key =
41 changes: 33 additions & 8 deletions auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import configparser
import server
from aiohttp import web
import bizyair


API_KEY = None
Expand Down Expand Up @@ -84,6 +85,25 @@
"""


def load_api_key():
current_directory = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(current_directory, "api_key.ini")

if os.path.exists(file_path):
config = configparser.ConfigParser()
config.read(file_path)
api_key: str = config.get("auth", "api_key", fallback="").strip().strip("'\"")
has_key = api_key.startswith("sk-")
return has_key, api_key
else:
return False, ""


has_key, api_key = load_api_key()
if has_key:
API_KEY = api_key


@server.PromptServer.instance.routes.get("/bizyair/set-api-key")
async def set_api_key_page(request):
return web.Response(text=set_api_key_html, content_type="text/html")
Expand All @@ -92,14 +112,19 @@ async def set_api_key_page(request):
@server.PromptServer.instance.routes.post("/bizyair/set_api_key")
async def set_api_key(request):
global API_KEY
has_key, api_key = load_api_key()
if has_key:
API_KEY = api_key
bizyair.set_api_key(API_KEY)
return web.Response(text="Key has been loaded from the api_key.ini file")
data = await request.post()
api_key = data.get("api_key")

try:
if api_key:
response = web.Response(text="ok")
response.set_cookie("api_key", api_key, max_age=30 * 24 * 60 * 60)
API_KEY = api_key
bizyair.set_api_key(API_KEY)
return response
else:
return web.Response(
Expand All @@ -113,19 +138,19 @@ async def set_api_key(request):
@server.PromptServer.instance.routes.get("/bizyair/get_api_key")
async def get_api_key(request):
global API_KEY
api_key = ""
current_directory = os.path.dirname(os.path.abspath(__file__))
file_path = os.path.join(current_directory, "api_key.ini")
if os.path.exists(file_path):
config = configparser.ConfigParser()
config.read(file_path)
api_key = config.get("auth", "api_key", fallback="").strip()
has_key, api_key = load_api_key()
if has_key:
API_KEY = api_key
bizyair.set_api_key(API_KEY)
return web.Response(text="Key has been loaded from the api_key.ini file")

if api_key == "":
api_key = request.cookies.get("api_key")
try:
if api_key:
API_KEY = api_key
response = web.Response(text="ok")
bizyair.set_api_key(API_KEY)
return response
else:
return web.Response(
Expand Down
Loading

0 comments on commit 67a0a0b

Please sign in to comment.