From 643bcfa42d82cdef1f19cc14af008b1f2787a1c0 Mon Sep 17 00:00:00 2001 From: puke Date: Wed, 14 May 2025 18:56:09 +0800 Subject: [PATCH] update README.md --- README.md | 12 ++++-------- README_CN.md | 12 ++++-------- oneapi.py | 6 +++--- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c7d180f..307af6f 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,7 @@ Request Body: "workflow": {Workflow JSON}, "params": { "paramName": "paramValue" - }, - "wait_for_result": true, - "timeout": 300 + } } ``` @@ -43,7 +41,7 @@ To use dynamic parameters in your workflow, you need to use special markers in t Examples: -- A LoadImage node marked with `$input_image` will use the input_image parameter from params as the image filename +- A LoadImage node marked with `$input_image` will use the input_image parameter from params as the image param - A CLIPTextEncode node marked with `$prompt.text` will replace the text field with the prompt parameter from params ## Examples @@ -59,8 +57,7 @@ curl -X POST "http://localhost:8188/oneapi/v1/execute" \ "workflow": '"$(cat workflows/example_workflow.json)"', "params": { "prompt": "a cute dog with a red hat" - }, - "wait_for_result": true + } }' ``` @@ -75,8 +72,7 @@ curl -X POST "http://localhost:8188/oneapi/v1/execute" \ "params": { "prompt": "a cute dog with a red hat", "image": "https://example.com/input.jpg" - }, - "wait_for_result": true + } }' ``` diff --git a/README_CN.md b/README_CN.md index 4082d4c..65ca52a 100644 --- a/README_CN.md +++ b/README_CN.md @@ -28,9 +28,7 @@ POST /oneapi/v1/execute "workflow": {工作流JSON}, "params": { "参数名": "参数值" - }, - "wait_for_result": true, - "timeout": 300 + } } ``` @@ -43,7 +41,7 @@ POST /oneapi/v1/execute 例如: -- 标记为 `$input_image` 的LoadImage节点,将使用params中的input_image参数作为图片文件名 +- 标记为 `$input_image` 的LoadImage节点,将使用params中的input_image参数作为图片参数 - 标记为 `$prompt.text` 的CLIPTextEncode节点,将使用params中的prompt参数替换text字段 ## 示例 @@ -59,8 +57,7 @@ curl -X POST "http://localhost:8188/oneapi/v1/execute" \ "workflow": '"$(cat workflows/example_workflow.json)"', "params": { "prompt": "a cute dog with a red hat" - }, - "wait_for_result": true + } }' ``` @@ -75,8 +72,7 @@ curl -X POST "http://localhost:8188/oneapi/v1/execute" \ "params": { "prompt": "a cute dog with a red hat", "image": "https://example.com/input.jpg" - }, - "wait_for_result": true + } }' ``` diff --git a/oneapi.py b/oneapi.py index 14efb1f..2c6103f 100644 --- a/oneapi.py +++ b/oneapi.py @@ -37,7 +37,7 @@ async def execute_workflow(request): workflow = data.get('workflow') params = data.get('params', {}) wait_for_result = data.get('wait_for_result', True) - timeout = data.get('timeout', 300) + timeout = data.get('timeout', None) if not workflow: return web.json_response({"error": "Workflow data is missing"}, status=400) @@ -320,7 +320,7 @@ async def _get_base_url(request): return base_url -async def _wait_for_results(prompt_id, timeout=300, request=None): +async def _wait_for_results(prompt_id, timeout=None, request=None): """Wait for workflow execution results, get history using HTTP API""" start_time = time.time() result = { @@ -334,7 +334,7 @@ async def _wait_for_results(prompt_id, timeout=300, request=None): while True: # Check timeout - if timeout > 0 and (time.time() - start_time) > timeout: + if timeout is not None and timeout > 0 and (time.time() - start_time) > timeout: result["status"] = "timeout" return result