- ComfyUI custom nodes: BridgeInput (11 types) + BridgeOutput
- AnyType wildcard for universal output capture
- Custom server route: GET /comfybridge/results/{prompt_id}
- Python async client (ComfyBridge) + sync wrapper (ComfyBridgeSync)
- Workflow JSON parser and patcher (deepcopy, original unchanged)
- WebSocket completion detection
- BridgeResult container with PIL/bytes helpers
- Examples: basic_text_to_image.py, agent_loop.py
- Unit tests for workflow parser and client
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
868 B
Python
25 lines
868 B
Python
"""타입 상수 및 Python ↔ ComfyUI 값 변환 유틸리티."""
|
|
|
|
from typing import Any
|
|
|
|
PRIMITIVE_TYPES = {"STRING", "INT", "FLOAT", "BOOLEAN"}
|
|
COMPLEX_TYPES = {"IMAGE", "MASK", "LATENT", "MODEL", "CLIP", "VAE", "CONDITIONING"}
|
|
ALL_TYPES = PRIMITIVE_TYPES | COMPLEX_TYPES
|
|
|
|
|
|
def convert_value(value: Any, type_name: str) -> Any:
|
|
"""
|
|
Python 값을 ComfyUI 워크플로우 JSON에 주입 가능한 형태로 변환한다.
|
|
복합 타입(IMAGE 등)은 업로드 후 파일명(str)을 그대로 전달한다.
|
|
"""
|
|
if type_name == "STRING":
|
|
return str(value)
|
|
if type_name == "INT":
|
|
return int(value)
|
|
if type_name == "FLOAT":
|
|
return float(value)
|
|
if type_name == "BOOLEAN":
|
|
return bool(value)
|
|
# 복합 타입: 노드 링크 [node_id, idx] 또는 서버 파일명(str)을 그대로 반환
|
|
return value
|