Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Allow the prompt request to specify the prompt ID. (#8189)

FeepingCreature260a5ca5d999
diff --git a/script_examples/websockets_api_example.py b/script_examples/websockets_api_example.py
index d696d2bba..58f26cfb6 100644
--- a/script_examples/websockets_api_example.py
+++ b/script_examples/websockets_api_example.py
@@ -10,11 +10,11 @@ import urllib.parse
server_address = "127.0.0.1:8188"
client_id = str(uuid.uuid4())
-def queue_prompt(prompt):
- p = {"prompt": prompt, "client_id": client_id}
+def queue_prompt(prompt, prompt_id):
+ p = {"prompt": prompt, "client_id": client_id, "prompt_id": prompt_id}
data = json.dumps(p).encode('utf-8')
- req = urllib.request.Request("http://{}/prompt".format(server_address), data=data)
- return json.loads(urllib.request.urlopen(req).read())
+ req = urllib.request.Request("http://{}/prompt".format(server_address), data=data)
+ urllib.request.urlopen(req).read()
def get_image(filename, subfolder, folder_type):
data = {"filename": filename, "subfolder": subfolder, "type": folder_type}
@@ -27,7 +27,8 @@ def get_history(prompt_id):
return json.loads(response.read())
def get_images(ws, prompt):
- prompt_id = queue_prompt(prompt)['prompt_id']
+ prompt_id = str(uuid.uuid4())
+ queue_prompt(prompt, prompt_id)
output_images = {}
while True:
out = ws.recv()
diff --git a/server.py b/server.py
index e8bad9f4e..71a58f0fa 100644
--- a/server.py
+++ b/server.py
@@ -678,7 +678,7 @@ class PromptServer():
if "prompt" in json_data:
prompt = json_data["prompt"]
- prompt_id = str(uuid.uuid4())
+ prompt_id = str(json_data.get("prompt_id", uuid.uuid4()))
valid = await execution.validate_prompt(prompt_id, prompt)
extra_data = {}
if "extra_data" in json_data: