mirror of
https://github.com/langgenius/dify.git
synced 2026-03-12 10:38:54 +08:00
WIP: resume
This commit is contained in:
@ -107,6 +107,7 @@ class ConsoleHumanInputFormApi(Resource):
|
||||
parser.add_argument("inputs", type=dict, required=True, location="json")
|
||||
parser.add_argument("action", type=str, required=True, location="json")
|
||||
args = parser.parse_args()
|
||||
current_user, _ = current_account_with_tenant()
|
||||
|
||||
# Submit the form
|
||||
service = HumanInputService(db.engine)
|
||||
@ -114,6 +115,7 @@ class ConsoleHumanInputFormApi(Resource):
|
||||
form_id=form_id,
|
||||
selected_action_id=args["action"],
|
||||
form_data=args["inputs"],
|
||||
user=current_user,
|
||||
)
|
||||
|
||||
return jsonify({})
|
||||
|
||||
@ -70,6 +70,7 @@ class HumanInputFormApi(WebApiResource):
|
||||
form_token=web_app_form_token,
|
||||
selected_action_id=args["action"],
|
||||
form_data=args["inputs"],
|
||||
submission_end_user_id=_end_user.id,
|
||||
)
|
||||
except FormNotFoundError:
|
||||
raise NotFoundError("Form not found")
|
||||
|
||||
@ -3,7 +3,6 @@ Web App Workflow Resume APIs.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import time
|
||||
from collections.abc import Generator
|
||||
|
||||
from flask import Response
|
||||
@ -14,42 +13,6 @@ from controllers.web.wraps import WebApiResource
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WorkflowResumeWaitApi(WebApiResource):
|
||||
"""API for long-polling workflow resume wait."""
|
||||
|
||||
def get(self, task_id: str):
|
||||
"""
|
||||
Get workflow execution resume notification.
|
||||
|
||||
GET /api/workflow/<task_id>/resume-wait
|
||||
|
||||
This is a long-polling API that waits for workflow to resume from paused state.
|
||||
"""
|
||||
# TODO: Implement actual workflow status checking
|
||||
# For now, return a basic response
|
||||
|
||||
timeout = 30 # 30 seconds timeout for demo
|
||||
start_time = time.time()
|
||||
|
||||
while time.time() - start_time < timeout:
|
||||
# TODO: Check workflow status from database/cache
|
||||
# workflow_status = workflow_service.get_status(task_id)
|
||||
|
||||
# For demo purposes, simulate different states
|
||||
# In real implementation, this would check the actual workflow state
|
||||
workflow_status = "paused" # or "running" or "ended"
|
||||
|
||||
if workflow_status == "running":
|
||||
return {"status": "running"}, 200
|
||||
elif workflow_status == "ended":
|
||||
return {"status": "ended"}, 200
|
||||
|
||||
time.sleep(1) # Poll every second
|
||||
|
||||
# Return paused status if timeout reached
|
||||
return {"status": "paused"}, 200
|
||||
|
||||
|
||||
class WorkflowEventsApi(WebApiResource):
|
||||
"""API for getting workflow execution events after resume."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user