bizyengine 1.2.81__py3-none-any.whl → 1.2.82__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bizyengine/bizy_server/api_client.py +22 -0
- bizyengine/bizy_server/errno.py +7 -0
- bizyengine/bizy_server/server.py +16 -0
- bizyengine/bizyair_extras/third_party_api/__init__.py +1 -0
- bizyengine/bizyair_extras/third_party_api/nodes_vlm.py +120 -0
- bizyengine/core/common/client.py +1 -0
- bizyengine/misc/utils.py +38 -0
- bizyengine/version.txt +1 -1
- {bizyengine-1.2.81.dist-info → bizyengine-1.2.82.dist-info}/METADATA +1 -1
- {bizyengine-1.2.81.dist-info → bizyengine-1.2.82.dist-info}/RECORD +12 -11
- {bizyengine-1.2.81.dist-info → bizyengine-1.2.82.dist-info}/WHEEL +0 -0
- {bizyengine-1.2.81.dist-info → bizyengine-1.2.82.dist-info}/top_level.txt +0 -0
|
@@ -1230,3 +1230,25 @@ class APIClient:
|
|
|
1230
1230
|
f"\033[31m[BizyAir]\033[0m Fail to get trd api node {model} pricing: {str(e)}"
|
|
1231
1231
|
)
|
|
1232
1232
|
return None, errnos.TRD_API_PRICING
|
|
1233
|
+
|
|
1234
|
+
async def get_trd_nodes_by_type(
|
|
1235
|
+
self, type, request_api_key: str = None
|
|
1236
|
+
) -> tuple[dict | None, ErrorNo | None]:
|
|
1237
|
+
server_url = f"{BIZYAIR_X_SERVER}/trd_api/nodes/query"
|
|
1238
|
+
headers, err = self.auth_header(api_key=request_api_key)
|
|
1239
|
+
if err is not None:
|
|
1240
|
+
return None, err
|
|
1241
|
+
|
|
1242
|
+
try:
|
|
1243
|
+
ret, err = await self.do_get(
|
|
1244
|
+
server_url, headers=headers, params={"model_type": type}
|
|
1245
|
+
)
|
|
1246
|
+
if err is not None:
|
|
1247
|
+
return None, err
|
|
1248
|
+
|
|
1249
|
+
return ret["data"], None
|
|
1250
|
+
except Exception as e:
|
|
1251
|
+
print(
|
|
1252
|
+
f"\033[31m[BizyAir]\033[0m Fail to get trd api node of type {type}: {str(e)}"
|
|
1253
|
+
)
|
|
1254
|
+
return None, errnos.GET_TRD_NODES
|
bizyengine/bizy_server/errno.py
CHANGED
bizyengine/bizy_server/server.py
CHANGED
|
@@ -985,6 +985,22 @@ class BizyAirServer:
|
|
|
985
985
|
return ErrResponse(err)
|
|
986
986
|
return OKResponse(pricing)
|
|
987
987
|
|
|
988
|
+
@self.prompt_server.routes.get(f"/{API_PREFIX}/trd_nodes")
|
|
989
|
+
async def get_trd_nodes_by_type(request):
|
|
990
|
+
from bizyengine.misc.utils import cache_trd_models, get_trd_models
|
|
991
|
+
|
|
992
|
+
request_api_key, err = _get_request_api_key(request.headers)
|
|
993
|
+
if err:
|
|
994
|
+
return ErrResponse(err)
|
|
995
|
+
type = request.rel_url.query.get("type", "")
|
|
996
|
+
if not type:
|
|
997
|
+
return ErrResponse(errnos.INVALID_TYPE)
|
|
998
|
+
cache_trd_models(type, request_api_key)
|
|
999
|
+
models = get_trd_models(type)
|
|
1000
|
+
if models is None:
|
|
1001
|
+
return ErrResponse(errnos.NO_MODEL_FOUND)
|
|
1002
|
+
return OKResponse(models)
|
|
1003
|
+
|
|
988
1004
|
# 服务器模式独占
|
|
989
1005
|
if BIZYAIR_SERVER_MODE:
|
|
990
1006
|
return
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
from bizyairsdk import tensor_to_bytesio
|
|
2
|
+
|
|
3
|
+
from .trd_nodes_base import BizyAirTrdApiBaseNode
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TRD_VLM_API(BizyAirTrdApiBaseNode):
|
|
7
|
+
NODE_DISPLAY_NAME = "Third-Party VLM API"
|
|
8
|
+
RETURN_TYPES = (
|
|
9
|
+
"STRING",
|
|
10
|
+
"""{"gemini-3-pro-preview": "gemini-3-pro-preview", "gemini-3-flash-preview": "gemini-3-flash-preview"}""", # NOTE: 需要动态获取
|
|
11
|
+
)
|
|
12
|
+
RETURN_NAMES = ("string", "bizyair_model_name")
|
|
13
|
+
CATEGORY = "☁️BizyAir/External APIs/VLM"
|
|
14
|
+
INPUT_IS_LIST = True
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def INPUT_TYPES(s):
|
|
18
|
+
return {
|
|
19
|
+
"required": {
|
|
20
|
+
"model": (
|
|
21
|
+
["gemini-3-pro-preview", "gemini-3-flash-preview"],
|
|
22
|
+
{"default": "gemini-3-flash-preview"},
|
|
23
|
+
), # NOTE: 需要动态获取
|
|
24
|
+
"system_prompt": (
|
|
25
|
+
"STRING",
|
|
26
|
+
{
|
|
27
|
+
"default": "你是一个能分析图像的AI助手。请仔细观察图像,并根据用户的问题提供详细、准确的描述。",
|
|
28
|
+
"multiline": True,
|
|
29
|
+
},
|
|
30
|
+
),
|
|
31
|
+
"user_prompt": (
|
|
32
|
+
"STRING",
|
|
33
|
+
{
|
|
34
|
+
"default": "请描述这张图片的内容,并指出任何有趣或不寻常的细节。",
|
|
35
|
+
"multiline": True,
|
|
36
|
+
},
|
|
37
|
+
),
|
|
38
|
+
"images": ("IMAGE",),
|
|
39
|
+
"max_tokens": ("INT", {"default": 32768, "min": 1, "max": 65536}),
|
|
40
|
+
"temperature": (
|
|
41
|
+
"FLOAT",
|
|
42
|
+
{"default": 1.0, "min": 0.0, "max": 2.0, "step": 0.01},
|
|
43
|
+
),
|
|
44
|
+
"detail": (
|
|
45
|
+
["low", "medium", "high"],
|
|
46
|
+
{"default": "high"},
|
|
47
|
+
),
|
|
48
|
+
"enable_thinking": (
|
|
49
|
+
"BOOLEAN",
|
|
50
|
+
{"default": False, "tooltip": "如果模型支持思考模式,是否开启"},
|
|
51
|
+
),
|
|
52
|
+
"inputcount": (
|
|
53
|
+
"INT",
|
|
54
|
+
{
|
|
55
|
+
"default": 1,
|
|
56
|
+
"min": 1,
|
|
57
|
+
"max": 900,
|
|
58
|
+
"tooltip": "动态控制输入的参考图数量,点击Update inputs按钮刷新",
|
|
59
|
+
},
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
def handle_inputs(self, headers, prompt_id, **kwargs):
|
|
65
|
+
temperature = kwargs.get("temperature", [1.0])[0]
|
|
66
|
+
max_tokens = kwargs.get("max_tokens", [32768])[0]
|
|
67
|
+
detail = kwargs.get("detail", ["high"])[0]
|
|
68
|
+
images = kwargs.get("images", [])
|
|
69
|
+
user_prompt = kwargs.get("user_prompt", [""])[0]
|
|
70
|
+
system_prompt = kwargs.get("system_prompt", [""])[0]
|
|
71
|
+
enable_thinking = kwargs.get("enable_thinking", [False])[0]
|
|
72
|
+
model = kwargs.get("model", ["gemini-3-flash-preview"])[0]
|
|
73
|
+
|
|
74
|
+
# 多图的情况可以认为图片输入都是List[Image Batch]
|
|
75
|
+
total_input_images = 0
|
|
76
|
+
for _, img_batch in enumerate(images if images is not None else []):
|
|
77
|
+
if img_batch is not None:
|
|
78
|
+
total_input_images += img_batch.shape[0]
|
|
79
|
+
extra_images, total_extra_images = self.get_extra_images(**kwargs)
|
|
80
|
+
total_input_images += total_extra_images
|
|
81
|
+
if total_input_images == 0:
|
|
82
|
+
raise ValueError("At least one image is required")
|
|
83
|
+
if total_input_images > 200:
|
|
84
|
+
raise ValueError("Maximum number of images is 200")
|
|
85
|
+
parts = []
|
|
86
|
+
index = 1
|
|
87
|
+
for _, img_batch in enumerate(images if images is not None else []):
|
|
88
|
+
for _, img in enumerate(img_batch if img_batch is not None else []):
|
|
89
|
+
if img is not None:
|
|
90
|
+
url = self.upload_file(
|
|
91
|
+
tensor_to_bytesio(image=img, total_pixels=4096 * 4096),
|
|
92
|
+
f"{prompt_id}_{index}.png",
|
|
93
|
+
headers,
|
|
94
|
+
)
|
|
95
|
+
parts.append(url)
|
|
96
|
+
index += 1
|
|
97
|
+
for _, img_batch in enumerate(extra_images):
|
|
98
|
+
for _, img in enumerate(img_batch if img_batch is not None else []):
|
|
99
|
+
if img is not None:
|
|
100
|
+
url = self.upload_file(
|
|
101
|
+
tensor_to_bytesio(image=img, total_pixels=4096 * 4096),
|
|
102
|
+
f"{prompt_id}_{index}.png",
|
|
103
|
+
headers,
|
|
104
|
+
)
|
|
105
|
+
parts.append(url)
|
|
106
|
+
index += 1
|
|
107
|
+
|
|
108
|
+
data = {
|
|
109
|
+
"urls": parts,
|
|
110
|
+
"user_prompt": user_prompt,
|
|
111
|
+
"system_prompt": system_prompt,
|
|
112
|
+
"temperature": temperature,
|
|
113
|
+
"max_tokens": max_tokens,
|
|
114
|
+
"detail": detail,
|
|
115
|
+
"enable_thinking": enable_thinking,
|
|
116
|
+
}
|
|
117
|
+
return data, model
|
|
118
|
+
|
|
119
|
+
def handle_outputs(self, outputs):
|
|
120
|
+
return (outputs[2][0], "")
|
bizyengine/core/common/client.py
CHANGED
|
@@ -257,6 +257,7 @@ async def async_send_request(
|
|
|
257
257
|
method, url, data=data, headers=headers, **kwargs
|
|
258
258
|
) as response:
|
|
259
259
|
response_data = await response.text()
|
|
260
|
+
logging.debug(f"Response Data: {response_data}")
|
|
260
261
|
if response.status != 200:
|
|
261
262
|
error_message = (
|
|
262
263
|
f"HTTP Status {response.status}, response body: {response_data}"
|
bizyengine/misc/utils.py
CHANGED
|
@@ -379,6 +379,7 @@ class SingleFlight(Generic[R]):
|
|
|
379
379
|
|
|
380
380
|
|
|
381
381
|
_MODELS_CACHE = TTLCache[str, list[str]](ttl_sec=600)
|
|
382
|
+
_TRD_MODELS_CACHE = TTLCache[str, dict](ttl_sec=600)
|
|
382
383
|
_SF = SingleFlight[None]()
|
|
383
384
|
|
|
384
385
|
|
|
@@ -421,3 +422,40 @@ def _cache_models(request_api_key: str):
|
|
|
421
422
|
]
|
|
422
423
|
_MODELS_CACHE.set("llm_models", llm_models)
|
|
423
424
|
_MODELS_CACHE.set("vlm_models", vlm_models)
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
def get_trd_models(type: str):
|
|
428
|
+
return _TRD_MODELS_CACHE.get(type)
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
def cache_trd_models(type, request_api_key: str):
|
|
432
|
+
# TODO: 效果待验证,目前节点只会被ComfyUI串行执行,所以不会出现竞争
|
|
433
|
+
# 重试最多五次
|
|
434
|
+
max_retries = 5
|
|
435
|
+
for i in range(max_retries):
|
|
436
|
+
try:
|
|
437
|
+
_, shared, e = _SF.do(
|
|
438
|
+
f"_cache_trd_models_{type}",
|
|
439
|
+
lambda: _cache_trd_models(type, request_api_key),
|
|
440
|
+
)
|
|
441
|
+
if e is not None:
|
|
442
|
+
raise e
|
|
443
|
+
return
|
|
444
|
+
except Exception:
|
|
445
|
+
logging.error(f"Failed to cache trd models on try #{i+1}")
|
|
446
|
+
if i < max_retries - 1:
|
|
447
|
+
time.sleep(5)
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
def _cache_trd_models(type, request_api_key: str):
|
|
451
|
+
# ① 开一条新线程专门跑协程 - 应该不需要在prompt那层上锁,因为并发只有1
|
|
452
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool:
|
|
453
|
+
api_client = APIClient()
|
|
454
|
+
models, err = pool.submit(
|
|
455
|
+
asyncio.run, api_client.get_trd_nodes_by_type(type, request_api_key)
|
|
456
|
+
).result()
|
|
457
|
+
if err is not None:
|
|
458
|
+
raise err
|
|
459
|
+
if len(models) == 0:
|
|
460
|
+
raise errno.NO_MODEL_FOUND
|
|
461
|
+
_TRD_MODELS_CACHE.set(type, models)
|
bizyengine/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.2.
|
|
1
|
+
1.2.82
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bizyengine
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.82
|
|
4
4
|
Summary: [a/BizyAir](https://github.com/siliconflow/BizyAir) Comfy Nodes that can run in any environment.
|
|
5
5
|
Author-email: SiliconFlow <yaochi@siliconflow.cn>
|
|
6
6
|
Project-URL: Repository, https://github.com/siliconflow/BizyAir
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
bizyengine/__init__.py,sha256=GP9V-JM07fz7uv_qTB43QEA2rKdrVJxi5I7LRnn_3ZQ,914
|
|
2
|
-
bizyengine/version.txt,sha256=
|
|
2
|
+
bizyengine/version.txt,sha256=w2FfV7RHNEYJIt90i-7AHCD4NcjvnrJqa6fXhmf82BY,6
|
|
3
3
|
bizyengine/bizy_server/__init__.py,sha256=SP9oSblnPo4KQyh7yOGD26YCskFAcQHAZy04nQBNRIw,200
|
|
4
|
-
bizyengine/bizy_server/api_client.py,sha256=
|
|
5
|
-
bizyengine/bizy_server/errno.py,sha256=
|
|
4
|
+
bizyengine/bizy_server/api_client.py,sha256=oe06P7l8t7lgkACbqN2UdS5R-IlZIINka6eWw8YyVv4,44451
|
|
5
|
+
bizyengine/bizy_server/errno.py,sha256=Qb-V0461LAYpsMMxgLggSZxlIPPaOhhV9k1TkMfqm_U,17494
|
|
6
6
|
bizyengine/bizy_server/error_handler.py,sha256=MGrfO1AEqbfEgMWPL8B6Ypew_zHiQAdYGlhN9bZohrY,167
|
|
7
7
|
bizyengine/bizy_server/execution.py,sha256=ayaEf6eGJKQsVZV-1_UlGlvwwmlH7FEek31Uq-MbUjA,1644
|
|
8
8
|
bizyengine/bizy_server/profile.py,sha256=f4juAzJ73gCm0AhagYpt9WnG8HEI6xze_U96-omBLqU,3044
|
|
9
9
|
bizyengine/bizy_server/resp.py,sha256=iOFT5Ud7VJBP2uqkojJIgc3y2ifMjjEXoj0ewneL9lc,710
|
|
10
|
-
bizyengine/bizy_server/server.py,sha256=
|
|
10
|
+
bizyengine/bizy_server/server.py,sha256=u_CdaxrWxvPebl_N_w5lB6w6dwmkInE35e21wjJ5gQE,59817
|
|
11
11
|
bizyengine/bizy_server/stream_response.py,sha256=H2XHqlVRtQMhgdztAuG7l8-iV_Pm42u2x6WJ0gNVIW0,9654
|
|
12
12
|
bizyengine/bizy_server/utils.py,sha256=t3y3ZTDzFa8K4wXlzgLVaFNCizgylsKsd9K3rLL4sGw,3986
|
|
13
13
|
bizyengine/bizyair_extras/__init__.py,sha256=9iPmEyR7F1IXbUaBNS90ivW9ul18GcuWFxRfFv2ieAw,1011
|
|
@@ -45,7 +45,7 @@ bizyengine/bizyair_extras/nodes_ipadapter_plus/__init__.py,sha256=ECKATm_EKi_4G4
|
|
|
45
45
|
bizyengine/bizyair_extras/nodes_ipadapter_plus/nodes_ipadapter_plus.py,sha256=lOKRem7oiPs8ZkA_p68HxagAgiCSvn3Rk-L4fSXIjyE,54846
|
|
46
46
|
bizyengine/bizyair_extras/nodes_kolors_mz/__init__.py,sha256=HsCCCphW8q0SrWEiFlZKK_W2lQr1T0UJIJL7gEn37ME,3729
|
|
47
47
|
bizyengine/bizyair_extras/oauth_callback/main.py,sha256=KQOZWor3kyNx8xvUNHYNMoHfCF9g_ht13_iPk4K_5YM,3633
|
|
48
|
-
bizyengine/bizyair_extras/third_party_api/__init__.py,sha256=
|
|
48
|
+
bizyengine/bizyair_extras/third_party_api/__init__.py,sha256=zSKsgBWaOXwKixZqDx8OSb-hhOFyYjtDVXe1vORinac,357
|
|
49
49
|
bizyengine/bizyair_extras/third_party_api/nodes_doubao.py,sha256=TrFDCRkyF6LRJ2QxRmlqiIX_ebeHI5KvKWpVfQxa3Qg,30256
|
|
50
50
|
bizyengine/bizyair_extras/third_party_api/nodes_flux.py,sha256=iv9V7-ijKGgR5_n8BlIe4E7QjWSGvWkIIUDMOn_3t1s,6339
|
|
51
51
|
bizyengine/bizyair_extras/third_party_api/nodes_gemini.py,sha256=tRjAGNJsJkYPXhlBREJd3jxPr4lF533Q_XMMHNIeXNM,17910
|
|
@@ -55,6 +55,7 @@ bizyengine/bizyair_extras/third_party_api/nodes_kling.py,sha256=ZxQB99O7E41lA25f
|
|
|
55
55
|
bizyengine/bizyair_extras/third_party_api/nodes_sora.py,sha256=_-O37uRi5QHqJZqlJ3QzoNHYxZH4zv79-0cBYuZHer4,7132
|
|
56
56
|
bizyengine/bizyair_extras/third_party_api/nodes_veo3.py,sha256=LzZl-9iLMe5IzEAXYUVkb8RUPLAfZloTPxRgGcY7Hsg,6703
|
|
57
57
|
bizyengine/bizyair_extras/third_party_api/nodes_vidu.py,sha256=-Eo2su0-t9qNPa5J4Qt3fx8xM9NjFHmgl19gMcTU7nM,10012
|
|
58
|
+
bizyengine/bizyair_extras/third_party_api/nodes_vlm.py,sha256=WF4QysWv3IJ1S-dxlwCzf5xazqOJxtlPyg4zDal70IA,4893
|
|
58
59
|
bizyengine/bizyair_extras/third_party_api/nodes_wan_api.py,sha256=GNc616NNsXcZYtojO2XTHwU3AFiprX6tFJ7qu3s2jgc,14508
|
|
59
60
|
bizyengine/bizyair_extras/third_party_api/trd_nodes_base.py,sha256=TeT6orrXv-G8sHzR9q8HqC4hPEgsbtUOJYJpX6-aM1g,9061
|
|
60
61
|
bizyengine/bizyair_extras/utils/aliyun_oss.py,sha256=H6wGZq1DqP7BHJ_frBJVvUVttgXprJprOnxytePIuos,3050
|
|
@@ -84,7 +85,7 @@ bizyengine/core/commands/servers/model_server.py,sha256=47DEQpj8HBSa-_TImW-5JCeu
|
|
|
84
85
|
bizyengine/core/commands/servers/prompt_server.py,sha256=5R4a5EU5z5lqGNoDlGRtUGGHRojFWAtm3rdslqxpebU,11366
|
|
85
86
|
bizyengine/core/common/__init__.py,sha256=GicZw6YeAZk1PsKmFDt9dm1F75zPUlpia9Q_ki5vW1Y,179
|
|
86
87
|
bizyengine/core/common/caching.py,sha256=hRNsSrfNxgc1zzvBzLVjMY0iMkKqA0TBCr-iYhEpzik,6946
|
|
87
|
-
bizyengine/core/common/client.py,sha256=
|
|
88
|
+
bizyengine/core/common/client.py,sha256=tEkIJALKr-LWnwrstS3j04fkfGfTxVq0FUO_gOeJGGw,10455
|
|
88
89
|
bizyengine/core/common/env_var.py,sha256=1EAW3gOXY2bKouCqrGa583vTJRdDasQ1IsFTnzDg7Dk,3450
|
|
89
90
|
bizyengine/core/common/utils.py,sha256=Jxk4tCURbUhjYBFuHTiQgeUo2w13TYj4upnPTKNNucM,4215
|
|
90
91
|
bizyengine/core/configs/conf.py,sha256=D_UWG9SSJnK5EhbrfNFryJQ8hUwwdvhOGlq1TielwpI,3830
|
|
@@ -103,8 +104,8 @@ bizyengine/misc/nodes_controlnet_union_sdxl.py,sha256=fYyu_XMY7mcX1Ad9x30q1tYB8m
|
|
|
103
104
|
bizyengine/misc/route_sam.py,sha256=-bMIR2QalfnszipGxSxvDAHGJa5gPSrjkYPb5baaRg4,1561
|
|
104
105
|
bizyengine/misc/segment_anything.py,sha256=wNKYwlYPMszfwj23524geFZJjZaG4eye65SGaUnh77I,8941
|
|
105
106
|
bizyengine/misc/supernode.py,sha256=STN9gaxfTSErH8OiHeZa47d8z-G9S0I7fXuJvHQOBFM,4532
|
|
106
|
-
bizyengine/misc/utils.py,sha256=
|
|
107
|
-
bizyengine-1.2.
|
|
108
|
-
bizyengine-1.2.
|
|
109
|
-
bizyengine-1.2.
|
|
110
|
-
bizyengine-1.2.
|
|
107
|
+
bizyengine/misc/utils.py,sha256=JJqlabu0-wU8WEglaQWRPIYDOPX7qnWTyTZeJAaORns,14654
|
|
108
|
+
bizyengine-1.2.82.dist-info/METADATA,sha256=5vQwTzdxix3GEyQ2YeNqUhneIjTKa8xcaPIZMDeUO3A,735
|
|
109
|
+
bizyengine-1.2.82.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
110
|
+
bizyengine-1.2.82.dist-info/top_level.txt,sha256=2zapzqxX-we5cRyJkGf9bd5JinRtXp3-_uDI-xCAnc0,11
|
|
111
|
+
bizyengine-1.2.82.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|