Files
siliconflow-BizyAir/showcase.py
685489435f add model community (#230)
* [feat]optimize tailwind config

* [feat]init shadcn vue

* fix

* query sort

* fix

* [feat]add model select component

* fix

* types

* types

* [feat]add model select dialog

* [feat]show model select

* [feat]add test

* fix

* fix

* fix

* [feat]fetch data with api

* [feat]add parameter to model select component

* fix

* fix

* [feat] optimize my code

* like

* base model types

* [feat]add vditor editor

* download

* download

* workflow

* fix

* [feat]custom full screen

* [feat]custom vditor full screen

* fix

* disable vditor cache

* [feat] fix single page used bugs

* [feat]fix

* fix

* [feat]fix vditor can't fullscreen

* fix

* [feat]optimize model select component & +remove model & optimize filter

* fix

* fix

* [feat]optimize alert dialog used

* [feat]+ apply node model widge

* [feat]optimize

* [feat]add model detail

* fix

* [feat]optimize class

* [feat]add debounce for node widget dbclick

* [feat]optimize model detail

* fix

* lijing test

* [feat]optimize node apply

* reformat

* [feat] fix editor preview image z-index

* [feat]optimize

* fix

* fix

* fix

* [feat]optimize scrollbar style & detail apply modelversion & remove model

* [feat] new version

* fix

* interrupt

* fix

* [feat]optimize

* [feat] add edit

* interrupt

* [feat]optimize expandedModels & model select scrollbar

* [feat]optimize filter

* fix

* [feat]update toast for big brother

* [feat]add easy-markdown

* interrupt

* fix

* [feat]add mini markdown editor

* [feat]remove unused test code

* fix

* [feat]optimize scroll model version

* fix

* [feat]add scroll area for model detail

* fix

* [feat]codereview for myself

* [feat]remove debug console.log

* fix

* status

* fix

* [fix]filter class & model detail scrollbar

* fix

* hash

* [feat]optimize style

* [feat]optimize tab

* hash

* [feat]fix filterbar bugs

* [feat]replace frontend modelTypes Array

* fix

* [feat]delete unuse files

* [feat]optimize preview md

* [feat]release

* [feat]optimize scroll

* [feat]optimize model detail

* fix

* fix

* [feat]code review

* [feat]optimize APIClient requests to aiohttp

* [feat]fix cancel update version fetch model list data error

* [feat]optimize scroll style & add sekleton for table model

* [feat]optimize model version scroll

* [feat]remove unused code

* fix

* [fix]auto merge

* [fix]code review

* fix

* fix

* fix

* remove useless code

* [feat]optimize model list fetch nodata

* Dev bbs patch 2 (#229)

* Refine cn lora loader node

* refine

* add exec_info

---------

Co-authored-by: Yao Chi <later@usopp.net>

* [feat]fix seach keywords no data bug

* fix

* add upload_id when upload error

* fix

* [feat]fix model list bug for page

* [feat]release core js

* fix

* fix do_get

* [feat] add loadding for model list

* [feat]update core js

* [feat]remove unused code

* remove wrong env var

* fix

* [fix]tab style

* [fix]resolve  default css

* [feat]relase new core js

* [feat]relase

* [feat]remove unusedcode

* [feat]relase

* fix

* fix

* Add biz_lib_frontend as a submodule(bizyair_frontend repo) (#237)

* Add biz_lib_frontend as a submodule(bizyair_frontend repo)

* checkou to dev_bbs branch

* Dev bbs rename submodule (#238)

* rename submoudle to bizyair_frontend

* update gitmodules

* reformat

* add frontend submodule (#239)

* use https url

* [feat]fix filter bug

* fix threading and session problems (#240)

* fix

* fix model_version_id_missing (#242)

* refine

* refine

* update tow api in upload progress

* add poc of js hash calculation

* Update prompt_processor.py

model_version_ids 修改为int数组

* fix

* m1

* m1

* m1

* m1

* remove useless codes

* timeout time to 2 seconds

* reformat

* [feat]optimize

* Remove package.json and package-lock.json files as part of project cleanup

* Remove unused biz_lib_frontend.js file and refactor bizyair_frontend.js for improved code organization and readability.

* fix

* fix

* Update subproject reference and refactor bizyair_frontend.js to improve code structure and reduce size.

* [feat]relase

* Fix tags are selected by default (#256)

Co-authored-by: Yao Chi <later@usopp.net>

* Refactor LoRA and ControlNet widget callbacks for improved error handling and functionality

- Introduced a new `createSetWidgetCallback` function to streamline widget event handling for LoRA and ControlNet loaders.
- Enhanced error handling during node creation and mouse event processing.
- Removed redundant code related to mouse event handling, improving readability and maintainability.
- Updated widget properties to ensure proper interaction and prevent default behaviors.

This refactor aims to enhance the user experience by ensuring that model selection is more robust and error-free.

* fix

* fix

* [feat]修复低版本无法弹出

* [feat]relase frontend

* [feat]release opt z-index

* fix

* [feat]fix bug & relase frontend

* [feat]fix bug & release frontend

* fix

* fix

* add news

* “fix”

* fix

* reformat

---------

Co-authored-by: of-HaiQin <5372604@qq.com>
Co-authored-by: dantegarden <761043617@qq.com>
Co-authored-by: Your Name <you@example.com>
Co-authored-by: YaoChi <later@usopp.net>
Co-authored-by: FengWen <ccsuwen@gmail.com>
Co-authored-by: FengWen <109639975+ccssu@users.noreply.github.com>
2024-12-05 16:56:40 +08:00

122 lines
3.5 KiB
Python

import asyncio
import json
import os
import urllib.error
import urllib.request
import aiohttp
import server
from aiohttp import web
BIZYAIR_DEBUG = os.getenv("BIZYAIR_DEBUG", False)
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
SHOW_CASES = {}
async def get_bizyair_news(base_url="https://bizyair.siliconflow.cn"):
url = f"{base_url}/bznews.json"
try:
async with aiohttp.ClientSession() as session:
async with session.get(url, timeout=2) as response:
if response.status == 200:
data = await response.text()
return json.loads(data)
else:
print(f"Failed to fetch bznews.json: HTTP Status {response.status}")
return {}
except aiohttp.ClientError as e:
print(f"Error fetching bznews.json: {e}")
return {}
except asyncio.exceptions.TimeoutError as e:
print(f"Request bizyair news timed out: {e}")
return {}
except Exception as e:
print(f"Error fetching BizyAir bznews.json: {type(e).__name__} - {str(e)}")
return {}
with open(os.path.join(CURRENT_DIR, "bizyair_example_menu.json"), "r") as file:
SHOW_CASES.update(json.load(file))
def extract_files(data):
file_whitelist = []
for key, value in data.items():
if isinstance(value, dict):
file_whitelist.extend(extract_files(value))
else:
file_whitelist.append(value)
return file_whitelist
file_whitelist = extract_files(SHOW_CASES)
from server import PromptServer
@PromptServer.instance.routes.get("/bizyair/showcases")
async def set_api_key_page(request):
return web.Response(
text=json.dumps(SHOW_CASES, ensure_ascii=False), content_type="application/json"
)
@PromptServer.instance.routes.get("/bizyair/news")
async def list_news(request):
return web.Response(
text=json.dumps(await get_bizyair_news(), ensure_ascii=False),
content_type="application/json",
)
@PromptServer.instance.routes.post("/bizyair/workflow")
async def get_file_content(request):
try:
data = await request.json()
except json.JSONDecodeError:
return web.Response(
text=json.dumps({"error": "Invalid JSON body"}),
status=400,
content_type="application/json",
)
filename = data.get("file")
if not filename:
return web.Response(
text=json.dumps({"error": "Missing file parameter"}),
status=400,
content_type="application/json",
)
if filename not in file_whitelist:
return web.Response(
text=json.dumps({"error": "Filename not allowed"}),
status=400,
content_type="application/json",
)
file_path = os.path.join(CURRENT_DIR, "examples", filename)
if BIZYAIR_DEBUG:
print(f"request the json workflow: {file_path}")
if not os.path.isfile(file_path):
return web.Response(
text=json.dumps({"error": "File not found"}),
status=404,
content_type="application/json",
)
try:
with open(file_path, "r", encoding="utf-8") as file:
file_content = json.load(file)
return web.Response(
text=json.dumps(file_content, ensure_ascii=False),
content_type="application/json",
)
except Exception as e:
return web.Response(
text=json.dumps({"error": str(e)}),
status=500,
content_type="application/json",
)