From ce6760492609ae3523336edebab210b9ad647a68 Mon Sep 17 00:00:00 2001 From: nick Date: Fri, 4 Oct 2024 17:34:50 -0700 Subject: [PATCH] stuff --- custom_routes.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/custom_routes.py b/custom_routes.py index 899383d..ec40622 100644 --- a/custom_routes.py +++ b/custom_routes.py @@ -222,6 +222,7 @@ create_native_run_endpoint = None status_endpoint = None file_upload_endpoint = None + def clear_current_prompt(sid): prompt_server = server.PromptServer.instance to_delete = list( @@ -422,25 +423,22 @@ def send_prompt(sid: str, inputs: StreamingPrompt): logger.info(f"error: {error_type}, {e}") logger.info(f"stack trace: {stack_trace_short}") - # # Add custom logic here # if 'prompt_id' in response: # prompt_id = response['prompt_id'] # if prompt_id in prompt_metadata: # metadata = prompt_metadata[prompt_id] - + # # Add additional information to the response # response['status_endpoint'] = metadata.status_endpoint # response['file_upload_endpoint'] = metadata.file_upload_endpoint - - return response @server.PromptServer.instance.routes.post("/comfyui-deploy/run") async def comfy_deploy_run(request): # Extract the bearer token from the Authorization header data = await request.json() - + client_id = data.get("client_id") # We proxy the request to Comfy Deploy, this is a native run if "is_native_run" in data: @@ -448,13 +446,17 @@ async def comfy_deploy_run(request): pprint(data) # headers = request.headers.copy() # headers['Content-Type'] = 'application/json' - async with session.post(data.get("native_run_api_endpoint"), json=data, headers={ - 'Content-Type': 'application/json', - 'Authorization': request.headers.get('Authorization') - }) as response: + async with session.post( + data.get("native_run_api_endpoint"), + json=data, + headers={ + "Content-Type": "application/json", + "Authorization": request.headers.get("Authorization"), + }, + ) as response: data = await response.json() print(data) - + if "cd_token" in data: token = data["cd_token"] else: