diff --git a/backend/open_webui/tasks.py b/backend/open_webui/tasks.py index 89c4b017ed..37c165bf04 100644 --- a/backend/open_webui/tasks.py +++ b/backend/open_webui/tasks.py @@ -166,3 +166,19 @@ async def stop_task(redis, task_id: str): return {"status": True, "message": f"Task {task_id} successfully stopped."} return {"status": False, "message": f"Failed to stop task {task_id}."} + + +async def stop_item_tasks(redis: Redis, item_id: str): + """ + Stop all tasks associated with a specific item ID. + """ + task_ids = await list_task_ids_by_item_id(redis, item_id) + if not task_ids: + return {"status": True, "message": f"No tasks found for item {item_id}."} + + for task_id in task_ids: + result = await stop_task(redis, task_id) + if not result["status"]: + return result # Return the first failure + + return {"status": True, "message": f"All tasks for item {item_id} stopped."} diff --git a/backend/requirements.txt b/backend/requirements.txt index 8dceea395f..34e4036f68 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -31,6 +31,8 @@ boto3==1.35.53 argon2-cffi==23.1.0 APScheduler==3.10.4 +pycrdt==0.12.25 + RestrictedPython==8.0 loguru==0.7.3