bizydraft 0.1.29__py3-none-any.whl → 0.2.0__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.

Potentially problematic release.


This version of bizydraft might be problematic. Click here for more details.

@@ -2,7 +2,7 @@ export class WebSocketClient {
2
2
  constructor(url, protocols) {
3
3
 
4
4
  const host = 'api.bizyair.cn';
5
-
5
+
6
6
  if (url.startsWith('ws://') || url.startsWith('wss://')) {
7
7
  this.url = url;
8
8
  } else {
@@ -1,3 +1,17 @@
1
+ const loadNodeList = [
2
+ 'LoadImage',
3
+ 'LoadImageMask',
4
+ 'LoadAudio',
5
+ 'LoadVideo',
6
+ 'Load3D',
7
+ ]
8
+ const extMap = {
9
+ 'LoadImage': '.png,.jpg,.jpeg,.webp,.gif,.svg,.ico,.bmp,.tiff,.tif,.heic,.heif',
10
+ 'LoadImageMask': '.png,.jpg,.jpeg,.webp,.gif,.svg,.ico,.bmp,.tiff,.tif,.heic,.heif',
11
+ 'LoadAudio': '.mp3,.wav,.ogg,.m4a,.aac,.flac,.wma,.m4r',
12
+ 'LoadVideo': '.mp4,.mov,.avi,.mkv,.webm,.flv,.wmv,.m4v',
13
+ 'Load3D': '.glb,.gltf,.fbx,.obj,.dae,.ply,.stl',
14
+ }
1
15
  export function getCookie(name) {
2
16
  const value = `; ${document.cookie}`;
3
17
  const parts = value.split(`; ${name}=`);
@@ -21,4 +35,50 @@ export const hideWidget = (node, widget_name) => {
21
35
  widget.type = originalType;
22
36
  widget.height = undefined;
23
37
  };
24
- }
38
+ }
39
+ export const computeIsLoadNode = (nodeName) => {
40
+
41
+ return loadNodeList.includes(nodeName)
42
+ }
43
+ export const computeExt = (nodeName) => {
44
+
45
+ return extMap[nodeName] || ''
46
+ }
47
+ /**
48
+ * 判断节点名是否为模型加载类(不包含 bizyair)
49
+ * @param {string} nodeName
50
+ * @returns {boolean}
51
+ */
52
+ function isModelLoaderType(nodeName) {
53
+ const regex = /^(\w+).*Loader.*/i;
54
+ return regex.test(nodeName);
55
+ }
56
+
57
+ /**
58
+ * 处理 graphData.output
59
+ * @param {Object} output - graphData.output 对象
60
+ * @returns {Object} 处理后的新对象
61
+ */
62
+ export function processGraphOutput(output) {
63
+ const newOutput = JSON.parse(JSON.stringify(output));
64
+ for (const key in newOutput) {
65
+ const node = newOutput[key];
66
+ // 1. 如果 class_type 在 loadNodeList 里,删除 inputs.image_name
67
+ if (loadNodeList.includes(node.class_type) && node.inputs && node.inputs.image_name !== undefined) {
68
+ delete node.inputs.image_name;
69
+ }
70
+ if (isModelLoaderType(node.class_type)) {
71
+ delete newOutput[key];
72
+ }
73
+ // 2. 如果 class_type 满足 Loader 正则且不包含 bizyair,删除 inputs.model_version_id
74
+ if (isModelLoaderType(node.class_type) && node.inputs) {
75
+ if (node.inputs.model_version_id !== undefined) {
76
+ delete node.inputs.model_version_id;
77
+ }
78
+ if (node.inputs.ckpt_name !== undefined) {
79
+ delete node.inputs.ckpt_name;
80
+ }
81
+ }
82
+ }
83
+ return newOutput;
84
+ }
@@ -10,7 +10,7 @@ export async function fileToOss(file) {
10
10
  if (!authToken) {
11
11
  throw new Error('未找到认证Token,请先登录');
12
12
  }
13
-
13
+
14
14
  // 获取上传凭证
15
15
  const uploadToken = await fetch(`${apiHost}/special/community/upload_token?file_name=${encodeURIComponent(file.name)}&file_type=inputs`, {
16
16
  method: 'GET',
@@ -19,17 +19,17 @@ export async function fileToOss(file) {
19
19
  'Authorization': `Bearer ${authToken}`
20
20
  }
21
21
  });
22
-
22
+
23
23
  // 检查响应状态
24
24
  if (!uploadToken.ok) {
25
25
  const errorText = await uploadToken.text();
26
26
  console.error('获取上传凭证失败:', uploadToken.status, errorText);
27
27
  throw new Error(`获取上传凭证失败: ${uploadToken.status} ${uploadToken.statusText}`);
28
28
  }
29
-
29
+
30
30
  const {data} = await uploadToken.json();
31
31
  // console.log('上传凭证响应:', data);
32
-
32
+
33
33
  // 使用STS凭证上传
34
34
  const ossConfig = {
35
35
  accessKeyId: data.data.file.access_key_id,
@@ -39,16 +39,16 @@ export async function fileToOss(file) {
39
39
  region: data.data.storage.region,
40
40
  objectKey: data.data.file.object_key
41
41
  };
42
-
42
+
43
43
  // console.log('OSS配置:', ossConfig);
44
-
44
+
45
45
  // 改用官方推荐的表单上传方式
46
46
  const formData = new FormData();
47
-
47
+
48
48
  // 构建Policy
49
49
  const expiration = new Date();
50
50
  expiration.setHours(expiration.getHours() + 1); // Policy过期时间1小时
51
-
51
+
52
52
  const policyObj = {
53
53
  expiration: expiration.toISOString(),
54
54
  conditions: [
@@ -58,47 +58,47 @@ export async function fileToOss(file) {
58
58
  ['starts-with', '$key', ossConfig.objectKey.split('/')[0]]
59
59
  ]
60
60
  };
61
-
61
+
62
62
  // Policy Base64编码
63
63
  const policy = btoa(JSON.stringify(policyObj));
64
64
  // console.log('Policy:', policy);
65
-
65
+
66
66
  // 构建表单字段
67
67
  formData.append('key', ossConfig.objectKey);
68
68
  formData.append('OSSAccessKeyId', ossConfig.accessKeyId);
69
69
  formData.append('policy', policy);
70
70
  formData.append('success_action_status', '200');
71
-
71
+
72
72
  // 如果有临时token,需要添加
73
73
  if (ossConfig.securityToken) {
74
74
  formData.append('x-oss-security-token', ossConfig.securityToken);
75
75
  }
76
-
76
+
77
77
  // 计算签名 - 阿里云官方要求使用HMAC-SHA1
78
78
  const signature = await hmacSha1(policy, ossConfig.accessKeySecret);
79
79
  // console.log('计算的签名:', signature);
80
80
  formData.append('signature', signature);
81
-
81
+
82
82
  // 最后添加文件内容
83
83
  formData.append('file', file);
84
-
84
+
85
85
  // OSS服务端点
86
86
  const host = `https://${ossConfig.bucket}.${ossConfig.region}.aliyuncs.com`;
87
87
  // console.log('上传地址:', host);
88
-
88
+
89
89
  // 开始上传
90
90
  const uploadResponse = await fetch(host, {
91
91
  method: 'POST',
92
92
  body: formData
93
93
  });
94
-
94
+
95
95
  // 检查响应
96
96
  if (!uploadResponse.ok) {
97
97
  const errorText = await uploadResponse.text();
98
98
  console.error('上传失败:', uploadResponse.status, errorText);
99
99
  throw new Error(`上传失败: ${uploadResponse.status} ${uploadResponse.statusText}`);
100
100
  }
101
-
101
+
102
102
  // 构建公开访问URL
103
103
  const fileUrl = `${host}/${ossConfig.objectKey}`;
104
104
 
@@ -121,7 +121,7 @@ export async function fileToOss(file) {
121
121
  };
122
122
  } catch (error) {
123
123
  console.error('文件上传到OSS失败:', error);
124
-
124
+
125
125
  throw error;
126
126
  }
127
127
  }
@@ -132,7 +132,7 @@ async function hmacSha1(message, key) {
132
132
  const encoder = new TextEncoder();
133
133
  const keyData = encoder.encode(key);
134
134
  const messageData = encoder.encode(message);
135
-
135
+
136
136
  // 导入密钥
137
137
  const cryptoKey = await window.crypto.subtle.importKey(
138
138
  'raw',
@@ -141,14 +141,14 @@ async function hmacSha1(message, key) {
141
141
  false,
142
142
  ['sign']
143
143
  );
144
-
144
+
145
145
  // 计算签名
146
146
  const signature = await window.crypto.subtle.sign(
147
147
  'HMAC',
148
148
  cryptoKey,
149
149
  messageData
150
150
  );
151
-
151
+
152
152
  // 转换为Base64编码
153
153
  const base64Signature = arrayBufferToBase64(signature);
154
154
  return base64Signature;
@@ -162,4 +162,4 @@ function arrayBufferToBase64(buffer) {
162
162
  binary += String.fromCharCode(bytes[i]);
163
163
  }
164
164
  return btoa(binary);
165
- }
165
+ }
bizydraft/workflow_io.py CHANGED
@@ -45,7 +45,9 @@ def get_leaf_nodes_from_prompt(prompt: Dict[str, Any]) -> Set[str]:
45
45
 
46
46
 
47
47
  def summarize_params(
48
- input_params: List[Dict[str, Any]], exclude_node_ids: Set[str]
48
+ input_params: List[Dict[str, Any]],
49
+ exclude_node_ids: Set[str],
50
+ wf_nodes: List[Dict[str, Any]],
49
51
  ) -> List[Dict[str, Any]]:
50
52
  """
51
53
  按节点类型和参数名整理参数信息,便于输出。
@@ -56,6 +58,10 @@ def summarize_params(
56
58
  node_id = param["node_id"]
57
59
  if node_id in exclude_node_ids:
58
60
  continue
61
+ wf_node = get_node_id_from_wf_nodes(wf_nodes, node_id)
62
+ title = param["class_type"]
63
+ if wf_node and wf_node.get("title", None):
64
+ title = wf_node.get("title")
59
65
  key = (param["class_type"], node_id)
60
66
  if key not in summary:
61
67
  summary[key] = {
@@ -63,6 +69,7 @@ def summarize_params(
63
69
  "displayName": param["class_type"],
64
70
  "nodeId": node_id,
65
71
  "params": [],
72
+ "title": title,
66
73
  }
67
74
  summary[key]["params"].append(
68
75
  {
@@ -75,8 +82,22 @@ def summarize_params(
75
82
  return list(summary.values())
76
83
 
77
84
 
85
+ def get_node_id_from_wf_nodes(
86
+ wf_nodes: List[Dict[str, Any]], node_id: str
87
+ ) -> Dict[str, Any]:
88
+ for wf_node in wf_nodes:
89
+ if str(wf_node.get("id", 0)) == node_id:
90
+ return wf_node
91
+ return None
92
+
93
+
78
94
  def parse_workflow_io(request_data) -> Dict[str, Any]:
79
95
  prompt = request_data.get("prompt", {})
96
+ extra_data = request_data.get("extra_data", {})
97
+
98
+ extra_pnginfo = extra_data.get("extra_pnginfo", {})
99
+ workflow = extra_pnginfo.get("workflow", {})
100
+ wf_nodes = workflow.get("nodes", [])
80
101
 
81
102
  # 1. 输出参数(推断叶子节点)
82
103
  leaf_nodes = get_leaf_nodes_from_prompt(prompt)
@@ -84,18 +105,25 @@ def parse_workflow_io(request_data) -> Dict[str, Any]:
84
105
  for node_id in leaf_nodes:
85
106
  node = prompt[node_id]
86
107
  class_type = node.get("class_type")
108
+ wf_node = get_node_id_from_wf_nodes(wf_nodes, node_id)
109
+ title = class_type
110
+ if wf_node and wf_node.get("title", None):
111
+ title = wf_node.get("title")
87
112
  output_nodes.append(
88
113
  {
89
114
  "nodeId": node_id,
90
115
  "name": class_type,
91
116
  "displayName": class_type,
117
+ "title": title,
92
118
  "params": [],
93
119
  }
94
120
  )
95
121
 
96
122
  # 2. 输入参数(排除已作为输出的节点)
97
123
  input_params = get_input_params(prompt)
98
- input_summary = summarize_params(input_params, exclude_node_ids=leaf_nodes)
124
+ input_summary = summarize_params(
125
+ input_params, exclude_node_ids=leaf_nodes, wf_nodes=wf_nodes
126
+ )
99
127
 
100
128
  # 3. 构造response_body.json格式
101
129
  return {"data": {"inputs": input_summary, "outputs": output_nodes}}
@@ -1,4 +1,4 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bizydraft
3
- Version: 0.1.29
3
+ Version: 0.2.0
4
4
  Summary: bizydraft
@@ -0,0 +1,28 @@
1
+ bizydraft/__init__.py,sha256=OM-sKCQrPh25nHVJIX-DgF1raMYyoWLSuyduIAHt0Gs,78
2
+ bizydraft/block_nodes.py,sha256=Lqn3oSCaGDHR2OICc8a2iRoRCVVK9v1-9MM3r-qIZgA,1092
3
+ bizydraft/env.py,sha256=nVh4xBKXWnRUPbHL3PqZr6VFN8txKsrsmshu8PFGaqo,299
4
+ bizydraft/hijack_nodes.py,sha256=4msT6YJqC_bQXKPmm76wiSJIhkZXETsGm1jz4qHHcZ4,2567
5
+ bizydraft/hijack_routes.py,sha256=lf6x3xDzbo9yQIRwfG_1oxcUNfrX_1ogbiff3WOV9gM,3268
6
+ bizydraft/oss_utils.py,sha256=W3-Td6K4vrB83oMowN82c3nmQ3IrEoR1UX6S8AvO6ig,7896
7
+ bizydraft/patch_handlers.py,sha256=bLkuk6pLoM_6o6fxLPfSGpUzSJoNsEO0ibKHomUdeiI,5682
8
+ bizydraft/postload.py,sha256=XFElKcmCajT_oO7SVJJBaN04XcWro54N5HB5cSCxfvI,1308
9
+ bizydraft/prestartup_patch.py,sha256=Rh_D-rEUmPaojSrl8CEBMAhSgwtLSm6gH2Mzmk5NCuQ,316
10
+ bizydraft/resp.py,sha256=8INvKOe5Dgai3peKfqKjrhUoYeuXWXn358w30-_cY-A,369
11
+ bizydraft/server.py,sha256=L2zoJgOisr65IRphOyko74AdsLel59gh55peyMaUrO8,2102
12
+ bizydraft/workflow_io.py,sha256=MYhJbpgkv8hrA5k_aolijOTrWpTtu62nzRznA4hv8JE,4298
13
+ bizydraft/static/js/aiAppHandler.js,sha256=t3tefGg9d_2-VeNxqrwMMdX6JYE5uroyXZq0hXNWSzw,17572
14
+ bizydraft/static/js/freezeModeHandler.js,sha256=Vnn7p2LsALbrAcZr8PLVZpFrB1pLt05MHvB0irl1Hnk,15479
15
+ bizydraft/static/js/handleStyle.js,sha256=VVurhbfcIW0bDnZ4w2MUK7tlo93CgMGs_3hgFeIuRsM,1846
16
+ bizydraft/static/js/hookLoadImage.js,sha256=jQGckFr7bTLRiwcFsVmSy1mj_o7TKj1uup0QQ00qwbk,8079
17
+ bizydraft/static/js/hookLoadModel.js,sha256=9eHklcb66EdH7kbm76178bK968Yd-H9xO6DdQhSH0_I,5630
18
+ bizydraft/static/js/main.js,sha256=oEsVEUZSo8ipx93oqs2WFQSRgp46XQ_D-Xao-wen2S8,121
19
+ bizydraft/static/js/nodeFocusHandler.js,sha256=24xXbS4Q-GjJdRqf11i-1pBo8MkOJ24F7MHFV44EG6Q,4683
20
+ bizydraft/static/js/nodeParamsFilter.js,sha256=H7lBB0G8HNqoGhOCH1hNXqPU-rPlrFyTxg_f_JgLEMk,4168
21
+ bizydraft/static/js/postEvent.js,sha256=VUxmyOtw2PMQBy4V7FZ1ShRj79RPTL-_ehLTt2NzsNI,37669
22
+ bizydraft/static/js/socket.js,sha256=VE3fTAgEfM0FZhL526Skt7OCRokOa3mzTCAjAomI_tE,2432
23
+ bizydraft/static/js/tool.js,sha256=UjYZgQ7711Ag5l_La4wZvp1jD8wT-Z6At5dMG3SJZxE,2745
24
+ bizydraft/static/js/uploadFile.js,sha256=WvglKzHMeOzDhOH3P-fLcPHxCLbKOJpo4DntoRxeJtI,4908
25
+ bizydraft-0.2.0.dist-info/METADATA,sha256=B-NGkfmJyxvgSQy9mzpBDMuKP8mUacXx3Emy5jQgHZo,72
26
+ bizydraft-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ bizydraft-0.2.0.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
28
+ bizydraft-0.2.0.dist-info/RECORD,,
@@ -1,19 +0,0 @@
1
- bizydraft/__init__.py,sha256=OM-sKCQrPh25nHVJIX-DgF1raMYyoWLSuyduIAHt0Gs,78
2
- bizydraft/hijack_nodes.py,sha256=xPVLBBnRiJaI8ZbR80O8W4C9SlNAp7MxP7dKj_pRlYs,869
3
- bizydraft/hijack_routes.py,sha256=MlietlmTU-Lj7evZo5yZE-ghQJZ9_1vdpyHXAXYfoFw,7417
4
- bizydraft/postload.py,sha256=YfiFjJ7MLN6WNar19lLdAL_3IPr5GyI3G4rbZIiAgXU,562
5
- bizydraft/prestartup_patch.py,sha256=Rh_D-rEUmPaojSrl8CEBMAhSgwtLSm6gH2Mzmk5NCuQ,316
6
- bizydraft/resp.py,sha256=8INvKOe5Dgai3peKfqKjrhUoYeuXWXn358w30-_cY-A,369
7
- bizydraft/server.py,sha256=Dp0w8AxDc83EkLE0XbFwBKZ4VIdKBs1obJR_WXuiqpA,2101
8
- bizydraft/workflow_io.py,sha256=lqLWhqNs5uJZ0IlTGyoEfBk6WjsWm0Btl6bQY-nldLo,3364
9
- bizydraft/static/js/handleStyle.js,sha256=P2DNMiKHr--ekn3CGNOAHU46OJCCsifejxw97kLmb7Q,1676
10
- bizydraft/static/js/hookLoadImage.js,sha256=GklOwfIkXhSfCFrHBz4pPqaSnBiKjegbpDknrzvXYOc,5767
11
- bizydraft/static/js/main.js,sha256=cZ-7wR9T8aNLzIrTjc-g9xVZf7z6TXWl1zhP_wXSSVo,150
12
- bizydraft/static/js/postEvent.js,sha256=lXo35DUiBmzGFMtOL2ULcjbCscNb5eAZ98_eX7en3hM,27926
13
- bizydraft/static/js/socket.js,sha256=vewGQLgdJSrjvqptEDxLirZRXZUjWTJDmDdjs4mbf4k,2436
14
- bizydraft/static/js/tool.js,sha256=Ejyb5GiFhuoCp5_dBvu2suagbxGHCkR2Lg_4rMKN2ls,756
15
- bizydraft/static/js/uploadFile.js,sha256=5OjLLaCHZkobLltNs27K5GgZBFHZJowBwS-oakLoNW4,4985
16
- bizydraft-0.1.29.dist-info/METADATA,sha256=wssPMXv_0LYQ6SG-3dVs0TMgd11QSG2oh6jUYoBtaXc,73
17
- bizydraft-0.1.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
- bizydraft-0.1.29.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
19
- bizydraft-0.1.29.dist-info/RECORD,,