From c7fc8444ea277096563c0547e024fe74dba264a5 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 17 Sep 2023 19:35:59 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(endpoints.py):=20handle=20Im?= =?UTF-8?q?portError=20when=20importing=20langflow.worker.process=5Fgraph?= =?UTF-8?q?=5Fcached=5Ftask=20to=20prevent=20crash=20when=20Celery=20is=20?= =?UTF-8?q?not=20installed=20=F0=9F=94=A5=20chore(endpoints.py):=20remove?= =?UTF-8?q?=20unused=20import=20of=20langflow.worker.process=5Fgraph=5Fcac?= =?UTF-8?q?hed=5Ftask=20=F0=9F=94=80=20chore(endpoints.py):=20refactor=20p?= =?UTF-8?q?rocess=5Fflow=20function=20to=20handle=20different=20result=20t?= =?UTF-8?q?ypes=20from=20task=5Fservice.launch=5Ftask?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/endpoints.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/api/v1/endpoints.py b/src/backend/langflow/api/v1/endpoints.py index ec107092b..57b0c6958 100644 --- a/src/backend/langflow/api/v1/endpoints.py +++ b/src/backend/langflow/api/v1/endpoints.py @@ -30,7 +30,15 @@ from langflow.interface.types import ( ) from langflow.services.utils import get_session -from langflow.worker import process_graph_cached_task + +try: + from langflow.worker import process_graph_cached_task +except ImportError: + + def process_graph_cached_task(*args, **kwargs): + raise NotImplementedError("Celery is not installed") + + from sqlmodel import Session @@ -143,7 +151,10 @@ async def process_flow( clear_cache, session_id, ) - task_result = result.result + if isinstance(result, dict) and "result" in result: + task_result = result["result"] + else: + task_result = result.result session_id = result.session_id else: task_id, task = await task_service.launch_task(