From 5954e6daa0c097f125a62f73b841fdf57c2ce564 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sun, 13 Aug 2023 19:26:48 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(endpoints.py):=20remove=20un?= =?UTF-8?q?used=20import=20'process=5Fgraph=5Fcached'=20and=20replace=20it?= =?UTF-8?q?=20with=20'process=5Fgraph=5Fcached=5Fworker'=20for=20processin?= =?UTF-8?q?g=20graph=20data=20asynchronously=20=F0=9F=94=A7=20fix(endpoint?= =?UTF-8?q?s.py):=20add=20error=20handling=20for=20processing=20tweaks=20a?= =?UTF-8?q?nd=20log=20the=20error=20message=20=E2=9C=A8=20feat(endpoints.p?= =?UTF-8?q?y):=20use=20'process=5Fgraph=5Fcached=5Fworker'=20to=20process?= =?UTF-8?q?=20graph=20data=20asynchronously=20and=20return=20the=20result?= =?UTF-8?q?=20in=20'ProcessResponse'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/endpoints.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/api/v1/endpoints.py b/src/backend/langflow/api/v1/endpoints.py index 24af55588..34f81cecf 100644 --- a/src/backend/langflow/api/v1/endpoints.py +++ b/src/backend/langflow/api/v1/endpoints.py @@ -3,10 +3,10 @@ from typing import Annotated, Optional from langflow.cache.utils import save_uploaded_file from langflow.database.models.flow import Flow -from langflow.processing.process import process_graph_cached, process_tweaks +from langflow.processing.process import process_tweaks from langflow.utils.logger import logger from langflow.settings import settings - +from langflow.worker import process_graph_cached as process_graph_cached_worker from fastapi import APIRouter, Depends, HTTPException, UploadFile, Body from langflow.interface.custom.custom_component import CustomComponent @@ -90,7 +90,12 @@ async def process_flow( graph_data = process_tweaks(graph_data, tweaks) except Exception as exc: logger.error(f"Error processing tweaks: {exc}") - response = process_graph_cached(graph_data, inputs, clear_cache) + # ! This was added just for testing purposes + response = process_graph_cached_worker.delay( + graph_data=graph_data, + inputs=inputs, + clear_cache=clear_cache, + ).get() return ProcessResponse( result=response, )