h3-blackwell-runtime/tools/replay_comfy_history.py
2026-08-12 14:12:42 +07:00

23 lines
660 B
Python

"""Replay an exact completed ComfyUI prompt by history id."""
import argparse
import json
from urllib.request import Request, urlopen
parser = argparse.ArgumentParser()
parser.add_argument("history_id")
parser.add_argument("--endpoint", default="http://localhost:8188")
args = parser.parse_args()
with urlopen(f"{args.endpoint}/history") as response:
history = json.load(response)
prompt = history[args.history_id]["prompt"][2]
request = Request(
f"{args.endpoint}/prompt",
data=json.dumps({"prompt": prompt}).encode(),
headers={"Content-Type": "application/json"},
)
with urlopen(request) as response:
print(response.read().decode())