🐛 fix(endpoints.py): handle ImportError when importing langflow.worker.process_graph_cached_task to prevent crash when Celery is not installed

🔥 chore(endpoints.py): remove unused import of langflow.worker.process_graph_cached_task
🔀 chore(endpoints.py): refactor process_flow function to handle different result types from task_service.launch_task
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-09-17 19:35:59 -03:00
commit c7fc8444ea

View file

@ -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(