Files
cbpark84andClaude Sonnet 4.6 9a2bcdd4fa feat: initial project structure for ComfyBridgeIO
- 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>
2026-07-16 10:45:26 +09:00

37 lines
1.1 KiB
Python

"""
AI Agent 루프 예제.
AI가 여러 번 워크플로우를 호출하며 결과를 평가하는 패턴.
"""
import asyncio
from comfybridgeio import ComfyBridge
async def generate_image(bridge: ComfyBridge, prompt: str, seed: int) -> bytes:
result = await bridge.run(
workflow="workflows/sdxl_bridge_template.json",
inputs={"prompt": prompt, "seed": seed, "steps": 25},
)
return result.as_bytes("output_image")
async def main():
bridge = ComfyBridge(host="localhost", port=8188)
prompts = [
"a red apple on a wooden table, photorealistic",
"a blue ocean at sunset, cinematic",
"a futuristic city at night, neon lights",
]
for i, prompt in enumerate(prompts):
print(f"Generating [{i+1}/{len(prompts)}]: {prompt[:50]}...")
img_bytes = await generate_image(bridge, prompt, seed=i * 1000)
out_path = f"output_{i}.png"
with open(out_path, "wb") as f:
f.write(img_bytes)
print(f" Saved: {out_path}")
if __name__ == "__main__":
asyncio.run(main())