comfy-webui-core 0.1.0__tar.gz
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.
- comfy_webui_core-0.1.0/LICENSE +201 -0
- comfy_webui_core-0.1.0/NOTICE +5 -0
- comfy_webui_core-0.1.0/PKG-INFO +84 -0
- comfy_webui_core-0.1.0/README.md +54 -0
- comfy_webui_core-0.1.0/pyproject.toml +46 -0
- comfy_webui_core-0.1.0/setup.cfg +4 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/__init__.py +73 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/backend_manager.py +70 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/chain_injectors/__init__.py +0 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/chain_injectors/easycache_injector.py +40 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/chain_injectors/lora_injector.py +67 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/chain_injectors/lora_model_only_injector.py +59 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/chain_injectors/reference_latent_injector.py +157 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/comfy_api.py +482 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/config.py +89 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/context.py +33 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/download_utils.py +147 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/input_processors.py +53 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/job_manager.py +129 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/model_downloader.py +170 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/node_info_manager.py +114 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/shared_ui.py +327 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/ui_builder.py +277 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/ui_loader.py +83 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/utils.py +199 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/workflow_assembler.py +235 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core/yaml_loader.py +80 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core.egg-info/PKG-INFO +84 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core.egg-info/SOURCES.txt +30 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core.egg-info/dependency_links.txt +1 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core.egg-info/requires.txt +8 -0
- comfy_webui_core-0.1.0/src/comfy_webui_core.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or exemplary damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 RioShiina47
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: comfy-webui-core
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Core framework for dynamic ComfyUI workflow generation, Gradio WebUI, and MCP tools
|
|
5
|
+
Author: RioShiina47
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/RioShiina47/comfy-webui-core
|
|
8
|
+
Project-URL: Repository, https://github.com/RioShiina47/comfy-webui-core
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/RioShiina47/comfy-webui-core/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
License-File: NOTICE
|
|
21
|
+
Requires-Dist: gradio[mcp]
|
|
22
|
+
Requires-Dist: requests
|
|
23
|
+
Requires-Dist: websocket-client
|
|
24
|
+
Requires-Dist: imageio
|
|
25
|
+
Requires-Dist: pyyaml
|
|
26
|
+
Requires-Dist: huggingface_hub
|
|
27
|
+
Requires-Dist: tqdm
|
|
28
|
+
Requires-Dist: pillow
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# Comfy web UI Core
|
|
32
|
+
|
|
33
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
34
|
+
|
|
35
|
+
This project is the core framework of the [comfy-webui](https://github.com/RioShiina47/comfy-webui) project.
|
|
36
|
+
|
|
37
|
+
We have removed all specific application-layer feature modules, retaining only the most essential components: the dynamic workflow engine, UI/API/MCP generator, and backend management system.
|
|
38
|
+
|
|
39
|
+
Its goal is to provide developers with a clean, lightweight starting point for rapidly building custom, complex-workflow-oriented Gradio WebUI applications on top of the powerful ComfyUI platform. It is an ideal choice for rapid prototyping.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Core Features
|
|
44
|
+
|
|
45
|
+
While it doesn't include any specific generation features, `comfy-webui-core` provides a powerful set of underlying mechanisms:
|
|
46
|
+
|
|
47
|
+
- **Recipe-Driven Dynamic Workflows**
|
|
48
|
+
Define ComfyUI node blueprints using simple and intuitive YAML `recipe` files. The system dynamically and programmatically assembles these into a final, executable, and complex workflow JSON based on user input from the frontend.
|
|
49
|
+
|
|
50
|
+
- **Pluggable Chain Injectors**
|
|
51
|
+
The core framework includes chain injectors for common dynamic functionalities like LoRA, ControlNet, IP-Adapter, and Regional Conditioning. You can easily add these dynamic, stackable capabilities to your new workflows without manually handling complex node connection logic.
|
|
52
|
+
|
|
53
|
+
- **API & MCP Ready (Workflow as a Service)**
|
|
54
|
+
The framework is not just for building graphical interfaces; its architecture natively supports Gradio's API and MCP mechanisms. Developers can create an `_mcp.py` file within a module to encapsulate complex, recipe-driven workflows into simple, high-level API and MCP functions that can be called externally, allowing for easy integration with LLMs and AI Agents.
|
|
55
|
+
|
|
56
|
+
- **Multi-Backend Management**
|
|
57
|
+
It features a built-in intelligent system for managing connections to multiple backends. You can configure and connect to several different ComfyUI instances (e.g., on different devices or with different dependency environments) and allow various UI modules to schedule tasks to their designated backends.
|
|
58
|
+
|
|
59
|
+
- **Asynchronous Job Engine**
|
|
60
|
+
All generation tasks are executed asynchronously in the background. Tasks continue to run on the server even if the browser is closed or the network connection is lost.
|
|
61
|
+
|
|
62
|
+
- **Layered Configuration System**
|
|
63
|
+
Through a directory structure of `yaml/` (base configuration) and `custom/yaml/` (user-defined overrides), you can easily separate and merge global and personal settings. This makes project upgrades and customizations simple and conflict-free.
|
|
64
|
+
|
|
65
|
+
- **Modular UI Builder**
|
|
66
|
+
The core UI builder can automatically discover the modules you create (`_ui.py`) and generate the corresponding Gradio tabs and interface layouts based on the layout configuration file (`ui_layout.yaml`).
|
|
67
|
+
|
|
68
|
+
## Target Audience
|
|
69
|
+
|
|
70
|
+
- Developers who want to build highly customized web interfaces for ComfyUI.
|
|
71
|
+
- Researchers or tech enthusiasts who need to quickly validate specific complex workflows and provide them with a simple UI.
|
|
72
|
+
- Developers looking to encapsulate complex ComfyUI workflows into standard MCP tools for easy integration with LLMs and AI Agents.
|
|
73
|
+
- Teams seeking a standardized foundational framework for developing in-house AI generation tools.
|
|
74
|
+
|
|
75
|
+
## Learn About the Full Version
|
|
76
|
+
|
|
77
|
+
To see a full-featured implementation, more comprehensive module examples, and advanced usage, please refer to the main project: [comfy-webui](https://github.com/RioShiina47/comfy-webui).
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 📄 License
|
|
82
|
+
|
|
83
|
+
- **Framework Code**: This project's code is licensed under the [Apache License, Version 2.0](https://opensource.org/licenses/Apache-2.0). See the [LICENSE](LICENSE) and [NOTICE](NOTICE) files for details.
|
|
84
|
+
- **Notice on Usage**: When modifying or redistributing this core framework, please comply with Section 4 of the Apache 2.0 License by retaining copyright notices and prominently stating any file changes.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Comfy web UI Core
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
|
+
|
|
5
|
+
This project is the core framework of the [comfy-webui](https://github.com/RioShiina47/comfy-webui) project.
|
|
6
|
+
|
|
7
|
+
We have removed all specific application-layer feature modules, retaining only the most essential components: the dynamic workflow engine, UI/API/MCP generator, and backend management system.
|
|
8
|
+
|
|
9
|
+
Its goal is to provide developers with a clean, lightweight starting point for rapidly building custom, complex-workflow-oriented Gradio WebUI applications on top of the powerful ComfyUI platform. It is an ideal choice for rapid prototyping.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Core Features
|
|
14
|
+
|
|
15
|
+
While it doesn't include any specific generation features, `comfy-webui-core` provides a powerful set of underlying mechanisms:
|
|
16
|
+
|
|
17
|
+
- **Recipe-Driven Dynamic Workflows**
|
|
18
|
+
Define ComfyUI node blueprints using simple and intuitive YAML `recipe` files. The system dynamically and programmatically assembles these into a final, executable, and complex workflow JSON based on user input from the frontend.
|
|
19
|
+
|
|
20
|
+
- **Pluggable Chain Injectors**
|
|
21
|
+
The core framework includes chain injectors for common dynamic functionalities like LoRA, ControlNet, IP-Adapter, and Regional Conditioning. You can easily add these dynamic, stackable capabilities to your new workflows without manually handling complex node connection logic.
|
|
22
|
+
|
|
23
|
+
- **API & MCP Ready (Workflow as a Service)**
|
|
24
|
+
The framework is not just for building graphical interfaces; its architecture natively supports Gradio's API and MCP mechanisms. Developers can create an `_mcp.py` file within a module to encapsulate complex, recipe-driven workflows into simple, high-level API and MCP functions that can be called externally, allowing for easy integration with LLMs and AI Agents.
|
|
25
|
+
|
|
26
|
+
- **Multi-Backend Management**
|
|
27
|
+
It features a built-in intelligent system for managing connections to multiple backends. You can configure and connect to several different ComfyUI instances (e.g., on different devices or with different dependency environments) and allow various UI modules to schedule tasks to their designated backends.
|
|
28
|
+
|
|
29
|
+
- **Asynchronous Job Engine**
|
|
30
|
+
All generation tasks are executed asynchronously in the background. Tasks continue to run on the server even if the browser is closed or the network connection is lost.
|
|
31
|
+
|
|
32
|
+
- **Layered Configuration System**
|
|
33
|
+
Through a directory structure of `yaml/` (base configuration) and `custom/yaml/` (user-defined overrides), you can easily separate and merge global and personal settings. This makes project upgrades and customizations simple and conflict-free.
|
|
34
|
+
|
|
35
|
+
- **Modular UI Builder**
|
|
36
|
+
The core UI builder can automatically discover the modules you create (`_ui.py`) and generate the corresponding Gradio tabs and interface layouts based on the layout configuration file (`ui_layout.yaml`).
|
|
37
|
+
|
|
38
|
+
## Target Audience
|
|
39
|
+
|
|
40
|
+
- Developers who want to build highly customized web interfaces for ComfyUI.
|
|
41
|
+
- Researchers or tech enthusiasts who need to quickly validate specific complex workflows and provide them with a simple UI.
|
|
42
|
+
- Developers looking to encapsulate complex ComfyUI workflows into standard MCP tools for easy integration with LLMs and AI Agents.
|
|
43
|
+
- Teams seeking a standardized foundational framework for developing in-house AI generation tools.
|
|
44
|
+
|
|
45
|
+
## Learn About the Full Version
|
|
46
|
+
|
|
47
|
+
To see a full-featured implementation, more comprehensive module examples, and advanced usage, please refer to the main project: [comfy-webui](https://github.com/RioShiina47/comfy-webui).
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📄 License
|
|
52
|
+
|
|
53
|
+
- **Framework Code**: This project's code is licensed under the [Apache License, Version 2.0](https://opensource.org/licenses/Apache-2.0). See the [LICENSE](LICENSE) and [NOTICE](NOTICE) files for details.
|
|
54
|
+
- **Notice on Usage**: When modifying or redistributing this core framework, please comply with Section 4 of the Apache 2.0 License by retaining copyright notices and prominently stating any file changes.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "comfy-webui-core"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Core framework for dynamic ComfyUI workflow generation, Gradio WebUI, and MCP tools"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "Apache-2.0" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "RioShiina47" }
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"License :: OSI Approved :: Apache Software License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"gradio[mcp]",
|
|
26
|
+
"requests",
|
|
27
|
+
"websocket-client",
|
|
28
|
+
"imageio",
|
|
29
|
+
"pyyaml",
|
|
30
|
+
"huggingface_hub",
|
|
31
|
+
"tqdm",
|
|
32
|
+
"pillow",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/RioShiina47/comfy-webui-core"
|
|
37
|
+
Repository = "https://github.com/RioShiina47/comfy-webui-core"
|
|
38
|
+
"Bug Tracker" = "https://github.com/RioShiina47/comfy-webui-core/issues"
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.packages.find]
|
|
41
|
+
where = ["src"]
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.package-data]
|
|
44
|
+
comfy_webui_core = [
|
|
45
|
+
"chain_injectors/*.py",
|
|
46
|
+
]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Comfy Web UI Core Framework.
|
|
3
|
+
|
|
4
|
+
Provides dynamic ComfyUI workflow engine, Gradio WebUI dynamic assembly,
|
|
5
|
+
MCP server endpoints, multi-backend routing, and chain injector topology.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .context import set_app_root, get_app_root
|
|
9
|
+
from .workflow_assembler import WorkflowAssembler
|
|
10
|
+
from .ui_builder import build_gradio_ui
|
|
11
|
+
from .ui_loader import discover_ui_modules, load_ui_layout
|
|
12
|
+
from .backend_manager import backend_manager
|
|
13
|
+
from .node_info_manager import (
|
|
14
|
+
fetch_and_cache_object_info,
|
|
15
|
+
get_node_info,
|
|
16
|
+
get_all_node_info,
|
|
17
|
+
)
|
|
18
|
+
from .job_manager import (
|
|
19
|
+
create_job,
|
|
20
|
+
get_job,
|
|
21
|
+
update_job,
|
|
22
|
+
get_latest_running_job_for_module,
|
|
23
|
+
)
|
|
24
|
+
from .yaml_loader import load_and_merge_yaml, load_and_merge_yaml_from_module
|
|
25
|
+
|
|
26
|
+
from . import config
|
|
27
|
+
from . import workflow_assembler
|
|
28
|
+
from . import ui_builder
|
|
29
|
+
from . import ui_loader
|
|
30
|
+
from . import backend_manager as backend_manager_mod
|
|
31
|
+
from . import node_info_manager as node_info_manager_mod
|
|
32
|
+
from . import job_manager as job_manager_mod
|
|
33
|
+
from . import comfy_api
|
|
34
|
+
from . import shared_ui
|
|
35
|
+
from . import utils
|
|
36
|
+
from . import input_processors
|
|
37
|
+
from . import yaml_loader
|
|
38
|
+
from . import download_utils
|
|
39
|
+
from . import model_downloader
|
|
40
|
+
from . import chain_injectors
|
|
41
|
+
|
|
42
|
+
__version__ = "0.1.0"
|
|
43
|
+
|
|
44
|
+
__all__ = [
|
|
45
|
+
"set_app_root",
|
|
46
|
+
"get_app_root",
|
|
47
|
+
"WorkflowAssembler",
|
|
48
|
+
"build_gradio_ui",
|
|
49
|
+
"discover_ui_modules",
|
|
50
|
+
"load_ui_layout",
|
|
51
|
+
"backend_manager",
|
|
52
|
+
"fetch_and_cache_object_info",
|
|
53
|
+
"get_node_info",
|
|
54
|
+
"get_all_node_info",
|
|
55
|
+
"create_job",
|
|
56
|
+
"get_job",
|
|
57
|
+
"update_job",
|
|
58
|
+
"get_latest_running_job_for_module",
|
|
59
|
+
"load_and_merge_yaml",
|
|
60
|
+
"load_and_merge_yaml_from_module",
|
|
61
|
+
"config",
|
|
62
|
+
"workflow_assembler",
|
|
63
|
+
"ui_builder",
|
|
64
|
+
"ui_loader",
|
|
65
|
+
"comfy_api",
|
|
66
|
+
"shared_ui",
|
|
67
|
+
"utils",
|
|
68
|
+
"input_processors",
|
|
69
|
+
"yaml_loader",
|
|
70
|
+
"download_utils",
|
|
71
|
+
"model_downloader",
|
|
72
|
+
"chain_injectors",
|
|
73
|
+
]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import threading
|
|
3
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
4
|
+
from .config import COMFYUI_BACKENDS
|
|
5
|
+
|
|
6
|
+
class BackendManager:
|
|
7
|
+
_instance = None
|
|
8
|
+
_lock = threading.Lock()
|
|
9
|
+
|
|
10
|
+
def __new__(cls, *args, **kwargs):
|
|
11
|
+
if not cls._instance:
|
|
12
|
+
with cls._lock:
|
|
13
|
+
if not cls._instance:
|
|
14
|
+
cls._instance = super(BackendManager, cls).__new__(cls)
|
|
15
|
+
return cls._instance
|
|
16
|
+
|
|
17
|
+
def __init__(self):
|
|
18
|
+
if hasattr(self, '_initialized') and self._initialized:
|
|
19
|
+
return
|
|
20
|
+
|
|
21
|
+
self.backends = COMFYUI_BACKENDS
|
|
22
|
+
self.active_backend_name = "default"
|
|
23
|
+
self._initialized = True
|
|
24
|
+
print(f"[BackendManager] Initialized with default backend '{self.active_backend_name}'.")
|
|
25
|
+
|
|
26
|
+
def get_active_backend_url(self):
|
|
27
|
+
return self.backends.get(self.active_backend_name)
|
|
28
|
+
|
|
29
|
+
def get_all_backend_urls(self):
|
|
30
|
+
return list(self.backends.values())
|
|
31
|
+
|
|
32
|
+
def _free_backend_memory(self, backend_name, backend_url):
|
|
33
|
+
try:
|
|
34
|
+
print(f"[BackendManager] Sending /free request to {backend_name} ({backend_url})...")
|
|
35
|
+
response = requests.post(
|
|
36
|
+
f"{backend_url}/free",
|
|
37
|
+
json={"unload_models": True, "free_memory": True},
|
|
38
|
+
timeout=20
|
|
39
|
+
)
|
|
40
|
+
response.raise_for_status()
|
|
41
|
+
print(f"[BackendManager] Successfully freed memory for {backend_name}.")
|
|
42
|
+
except requests.exceptions.RequestException as e:
|
|
43
|
+
print(f"[BackendManager] Warning: Could not free memory for backend '{backend_name}'. "
|
|
44
|
+
f"Is the backend running and does it support the /free endpoint? Error: {e}")
|
|
45
|
+
|
|
46
|
+
def switch_backend(self, target_backend_name: str):
|
|
47
|
+
if target_backend_name not in self.backends:
|
|
48
|
+
print(f"[BackendManager] Error: Attempted to switch to an unknown backend '{target_backend_name}'. "
|
|
49
|
+
f"Falling back to 'default'.")
|
|
50
|
+
target_backend_name = "default"
|
|
51
|
+
|
|
52
|
+
if self.active_backend_name == target_backend_name:
|
|
53
|
+
print(f"[BackendManager] Backend '{target_backend_name}' is already active. No switch needed.")
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
print(f"[BackendManager] Switching backend from '{self.active_backend_name}' to '{target_backend_name}'...")
|
|
57
|
+
|
|
58
|
+
inactive_backends = {name: url for name, url in self.backends.items() if name != target_backend_name}
|
|
59
|
+
|
|
60
|
+
if inactive_backends:
|
|
61
|
+
print(f"[BackendManager] Freeing up resources on {len(inactive_backends)} inactive backend(s)...")
|
|
62
|
+
with ThreadPoolExecutor(max_workers=len(inactive_backends)) as executor:
|
|
63
|
+
futures = [executor.submit(self._free_backend_memory, name, url) for name, url in inactive_backends.items()]
|
|
64
|
+
for future in futures:
|
|
65
|
+
future.result()
|
|
66
|
+
|
|
67
|
+
self.active_backend_name = target_backend_name
|
|
68
|
+
print(f"[BackendManager] Switch complete. Active backend is now '{self.active_backend_name}'.")
|
|
69
|
+
|
|
70
|
+
backend_manager = BackendManager()
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
def inject(assembler, chain_definition, chain_items):
|
|
2
|
+
if not chain_items:
|
|
3
|
+
return
|
|
4
|
+
|
|
5
|
+
ksampler_names = chain_definition.get('ksampler_node', 'ksampler')
|
|
6
|
+
if not isinstance(ksampler_names, list):
|
|
7
|
+
ksampler_names = [ksampler_names]
|
|
8
|
+
|
|
9
|
+
nodes_injected = 0
|
|
10
|
+
for ksampler_name in ksampler_names:
|
|
11
|
+
if ksampler_name not in assembler.node_map:
|
|
12
|
+
print(f"Warning: [EasyCache Injector] KSampler node '{ksampler_name}' not found. Skipping.")
|
|
13
|
+
continue
|
|
14
|
+
|
|
15
|
+
ksampler_id = assembler.node_map[ksampler_name]
|
|
16
|
+
|
|
17
|
+
if 'model' not in assembler.workflow[ksampler_id]['inputs']:
|
|
18
|
+
print(f"Warning: [EasyCache Injector] KSampler node '{ksampler_name}' is missing 'model' input. Skipping.")
|
|
19
|
+
continue
|
|
20
|
+
|
|
21
|
+
current_model_connection = assembler.workflow[ksampler_id]['inputs']['model']
|
|
22
|
+
|
|
23
|
+
easycache_id = assembler._get_unique_id()
|
|
24
|
+
easycache_node = assembler._get_node_template_from_api("EasyCache")
|
|
25
|
+
|
|
26
|
+
easycache_node['inputs']['reuse_threshold'] = chain_definition.get('reuse_threshold', 0.2)
|
|
27
|
+
easycache_node['inputs']['start_percent'] = chain_definition.get('start_percent', 0.15)
|
|
28
|
+
easycache_node['inputs']['end_percent'] = chain_definition.get('end_percent', 0.95)
|
|
29
|
+
easycache_node['inputs']['verbose'] = chain_definition.get('verbose', False)
|
|
30
|
+
|
|
31
|
+
easycache_node['inputs']['model'] = current_model_connection
|
|
32
|
+
assembler.workflow[easycache_id] = easycache_node
|
|
33
|
+
|
|
34
|
+
assembler.workflow[ksampler_id]['inputs']['model'] = [easycache_id, 0]
|
|
35
|
+
|
|
36
|
+
print(f"EasyCache injector applied. KSampler '{ksampler_name}' model input re-routed through EasyCache node.")
|
|
37
|
+
nodes_injected += 1
|
|
38
|
+
|
|
39
|
+
if nodes_injected > 0:
|
|
40
|
+
print(f"EasyCache injector finished. Applied to {nodes_injected} KSampler node(s).")
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from copy import deepcopy
|
|
2
|
+
|
|
3
|
+
def inject(assembler, chain_definition, chain_items):
|
|
4
|
+
if not chain_items:
|
|
5
|
+
return
|
|
6
|
+
|
|
7
|
+
start_node_name = chain_definition.get('start')
|
|
8
|
+
start_node_id = None
|
|
9
|
+
if start_node_name:
|
|
10
|
+
if start_node_name not in assembler.node_map:
|
|
11
|
+
print(f"Warning: Start node '{start_node_name}' for dynamic LoRA chain not found. Skipping chain.")
|
|
12
|
+
return
|
|
13
|
+
start_node_id = assembler.node_map[start_node_name]
|
|
14
|
+
|
|
15
|
+
output_map = chain_definition.get('output_map', {})
|
|
16
|
+
current_connections = {}
|
|
17
|
+
for key, type_name in output_map.items():
|
|
18
|
+
if ':' in str(key):
|
|
19
|
+
node_name, idx_str = key.split(':')
|
|
20
|
+
if node_name not in assembler.node_map:
|
|
21
|
+
print(f"Warning: Node '{node_name}' in chain's output_map not found. Skipping.")
|
|
22
|
+
continue
|
|
23
|
+
node_id = assembler.node_map[node_name]
|
|
24
|
+
start_output_idx = int(idx_str)
|
|
25
|
+
current_connections[type_name] = [node_id, start_output_idx]
|
|
26
|
+
elif start_node_id:
|
|
27
|
+
start_output_idx = int(key)
|
|
28
|
+
current_connections[type_name] = [start_node_id, start_output_idx]
|
|
29
|
+
else:
|
|
30
|
+
print(f"Warning: LoRA chain has no 'start' node defined, and an output_map key '{key}' is not in 'node:index' format. Skipping this connection.")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
input_map = chain_definition.get('input_map', {})
|
|
34
|
+
chain_output_map = chain_definition.get('template_output_map', { "0": "model", "1": "clip" })
|
|
35
|
+
|
|
36
|
+
for item_data in chain_items:
|
|
37
|
+
template_name = chain_definition['template']
|
|
38
|
+
template = assembler._get_node_template_from_api(template_name)
|
|
39
|
+
node_data = deepcopy(template)
|
|
40
|
+
|
|
41
|
+
for param_name, value in item_data.items():
|
|
42
|
+
if param_name in node_data['inputs']:
|
|
43
|
+
node_data['inputs'][param_name] = value
|
|
44
|
+
|
|
45
|
+
for type_name, input_name in input_map.items():
|
|
46
|
+
if type_name in current_connections:
|
|
47
|
+
node_data['inputs'][input_name] = current_connections[type_name]
|
|
48
|
+
|
|
49
|
+
new_node_id = assembler._get_unique_id()
|
|
50
|
+
assembler.workflow[new_node_id] = node_data
|
|
51
|
+
|
|
52
|
+
for idx_str, type_name in chain_output_map.items():
|
|
53
|
+
current_connections[type_name] = [new_node_id, int(idx_str)]
|
|
54
|
+
|
|
55
|
+
end_input_map = chain_definition.get('end_input_map', {})
|
|
56
|
+
for type_name, targets in end_input_map.items():
|
|
57
|
+
if type_name in current_connections:
|
|
58
|
+
if not isinstance(targets, list):
|
|
59
|
+
targets = [targets]
|
|
60
|
+
|
|
61
|
+
for target_str in targets:
|
|
62
|
+
end_node_name, end_input_name = target_str.split(':')
|
|
63
|
+
if end_node_name in assembler.node_map:
|
|
64
|
+
end_node_id = assembler.node_map[end_node_name]
|
|
65
|
+
assembler.workflow[end_node_id]['inputs'][end_input_name] = current_connections[type_name]
|
|
66
|
+
else:
|
|
67
|
+
print(f"Warning: End node '{end_node_name}' for dynamic chain not found. Skipping connection.")
|