🐛 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.services.utils import get_session
try:
from langflow.worker import process_graph_cached_task 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 from sqlmodel import Session
@ -143,6 +151,9 @@ async def process_flow(
clear_cache, clear_cache,
session_id, session_id,
) )
if isinstance(result, dict) and "result" in result:
task_result = result["result"]
else:
task_result = result.result task_result = result.result
session_id = result.session_id session_id = result.session_id
else: else: